-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: fix flaky test-net-socket-local-address #4644
Conversation
The close event can fire twice if close is called twice. Move checks to exit event for process instead. Ref: nodejs#4476
Stress CI without the fix: https://ci.nodejs.org/job/node-stress-single-test/334/nodes=win-vs2015/console Stress CI with this fix: https://ci.nodejs.org/job/node-stress-single-test/337/nodes=win-vs2015/console |
LGTM |
assert.deepEqual(clientLocalPorts, serverRemotePorts, | ||
'client and server should agree on the ports used'); | ||
assert.equal(2, conns); | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be changed to common.mustCall(fn, 2)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as the test was written. Most of the times, it would run once, but every once in a while on Windows (and possibly elsewhere, but definitely on Windows), it would run twice.
In a stress test run, the test ran 9999 times on Windows. 9988 times, the function ran once. But 11 times, the test failed because it ran twice.
Changes LGTM, but shouldn't we be able to reliably determine how many times the |
@cjihrig My original fix for this was to put in a boolean that indicated whether or not I refactored it to The race condition exists because the client connection callback calls |
@cjihrig Took a look. It looked good, but when I tried to confirm that it still triggered an assertion in Node 3.0.0 (by converting ES6 stuff to ES5), the test passed instead. So it no longer tests for the bug it was written to find. Then it occurred to me that I didn't do a similar thing for this version of the test in this PR. So I've done that now and I can report that it still triggers the error:
So that's good. For the record, here's the version of the test in this PR with unsupported-in-3.0.0 features rewritten or commented out:
If you can come up with a simpler test in that other PR that still finds the bug the test was written for, I'm happy to go with that instead of this PR, of course. |
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: #4476 Refs: #4644 PR-URL: #4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Closing in favor of #4650. |
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: #4476 Refs: #4644 PR-URL: #4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: #4476 Refs: #4644 PR-URL: #4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: #4476 Refs: #4644 PR-URL: #4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: nodejs#4476 Refs: nodejs#4644 PR-URL: nodejs#4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: nodejs#4476 Refs: nodejs#4644 PR-URL: nodejs#4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic. Refs: nodejs#4476 Refs: nodejs#4644 PR-URL: nodejs#4650 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
The close event can fire twice if close is called twice. Move checks
to exit event for process instead.
Ref: #4476