Browse Source

test: verify cluster worker exit

test-cluster-disconnect-handles already includes logic that
tries to cleanup any child processes when the test fails. This
commit adds additional checks to verify that the child exited
normally, and fails the test if that is not the case.

Refs: https://github.com/nodejs/node/issues/6988
PR-URL: https://github.com/nodejs/node/pull/6993
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
v4.x
cjihrig 9 years ago
committed by Myles Borins
parent
commit
8c412af7ac
  1. 4
      test/parallel/test-cluster-disconnect-handles.js

4
test/parallel/test-cluster-disconnect-handles.js

@ -31,6 +31,10 @@ if (cluster.isMaster) {
// scanner but is ignored by atoi(3). Heinous hack.
cluster.setupMaster({ execArgv: [`--debug=${common.PORT}.`] });
const worker = cluster.fork();
worker.once('exit', common.mustCall((code, signal) => {
assert.strictEqual(code, 0, 'worker did not exit normally');
assert.strictEqual(signal, null, 'worker did not exit normally');
}));
worker.on('message', common.mustCall((message) => {
assert.strictEqual(Array.isArray(message), true);
assert.strictEqual(message[0], 'listening');

Loading…
Cancel
Save