Skip to content

Commit

Permalink
test: move net reconnect error test to sequential
Browse files Browse the repository at this point in the history
The usage of common.PORT could cause undesired port collisions when run
in parallel. The following test was moved to sequential.
test-net-reconnect-error.js

PR-URL: #13033
Refs: #12376
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
arturgvieira authored and refack committed May 20, 2017
1 parent 06a617a commit c60a7fa
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ const N = 20;
let client_error_count = 0;
let disconnect_count = 0;

// Hopefully nothing is running on common.PORT
const c = net.createConnection(common.PORT);

c.on('connect', common.mustNotCall('client should not have connected'));

c.on('error', function(e) {
console.error(`CLIENT error: ${e.code}`);
c.on('error', common.mustCall((e) => {
client_error_count++;
assert.strictEqual('ECONNREFUSED', e.code);
});
}, N + 1));

c.on('close', function() {
console.log('CLIENT disconnect');
c.on('close', common.mustCall(() => {
if (disconnect_count++ < N)
c.connect(common.PORT); // reconnect
});
}, N + 1));

process.on('exit', function() {
assert.strictEqual(N + 1, disconnect_count);
Expand Down

0 comments on commit c60a7fa

Please sign in to comment.