Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
test: cover SCHED_NONE and SCHED_RR in cluster listen-twice-same-port…
… test
  • Loading branch information
islandryu committed Aug 23, 2026
commit d095f6e42fc5941753090f2a92ce5657cc1f8d56
23 changes: 23 additions & 0 deletions test/sequential/test-cluster-listen-twice-same-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion for the test: it passes on an unpatched build under SCHED_RR (the POSIX default), so it wouldn't catch a regression on Linux/macOS. The PR fixes behavior with SCHED_NONE, so could the tests cover both SCHED_RR and SCHED_NONE policies regardless of the OS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've covered both policies.

if (process.argv[2] === undefined) {
const { fork } = require('child_process');

function run(policy) {
return new Promise((resolve) => {
const child = fork(__filename, [policy]);
child.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
resolve();
}));
});
}

(async () => {
await run('none');
await run('rr');
})().then(common.mustCall());
return;
}

cluster.schedulingPolicy =
process.argv[2] === 'rr' ? cluster.SCHED_RR : cluster.SCHED_NONE;

if (cluster.isPrimary) {
cluster.fork().on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
Expand Down
Loading