Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: avoid test-cluster-master-kill flakiness #6531

Closed
wants to merge 4 commits into from
Closed
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
Next Next commit
WIP: Poll indefinitely
  • Loading branch information
stefanmb committed May 3, 2016
commit fadbde5d3ef6cb3bddb9909d84a1ca550381a0e2
23 changes: 9 additions & 14 deletions test/parallel/test-cluster-master-kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ if (cluster.isWorker) {
// terminate the cluster process
worker.once('listening', function() {
setTimeout(function() {
/* Cluster.disconnect() will exercise a different 'graceful' shutdown path.
From the perspective of the worker, closing the channel is equivalent
to the parent calling process.exit(0). */
worker.process._channel.close();
process.exit(0);
}, 1000);
});

worker.once('exit', function() {
process.exit(0);
});

} else {

// This is the testcase
Expand Down Expand Up @@ -66,15 +59,17 @@ if (cluster.isWorker) {
assert.equal(code, 0);

// check worker process status
alive = isAlive(pid);
var pollWorker = function() {
alive = isAlive(pid);
if (alive) {
setTimeout(pollWorker, 500);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you safely can set the timeout value lower, so we don´t slow down the test up to a half second.

}
};
// Loop indefinitely until worker exit.
pollWorker();
});

process.once('exit', function() {
// cleanup: kill the worker if alive
if (alive) {
process.kill(pid);
}

assert.equal(typeof pid, 'number', 'did not get worker pid info');
assert.equal(alive, false, 'worker was alive after master died');
});
Expand Down