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 MylesBorins committed Jul 17, 2017
1 parent 1f97133 commit 253c5aa
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@ 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', function() {
console.error('CLIENT connected');
assert.ok(false);
});

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 253c5aa

Please sign in to comment.