Skip to content
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-cluster-net-listen-ipv6only-none and related #29681

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ const WORKER_ACCOUNT = 3;

if (cluster.isMaster) {
const workers = new Map();
let address;

const countdown = new Countdown(WORKER_ACCOUNT, () => {
// Make sure the `ipv6Only` option works.
// Make sure the `ipv6Only` option works. This is the part of the test that
// requires the whole test to use `common.PORT` rather than port `0`. If it
// used port `0` instead, then the operating system can supply a port that
// is available for the IPv6 interface but in use by the IPv4 interface.
// Refs: https://github.com/nodejs/node/issues/29679
const server = net.createServer().listen({
host: '0.0.0.0',
port: address.port,
port: common.PORT,
}, common.mustCall(() => {
// Exit.
server.close();
Expand All @@ -37,13 +40,9 @@ if (cluster.isMaster) {
const worker = cluster.fork().on('exit', common.mustCall((statusCode) => {
assert.strictEqual(statusCode, 0);
})).on('listening', common.mustCall((workerAddress) => {
if (!address) {
address = workerAddress;
} else {
assert.strictEqual(address.addressType, workerAddress.addressType);
assert.strictEqual(address.host, workerAddress.host);
assert.strictEqual(address.port, workerAddress.port);
}
assert.strictEqual(workerAddress.addressType, 6);
assert.strictEqual(workerAddress.address, host);
assert.strictEqual(workerAddress.port, common.PORT);
countdown.dec();
}));

Expand All @@ -52,7 +51,7 @@ if (cluster.isMaster) {
} else {
net.createServer().listen({
host,
port: 0,
port: common.PORT,
ipv6Only: true,
}, common.mustCall());
}