mirror of https://github.com/nodejs/node.git
test: move net reconnect error test to sequential
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: https://github.com/nodejs/node/pull/13033 Refs: https://github.com/nodejs/node/issues/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>pull/12976/head
parent
06a617aa21
commit
c60a7fa738
|
@ -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);
|
Loading…
Reference in New Issue