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
20 changes: 10 additions & 10 deletions test/parallel/test-cluster-master-kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ if (cluster.isWorker) {
// terminate the cluster process
worker.once('listening', function() {
setTimeout(function() {
process.exit(0);
/* 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();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't object, but this does use undocumented APIs, and the last test didn't. That can be annoying when trying to rearrange things that are supposed to be internal.

Why not just change the check at the end to not do a single check after some randomly chosen time interval, but to run the check every half-second, indefinitely, until it passes or the runner kills this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sam-github That would be another way to do this - I'm not a huge fan of polling but it may be the lesser evil. I can do another version with your suggestion. Thanks.

}, 1000);
});

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

} else {

// This is the testcase
Expand Down Expand Up @@ -55,18 +62,11 @@ if (cluster.isWorker) {
var alive = true;
master.on('exit', function(code) {

// make sure that the master died by purpose
// make sure that the master died on purpose
assert.equal(code, 0);

// check worker process status
var timeout = 200;
if (common.isAix) {
// AIX needs more time due to default exit performance
timeout = 1000;
}
setTimeout(function() {
alive = isAlive(pid);
}, timeout);
alive = isAlive(pid);
});

process.once('exit', function() {
Expand Down