test: make test-cluster-disconnect-leak reliable
authorRich Trott <rtrott@gmail.com>
Mon, 18 Jan 2016 03:50:09 +0000 (19:50 -0800)
committerMyles Borins <mborins@us.ibm.com>
Mon, 15 Feb 2016 19:30:23 +0000 (11:30 -0800)
commit01780011636330bfcd3e326c8c582beb592c7e69
tree45498c902f55483481c3dcbabb907026ea8713ca
parentcb5986da81018d81940d50781778f42bea3f8c02
test: make test-cluster-disconnect-leak reliable

Previously, test-cluster-disconnect-leak had two issues:

* Magic numbers: How many times to spawn a worker was determined through
empirical experimentation. This means that as new platforms and new
CPU/RAM configurations are tested, the magic numbers require more
and more refinement. This brings us to...

* Non-determinism: The test *seems* to fail all the time when the bug
it tests for is present, but it's really a judgment based on sampling.
"Oh, with 8 workers per CPU, it fails about 80% of the time. Let's try
16..."

This revised version of the test takes a different approach. The fix
for the bug that the test was written for means that the `disconnect`
event will fire reliably for a single worker. So we check for that and
the test still fails when the fix is not in the code base and succeeds
when it is.

Advantages of this approach include:

* The test runs much faster.
* The test now works on Windows. The previous version skipped Windows.
* The test should be reliable on any new platform regardless of CPU and
RAM.

Ref: https://github.com/nodejs/node/pull/4674

PR-URL: https://github.com/nodejs/node/pull/4736
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
test/sequential/test-cluster-disconnect-leak.js