Skip to content

Commit dac9f42

Browse files
ooHmartYaddaleax
authored andcommitted
test: remove common.PORT in test tls ticket cluster
PR-URL: #12715 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent d37f27a commit dac9f42

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

test/parallel/test-tls-ticket-cluster.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ if (cluster.isMaster) {
4141
let reqCount = 0;
4242
let lastSession = null;
4343
let shootOnce = false;
44+
let workerPort = null;
4445

4546
function shoot() {
46-
console.error('[master] connecting');
47-
const c = tls.connect(common.PORT, {
47+
console.error('[master] connecting', workerPort);
48+
const c = tls.connect(workerPort, {
4849
session: lastSession,
4950
rejectUnauthorized: false
5051
}, function() {
@@ -63,11 +64,12 @@ if (cluster.isMaster) {
6364

6465
function fork() {
6566
const worker = cluster.fork();
66-
worker.on('message', function(msg) {
67+
worker.on('message', function({ msg, port }) {
6768
console.error('[master] got %j', msg);
6869
if (msg === 'reused') {
6970
++reusedCount;
7071
} else if (msg === 'listening' && !shootOnce) {
72+
workerPort = port || workerPort;
7173
shootOnce = true;
7274
shoot();
7375
}
@@ -99,15 +101,19 @@ const options = {
99101

100102
const server = tls.createServer(options, function(c) {
101103
if (c.isSessionReused()) {
102-
process.send('reused');
104+
process.send({ msg: 'reused' });
103105
} else {
104-
process.send('not-reused');
106+
process.send({ msg: 'not-reused' });
105107
}
106108
c.end();
107109
});
108110

109-
server.listen(common.PORT, function() {
110-
process.send('listening');
111+
server.listen(0, function() {
112+
const { port } = server.address();
113+
process.send({
114+
msg: 'listening',
115+
port,
116+
});
111117
});
112118

113119
process.on('message', function listener(msg) {

0 commit comments

Comments
 (0)