Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.

(cherry picked from commit efb0075ee0e1f4123974fe5b74ded8727bad4a9e)
  • Loading branch information
joaocgreis committed Jun 1, 2015
commit 1bcb5f0302204b42d6a3df54bf64ceb56056ff33
22 changes: 12 additions & 10 deletions test/parallel/test-tls-server-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ var serverKey = loadPEM('agent2-key');
var serverCert = loadPEM('agent2-cert');


function runClient(options, cb) {
function runClient(port, options, cb) {

// Client can connect in three ways:
// - Self-signed cert
// - Certificate, but not signed by CA.
// - Certificate signed by CA.

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


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

// Run the tests
var successfulTests = 0;
function runTest(testIndex) {
function runTest(port, testIndex) {
var tcase = testCases[testIndex];
if (!tcase) return;

Expand Down Expand Up @@ -293,31 +293,31 @@ function runTest(testIndex) {
function runNextClient(clientIndex) {
var options = tcase.clients[clientIndex];
if (options) {
runClient(options, function() {
runClient(port, options, function() {
runNextClient(clientIndex + 1);
});
} else {
server.close();
successfulTests++;
runTest(testIndex + 1);
runTest(port, nextTest++);
}
}

server.listen(common.PORT, function() {
server.listen(port, function() {
if (tcase.debug) {
console.error('TLS server running on port ' + common.PORT);
console.error('TLS server running on port ' + port);
} else {
if (tcase.renegotiate) {
runNextClient(0);
} else {
var clientsCompleted = 0;
for (var i = 0; i < tcase.clients.length; i++) {
runClient(tcase.clients[i], function() {
runClient(port, tcase.clients[i], function() {
clientsCompleted++;
if (clientsCompleted === tcase.clients.length) {
server.close();
successfulTests++;
runTest(testIndex + 1);
runTest(port, nextTest++);
}
});
}
Expand All @@ -327,7 +327,9 @@ function runTest(testIndex) {
}


runTest(0);
var nextTest = 0;
runTest(common.PORT, nextTest++);
runTest(common.PORT + 1, nextTest++);


process.on('exit', function() {
Expand Down