2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-09-13 19:27:34 +01:00
|
|
|
const common = require('../common');
|
|
|
|
|
const assert = require('assert');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2016-09-13 19:27:34 +01:00
|
|
|
const https = require('https');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2016-09-13 19:27:34 +01:00
|
|
|
const fs = require('fs');
|
2011-01-21 15:55:48 -08:00
|
|
|
|
2016-09-13 19:27:34 +01:00
|
|
|
const options = {
|
2011-01-21 15:55:48 -08:00
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2016-09-13 19:27:34 +01:00
|
|
|
const server = https.Server(options, function(req, res) {
|
2011-01-21 15:55:48 -08:00
|
|
|
res.writeHead(200);
|
2011-10-04 18:08:18 -04:00
|
|
|
res.end('hello world\n');
|
2011-01-21 15:55:48 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let responses = 0;
|
2016-09-13 19:27:34 +01:00
|
|
|
const N = 4;
|
|
|
|
|
const M = 4;
|
|
|
|
|
|
2011-01-21 15:55:48 -08:00
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, function() {
|
2017-01-08 13:19:00 +00:00
|
|
|
for (let i = 0; i < N; i++) {
|
2011-10-04 18:08:18 -04:00
|
|
|
setTimeout(function() {
|
2017-01-08 13:19:00 +00:00
|
|
|
for (let j = 0; j < M; j++) {
|
2012-08-30 16:43:20 +02:00
|
|
|
https.get({
|
|
|
|
|
path: '/',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: server.address().port,
|
2012-08-30 16:43:20 +02:00
|
|
|
rejectUnauthorized: false
|
|
|
|
|
}, function(res) {
|
2012-12-13 07:47:33 -08:00
|
|
|
res.resume();
|
2016-09-13 19:27:34 +01:00
|
|
|
assert.strictEqual(res.statusCode, 200);
|
|
|
|
|
if (++responses === N * M) server.close();
|
2011-01-21 15:55:48 -08:00
|
|
|
}).on('error', function(e) {
|
2016-09-13 19:27:34 +01:00
|
|
|
throw e;
|
2011-01-21 15:55:48 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, i);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
2016-09-13 19:27:34 +01:00
|
|
|
assert.strictEqual(N * M, responses);
|
2011-01-21 15:55:48 -08:00
|
|
|
});
|