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 <mscdex@mscdex.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
2f417c3193
commit
e4b78c6fd1
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user