Skip to content

Commit

Permalink
test: retry on known SmartOS bug
Browse files Browse the repository at this point in the history
There is a known issue with SmartOS that is generally worked around
in `tools/test.py`. However, a more robust workaround is required for
some tests that open many network connections.

`test-http-regr-gh-2928` is one such test.

Fixes: #5445
Refs: #3941
PR-URL: #5454
Reviewed-By: Fedor Indutny <fedor@indutny.com>
  • Loading branch information
Trott authored and Fishrock123 committed Mar 2, 2016
1 parent 1e86804 commit d1a82c6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/sequential/test-http-regr-gh-2928.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ var gotRequests = 0;
var gotResponses = 0;

function execAndClose() {
process.stdout.write('.');
if (parsers.length === 0)
return;
process.stdout.write('.');

const parser = parsers.pop();
parser.reinitialize(HTTPParser.RESPONSE);

const socket = net.connect(common.PORT);
socket.on('error', (e) => {
// If SmartOS and ECONNREFUSED, then retry. See
// https://github.com/nodejs/node/issues/2663.
if (common.isSunOS && e.code === 'ECONNREFUSED') {
parsers.push(parser);
socket.destroy();
setImmediate(execAndClose);
return;
}
throw e;
});

parser.consume(socket._handle._externalStream);

parser.onIncoming = function onIncoming() {
Expand Down

0 comments on commit d1a82c6

Please sign in to comment.