-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: move net reconnect error test to sequential #13033
Conversation
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.
LGTM
There is a comment on the test
which I think can be removed now. Calls to |
[non blocking opinion] |
Hi, I've removed the comment, as @lpinca mentioned. |
@refack Could you take a look and let me know if this is what you meant? If not could you point me in the right direction? Not sure how to use common.mustNotCall. |
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.
👍
I checked on the lint errors. Everything should be good to go. |
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.
The changes introduced here greatly change the test. Previously, there were 20 attempted connections, now there is only 1. This is not a refactor; this is a change. Should be in a separate PR if at all.
By the way, the change from 20 attempted connections to just 1 seems likely to defeat the purpose of the test, as the test name contains I'm not opposed to refactoring a test that is being moved in general, but I don't know that I would have recommended it here where you already had a bunch of reviews/approvals. |
Good point, I will revert it back to the original test. |
})); | ||
|
||
c.on('close', common.mustCall(() => { | ||
once(() => c.connect(common.PORT)); // reconnect |
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.
Yep @Trott is right, this should run N
times
I have made the requested changes. |
@@ -27,19 +27,16 @@ const N = 20; | |||
let client_error_count = 0; | |||
let disconnect_count = 0; | |||
|
|||
// Hopefully nothing is running on common.PORT | |||
const c = net.createConnection(common.PORT); | |||
|
|||
c.on('connect', common.mustNotCall('client should not have connected')); | |||
|
|||
c.on('error', function(e) { |
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.
You could try to add `common.mustCall(..., 20) here and on line 39
I know we're driving you crazy back and forth, sorry... |
No worries. I am most interested in getting it right. I don't mind. |
client_error_count++; | ||
assert.strictEqual('ECONNREFUSED', e.code); | ||
}); | ||
}, 21)); |
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.
You could use N + 1
if (disconnect_count++ < N) | ||
c.connect(common.PORT); // reconnect | ||
}); | ||
}, 21)); | ||
|
||
process.on('exit', function() { |
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.
[suggestion]
I see here an interesting point. Think about this handler...
On the one hand you have the mustCall
count that verified each operation is called 21 time.
On the other hand you already have these numbers calculated, so why not check them.
From my perspective it's totally up to you to decide, but thinking about it IMHO is the important part.
Stress on freeBSD (100 x all |
The usage of common.PORT could cause undesired port collisions when run in parallel. The following test was moved to sequential. test-net-reconnect-error.js Ref: #12376
@refack I made the first changes you requested and used N + 1, but not sure what would be the desired change on the second request entry, the one about the 'exit' handler. If you could clarify. Thanks |
👍 P.S. Stress test seems to pass. |
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.
LGTM if CI is green. Thanks for sticking with it!
@refack I think that since those variables are used in the test, that we should track their input and output values. As a way to make certain that the test framing stays together, making sure that their values are known helps to understand the test, and have expectations as to results. |
Sounds like a good reason to me. Thank you for taking the time to indulge me 👍 |
CI: https://ci.nodejs.org/job/node-test-commit/10039/ |
landed in c60a7fa |
The usage of common.PORT could cause undesired port collisions when run in parallel. The following test was moved to sequential. test-net-reconnect-error.js PR-URL: #13033 Refs: #12376 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Post land CI: https://ci.nodejs.org/job/node-test-commit/10041/ |
The usage of common.PORT could cause undesired port collisions when run in parallel. The following test was moved to sequential. test-net-reconnect-error.js PR-URL: #13033 Refs: #12376 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
The usage of common.PORT could cause undesired port collisions when run
in parallel. The following test was moved to sequential.
test-net-reconnect-error.js
Ref: #12376
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test net