From 81a9f96a29cfac5a6d91c49ad4d3f8758143950c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 27 May 2016 20:00:55 -0700 Subject: [PATCH] test: make test-child-process-fork-net more robust test-child-process-fork-net will sometimes fail in CI with EADDRINUSE because an earlier test failed to free common.PORT. Have the operating system provide an available port instead. PR-URL: https://github.com/nodejs/node/pull/7033 Reviewed-By: Brian White Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-child-process-fork-net.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index f815f76a664d9f..1b12e1e173b92a 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -1,6 +1,6 @@ 'use strict'; const assert = require('assert'); -const common = require('../common'); +require('../common'); const fork = require('child_process').fork; const net = require('net'); @@ -91,7 +91,7 @@ if (process.argv[2] === 'child') { console.log('PARENT: server listening'); child.send({what: 'server'}, server); }); - server.listen(common.PORT); + server.listen(0); // handle client messages var messageHandlers = function(msg) { @@ -100,7 +100,7 @@ if (process.argv[2] === 'child') { // make connections var socket; for (var i = 0; i < 4; i++) { - socket = net.connect(common.PORT, function() { + socket = net.connect(server.address().port, function() { console.log('CLIENT: connected'); }); socket.on('close', function() { @@ -143,9 +143,9 @@ if (process.argv[2] === 'child') { // // An isolated test for this would be lovely, but for now, this // will have to do. - server.listen(common.PORT + 1, function() { + server.listen(0, function() { console.error('testSocket, listening'); - var connect = net.connect(common.PORT + 1); + var connect = net.connect(server.address().port); var store = ''; connect.on('data', function(chunk) { store += chunk;