Skip to content

Commit

Permalink
test: fix spurious EADDRINUSE in test-https-strict
Browse files Browse the repository at this point in the history
test-https-strict sometimes fails with EADDRINUSE in CI. Remove use of
common.PORT to make the test resistant from side effects from other
tests that may have not freed up the port.

PR-URL: #7024
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott committed May 31, 2016
1 parent 0d7f313 commit 2f417c3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/parallel/test-https-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ var server3 = server(options3);

var listenWait = 0;

var port = common.PORT;
var port1 = port++;
var port2 = port++;
var port3 = port++;
server1.listen(port1, listening());
server2.listen(port2, listening());
server3.listen(port3, listening());
server1.listen(0, listening());
server2.listen(0, listening());
server3.listen(0, listening());

var responseErrors = {};
var expectResponseCount = 0;
Expand Down Expand Up @@ -131,9 +127,9 @@ function makeReq(path, port, error, host, ca) {
}
var req = https.get(options);
expectResponseCount++;
var server = port === port1 ? server1
: port === port2 ? server2
: port === port3 ? server3
var server = port === server1.address().port ? server1
: port === server2.address().port ? server2
: port === server3.address().port ? server3
: null;

if (!server) throw new Error('invalid port: ' + port);
Expand All @@ -156,6 +152,10 @@ function makeReq(path, port, error, host, ca) {
function allListening() {
// ok, ready to start the tests!

const port1 = server1.address().port;
const port2 = server2.address().port;
const port3 = server3.address().port;

// server1: host 'agent1', signed by ca1
makeReq('/inv1', port1, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
makeReq('/inv1-ca1', port1,
Expand Down

0 comments on commit 2f417c3

Please sign in to comment.