mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
15164cebce
Doc deprecate isMaster and setupMaster in favor of isPrimary and setupPrimary. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/36478 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasIPv6)
|
|
common.skip('no IPv6 support');
|
|
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const net = require('net');
|
|
|
|
// This test ensures that the `ipv6Only` option in `net.Server.listen()`
|
|
// works as expected when we use cluster with `SCHED_NONE` schedulingPolicy.
|
|
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
|
const host = '::';
|
|
const WORKER_ACCOUNT = 3;
|
|
|
|
if (cluster.isPrimary) {
|
|
const workers = [];
|
|
|
|
for (let i = 0; i < WORKER_ACCOUNT; i += 1) {
|
|
const myWorker = new Promise((resolve) => {
|
|
const worker = cluster.fork().on('exit', common.mustCall((statusCode) => {
|
|
assert.strictEqual(statusCode, 0);
|
|
})).on('listening', common.mustCall((workerAddress) => {
|
|
assert.strictEqual(workerAddress.addressType, 6);
|
|
assert.strictEqual(workerAddress.address, host);
|
|
assert.strictEqual(workerAddress.port, common.PORT);
|
|
resolve(worker);
|
|
}));
|
|
});
|
|
|
|
workers.push(myWorker);
|
|
}
|
|
|
|
Promise.all(workers).then(common.mustCall((resolvedWorkers) => {
|
|
// 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: common.PORT,
|
|
}, common.mustCall(() => {
|
|
// Exit.
|
|
server.close();
|
|
resolvedWorkers.forEach((resolvedWorker) => {
|
|
resolvedWorker.disconnect();
|
|
});
|
|
}));
|
|
}));
|
|
} else {
|
|
net.createServer().listen({
|
|
host,
|
|
port: common.PORT,
|
|
ipv6Only: true,
|
|
}, common.mustCall());
|
|
}
|