Browse Source

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.
v0.9.1-release
Ben Noordhuis 13 years ago
parent
commit
d8c4ecea0b
  1. 5
      test/simple/test-cluster-master-error.js

5
test/simple/test-cluster-master-error.js

@ -112,6 +112,10 @@ if (cluster.isWorker) {
// Check that the cluster died accidently // Check that the cluster died accidently
existMaster = (code === 1); existMaster = (code === 1);
// Give the workers time to shut down
setTimeout(checkWorkers, 200);
function checkWorkers() {
// When master is dead all workers should be dead to // When master is dead all workers should be dead to
var alive = false; var alive = false;
workers.forEach(function(pid) { workers.forEach(function(pid) {
@ -122,6 +126,7 @@ if (cluster.isWorker) {
// If a worker was alive this did not act as expected // If a worker was alive this did not act as expected
existWorker = !alive; existWorker = !alive;
}
}); });
process.once('exit', function() { process.once('exit', function() {

Loading…
Cancel
Save