mirror of https://github.com/nodejs/node.git
test: fix race in simple/test-cluster-master-error
Said test checks that the workers shut down when the master errors but it failed intermittently. Insert a small delay before doing the 'is dead?' check to give the workers a chance to shut down.pull/24503/head
parent
fb47a337ba
commit
d8c4ecea0b
|
@ -112,16 +112,21 @@ if (cluster.isWorker) {
|
||||||
// Check that the cluster died accidently
|
// Check that the cluster died accidently
|
||||||
existMaster = (code === 1);
|
existMaster = (code === 1);
|
||||||
|
|
||||||
// When master is dead all workers should be dead to
|
// Give the workers time to shut down
|
||||||
var alive = false;
|
setTimeout(checkWorkers, 200);
|
||||||
workers.forEach(function(pid) {
|
|
||||||
if (isAlive(pid)) {
|
|
||||||
alive = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// If a worker was alive this did not act as expected
|
function checkWorkers() {
|
||||||
existWorker = !alive;
|
// When master is dead all workers should be dead to
|
||||||
|
var alive = false;
|
||||||
|
workers.forEach(function(pid) {
|
||||||
|
if (isAlive(pid)) {
|
||||||
|
alive = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If a worker was alive this did not act as expected
|
||||||
|
existWorker = !alive;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
process.once('exit', function() {
|
process.once('exit', function() {
|
||||||
|
|
Loading…
Reference in New Issue