Skip to content

Commit

Permalink
test: remove common.PORT in test tls ticket cluster
Browse files Browse the repository at this point in the history
PR-URL: #12715
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
ooHmartY authored and addaleax committed May 7, 2017
1 parent d37f27a commit dac9f42
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions test/parallel/test-tls-ticket-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ if (cluster.isMaster) {
let reqCount = 0;
let lastSession = null;
let shootOnce = false;
let workerPort = null;

function shoot() {
console.error('[master] connecting');
const c = tls.connect(common.PORT, {
console.error('[master] connecting', workerPort);
const c = tls.connect(workerPort, {
session: lastSession,
rejectUnauthorized: false
}, function() {
Expand All @@ -63,11 +64,12 @@ if (cluster.isMaster) {

function fork() {
const worker = cluster.fork();
worker.on('message', function(msg) {
worker.on('message', function({ msg, port }) {
console.error('[master] got %j', msg);
if (msg === 'reused') {
++reusedCount;
} else if (msg === 'listening' && !shootOnce) {
workerPort = port || workerPort;
shootOnce = true;
shoot();
}
Expand Down Expand Up @@ -99,15 +101,19 @@ const options = {

const server = tls.createServer(options, function(c) {
if (c.isSessionReused()) {
process.send('reused');
process.send({ msg: 'reused' });
} else {
process.send('not-reused');
process.send({ msg: 'not-reused' });
}
c.end();
});

server.listen(common.PORT, function() {
process.send('listening');
server.listen(0, function() {
const { port } = server.address();
process.send({
msg: 'listening',
port,
});
});

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

0 comments on commit dac9f42

Please sign in to comment.