-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: dynamic port in test cluster disconnect #12545
test: dynamic port in test cluster disconnect #12545
Conversation
Uhm. I'm not really sure why the |
Not your fault, timeout issue. CI can be considered Green on Windows. |
@@ -47,6 +47,7 @@ if (cluster.isWorker) { | |||
// check result | |||
socket.on('end', common.mustCall(() => { | |||
cb(result === 'echo'); | |||
server_ports.splice(server_ports.indexOf(port)); |
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.
Shouldn't the second argument of splice
be 1
?
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're absolutely right. Thanks for pointing that out. I missed it somehow. I've pushed the changes.
@@ -72,7 +73,11 @@ if (cluster.isWorker) { | |||
let online = 0; | |||
|
|||
for (let i = 0, l = workers; i < l; i++) { | |||
cluster.fork().on('listening', common.mustCall(() => { | |||
cluster.fork().on('listening', common.mustCall((address) => { | |||
if (server_ports.indexOf(address.port) === -1) { |
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.
Nit: if this change will not be backported to v4 we can use Array.prototype.includes()
instead of Array.prototype.indexOf()
.
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.
Please let me know if I should change it. It will also require a new CI build.
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.
IMHO can land as is (found 433 hits to indexOf
in /test/*.js
)
@lpinca since v4 entered maintenance, do you think we can eliminate all 433 now (in a different PR)?
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.
@refack yes, not sure if it's worth the effort though.
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'm looking at https://ci.nodejs.org/job/node-test-commit-linux/nodes=fedora22/9316/console and I can't tell why it failed. Help? |
@sebastianplesciuc Infrastructure failure, don't worry about it. That buildbot is getting the ax soon anyway (ref). |
@@ -72,7 +73,11 @@ if (cluster.isWorker) { | |||
let online = 0; | |||
|
|||
for (let i = 0, l = workers; i < l; i++) { | |||
cluster.fork().on('listening', common.mustCall(() => { | |||
cluster.fork().on('listening', common.mustCall((address) => { | |||
if (server_ports.indexOf(address.port) === -1) { |
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.
IMHO can land as is (found 433 hits to indexOf
in /test/*.js
)
@lpinca since v4 entered maintenance, do you think we can eliminate all 433 now (in a different PR)?
} else if (cluster.isMaster) { | ||
const servers = 2; | ||
const server_ports = []; |
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.
Please use camelCase in JavaScript code.
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.
@cjihrig Fixed! Thank you!
@@ -72,7 +73,11 @@ if (cluster.isWorker) { | |||
let online = 0; | |||
|
|||
for (let i = 0, l = workers; i < l; i++) { | |||
cluster.fork().on('listening', common.mustCall(() => { | |||
cluster.fork().on('listening', common.mustCall((address) => { | |||
if (serverPorts.indexOf(address.port) === -1) { |
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.
Will we be backporting PRs that fix potentially flaky tests to v4.x? If not (or these common.PORT
tests will just be moved to sequential
in v4.x), using Array.prototype.includes()
might be more readable here.
/cc @nodejs/lts
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.
Will we be backporting PRs that fix potentially flaky tests to v4.x?
Almost certainly not. ! serverPorts.includes(address.port)
should be fine here.
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.
Changed it to use includes
and rebased this branch to the latest master. Thanks!
@@ -47,6 +47,7 @@ if (cluster.isWorker) { | |||
// check result | |||
socket.on('end', common.mustCall(() => { | |||
cb(result === 'echo'); | |||
serverPorts.splice(serverPorts.indexOf(port), 1); |
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 might want to use a Set
, not an array.
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.
@aqrln Changed to use Set
. Thank you!
Removed common.PORT from test-cluster-disconnect to eliminate the possibility that a port used in another test will collide with common.PORT. Refs: #12376
Landed in bee250c |
Removed common.PORT from test-cluster-disconnect to eliminate the possibility that a port used in another test will collide with common.PORT. PR-URL: #12545 Refs: #12376 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
Adding the |
Removed common.PORT from test-cluster-disconnect to eliminate the possibility that a port used in another test will collide with common.PORT. PR-URL: nodejs#12545 Refs: nodejs#12376 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
Removed common.PORT from test-cluster-disconnect to eliminate the possibility that a port used in another test will collide with common.PORT. PR-URL: #12545 Refs: #12376 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
Removed common.PORT from test-cluster-disconnect to eliminate the possibility that a port used in another test will collide with common.PORT. PR-URL: #12545 Refs: #12376 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
Removed common.PORT from test-cluster-disconnect to eliminate the
possibility that a dynamic port used in another test will collide
with common.PORT.
Refs: #12376
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test