Skip to content

Commit 975e595

Browse files
joaocgreisorangemocha
authored andcommitted
test: run tls-server-verify servers in parallel
Different servers must use different ports. Since we can count only on common.PORT and common.PORT+1, run only 2 servers in parallel. Fixes: #1461 PR-URL: #1836 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent b18604b commit 975e595

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/parallel/test-tls-server-verify.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ var serverKey = loadPEM('agent2-key');
125125
var serverCert = loadPEM('agent2-cert');
126126

127127

128-
function runClient(options, cb) {
128+
function runClient(port, options, cb) {
129129

130130
// Client can connect in three ways:
131131
// - Self-signed cert
132132
// - Certificate, but not signed by CA.
133133
// - Certificate signed by CA.
134134

135-
var args = ['s_client', '-connect', '127.0.0.1:' + common.PORT];
135+
var args = ['s_client', '-connect', '127.0.0.1:' + port];
136136

137137

138138
console.log(' connecting with', options.name);
@@ -230,7 +230,7 @@ function runClient(options, cb) {
230230

231231
// Run the tests
232232
var successfulTests = 0;
233-
function runTest(testIndex) {
233+
function runTest(port, testIndex) {
234234
var tcase = testCases[testIndex];
235235
if (!tcase) return;
236236

@@ -293,31 +293,31 @@ function runTest(testIndex) {
293293
function runNextClient(clientIndex) {
294294
var options = tcase.clients[clientIndex];
295295
if (options) {
296-
runClient(options, function() {
296+
runClient(port, options, function() {
297297
runNextClient(clientIndex + 1);
298298
});
299299
} else {
300300
server.close();
301301
successfulTests++;
302-
runTest(testIndex + 1);
302+
runTest(port, nextTest++);
303303
}
304304
}
305305

306-
server.listen(common.PORT, function() {
306+
server.listen(port, function() {
307307
if (tcase.debug) {
308-
console.error('TLS server running on port ' + common.PORT);
308+
console.error('TLS server running on port ' + port);
309309
} else {
310310
if (tcase.renegotiate) {
311311
runNextClient(0);
312312
} else {
313313
var clientsCompleted = 0;
314314
for (var i = 0; i < tcase.clients.length; i++) {
315-
runClient(tcase.clients[i], function() {
315+
runClient(port, tcase.clients[i], function() {
316316
clientsCompleted++;
317317
if (clientsCompleted === tcase.clients.length) {
318318
server.close();
319319
successfulTests++;
320-
runTest(testIndex + 1);
320+
runTest(port, nextTest++);
321321
}
322322
});
323323
}
@@ -327,7 +327,9 @@ function runTest(testIndex) {
327327
}
328328

329329

330-
runTest(0);
330+
var nextTest = 0;
331+
runTest(common.PORT, nextTest++);
332+
runTest(common.PORT + 1, nextTest++);
331333

332334

333335
process.on('exit', function() {

0 commit comments

Comments
 (0)