node/test/parallel/test-cluster-kill-disconnect.js
Ujjwal Sharma 580ad0157a
test: name test files appropriately
Rename the tests appropriately alongside mentioning the subsystem.
Also, make a few basic changes to make sure the test conforms
to the standard test structure.

This renames:
- test-regress-GH-1531
- test-regress-GH-2245
- test-regress-GH-3238
- test-regress-GH-3542
- test-regress-GH-3739
- test-regress-GH-4256

PR-URL: https://github.com/nodejs/node/pull/19212
Refs: https://github.com/nodejs/node/issues/19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-11 04:17:42 +01:00

29 lines
793 B
JavaScript

'use strict';
const common = require('../common');
// Check that cluster works perfectly for both `kill` and `disconnect` cases.
// Also take into account that the `disconnect` event may be received after the
// `exit` event.
// https://github.com/nodejs/node/issues/3238
const assert = require('assert');
const cluster = require('cluster');
if (cluster.isMaster) {
function forkWorker(action) {
const worker = cluster.fork({ action });
worker.on('disconnect', common.mustCall(() => {
assert.strictEqual(worker.exitedAfterDisconnect, true);
}));
worker.on('exit', common.mustCall(() => {
assert.strictEqual(worker.exitedAfterDisconnect, true);
}));
}
forkWorker('disconnect');
forkWorker('kill');
} else {
cluster.worker[process.env.action]();
}