Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a6b7b0

Browse filesBrowse files
Trotttargos
authored andcommitted
test: fix flaky test-cluster-net-listen-ipv6only-none
test-cluster-net-listen-ipv6only-none was using port `0` for an IPv6-only operation and assuming that the operating system would supply a port that was also available in IPv4. However, CI results seem to indicate that a port can be supplied that is in use by IPv4 but available to IPv6, resulting in the test failing. Use `common.PORT` to avoid this issue. Fixes: #29679 PR-URL: #29681 Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 298d927 commit 2a6b7b0
Copy full SHA for 2a6b7b0

File tree

Expand file treeCollapse file tree

1 file changed

+10
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-11
lines changed
Open diff view settings
Collapse file

‎…test-cluster-net-listen-ipv6only-none.js‎ ‎…test-cluster-net-listen-ipv6only-none.js‎test/parallel/test-cluster-net-listen-ipv6only-none.js renamed to test/sequential/test-cluster-net-listen-ipv6only-none.js test/parallel/test-cluster-net-listen-ipv6only-none.js renamed to test/sequential/test-cluster-net-listen-ipv6only-none.js

Copy file name to clipboardExpand all lines: test/sequential/test-cluster-net-listen-ipv6only-none.js
+10-11Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ const WORKER_ACCOUNT = 3;
1717

1818
if (cluster.isMaster) {
1919
const workers = new Map();
20-
let address;
2120

2221
const countdown = new Countdown(WORKER_ACCOUNT, () => {
23-
// Make sure the `ipv6Only` option works.
22+
// Make sure the `ipv6Only` option works. This is the part of the test that
23+
// requires the whole test to use `common.PORT` rather than port `0`. If it
24+
// used port `0` instead, then the operating system can supply a port that
25+
// is available for the IPv6 interface but in use by the IPv4 interface.
26+
// Refs: https://github.com/nodejs/node/issues/29679
2427
const server = net.createServer().listen({
2528
host: '0.0.0.0',
26-
port: address.port,
29+
port: common.PORT,
2730
}, common.mustCall(() => {
2831
// Exit.
2932
server.close();
@@ -37,13 +40,9 @@ if (cluster.isMaster) {
3740
const worker = cluster.fork().on('exit', common.mustCall((statusCode) => {
3841
assert.strictEqual(statusCode, 0);
3942
})).on('listening', common.mustCall((workerAddress) => {
40-
if (!address) {
41-
address = workerAddress;
42-
} else {
43-
assert.strictEqual(address.addressType, workerAddress.addressType);
44-
assert.strictEqual(address.host, workerAddress.host);
45-
assert.strictEqual(address.port, workerAddress.port);
46-
}
43+
assert.strictEqual(workerAddress.addressType, 6);
44+
assert.strictEqual(workerAddress.address, host);
45+
assert.strictEqual(workerAddress.port, common.PORT);
4746
countdown.dec();
4847
}));
4948

@@ -52,7 +51,7 @@ if (cluster.isMaster) {
5251
} else {
5352
net.createServer().listen({
5453
host,
55-
port: 0,
54+
port: common.PORT,
5655
ipv6Only: true,
5756
}, common.mustCall());
5857
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.