Skip to content

Commit d8f5f55

Browse files
gireeshpunathiladdaleax
authored andcommitted
test: eliminate port collision
In test test-cluster-net-listen-ipv6only-rr, the cluster member that listens to `any` port actually has the potential to `grab` any port from the environment which when passed onto the master causes collision when it tries to listen on. Moving the test to sequential alone is not sufficient as the cluster member can in theory catch on to the admin ports on the host. Assigning static port alone is also not sufficient, as it can interfere with other running tests in the parallel category which would be mostly running with `port: any` fashion. So move to sequential, and use a static port. Fixes: #25813 PR-URL: #26298 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 1abe1d1 commit d8f5f55

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/parallel/test-cluster-net-listen-ipv6only-rr.js test/sequential/test-cluster-net-listen-ipv6only-rr.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ if (cluster.isMaster) {
4848
workers.set(i, worker);
4949
}
5050
} else {
51+
// As the cluster member has the potential to grab any port
52+
// from the environment, this can cause collision when master
53+
// obtains the port from cluster member and tries to listen on.
54+
// So move this to sequential, and provide a static port.
55+
// Refs: https://github.com/nodejs/node/issues/25813
5156
net.createServer().listen({
52-
host,
53-
port: 0,
57+
host: host,
58+
port: common.PORT,
5459
ipv6Only: true,
5560
}, common.mustCall());
5661
}

0 commit comments

Comments
 (0)