Browse Source

test: fix flaky SmartOS test

SmartOS has an issue where it will trigger ECONNREFUSED when it should
not. See https://smartos.org/bugview/OS-2767.

This change adds logic to test-net-server-max-connections.js to work
around the issue.

Fixes: https://github.com/nodejs/node/issues/2663
PR-URL: https://github.com/nodejs/node/pull/3830
Reviewed-By: James M Snell <jasnell@gmail.com>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
5b80ca9339
  1. 29
      test/parallel/test-net-server-max-connections.js

29
test/parallel/test-net-server-max-connections.js

@ -36,18 +36,6 @@ function makeConnection(index) {
if (index + 1 < N) {
makeConnection(index + 1);
}
});
c.on('end', function() { c.end(); });
c.on('data', function(b) {
gotData = true;
assert.ok(0 < b.length);
});
c.on('error', function(e) {
console.error('error %d: %s', index, e);
});
c.on('close', function() {
console.error('closed %d', index);
@ -77,6 +65,23 @@ function makeConnection(index) {
index + ' got data, but shouldn\'t have');
}
});
});
c.on('end', function() { c.end(); });
c.on('data', function(b) {
gotData = true;
assert.ok(0 < b.length);
});
c.on('error', function(e) {
// Retry if SmartOS and ECONNREFUSED. See
// https://github.com/nodejs/node/issues/2663.
if (common.isSunOS && (e.code === 'ECONNREFUSED')) {
c.connect(common.PORT);
}
console.error('error %d: %s', index, e);
});
}

Loading…
Cancel
Save