Browse Source

test: fix flaky test-https-client-get-url

Fixed test-https-client-get-url by waiting on HTTPS GET requests
to finish before closing the server.

PR-URL: https://github.com/nodejs/node/pull/12876
Fixes: https://github.com/nodejs/node/issues/12873
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
v6
Sebastian Plesciuc 8 years ago
committed by Refael Ackermann
parent
commit
317180ffe5
  1. 19
      test/parallel/test-https-client-get-url.js

19
test/parallel/test-https-client-get-url.js

@ -41,18 +41,21 @@ const options = {
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
};
const server = https.createServer(options, common.mustCall(function(req, res) {
const server = https.createServer(options, common.mustCall((req, res) => {
assert.strictEqual('GET', req.method);
assert.strictEqual('/foo?bar', req.url);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello\n');
res.end();
server.close();
}, 3));
server.listen(0, function() {
const u = `https://127.0.0.1:${this.address().port}/foo?bar`;
https.get(u);
https.get(url.parse(u));
https.get(new URL(u));
});
server.listen(0, common.mustCall(() => {
const u = `https://${common.localhostIPv4}:${server.address().port}/foo?bar`;
https.get(u, common.mustCall(() => {
https.get(url.parse(u), common.mustCall(() => {
https.get(new URL(u), common.mustCall(() => {
server.close();
}));
}));
}));
}));

Loading…
Cancel
Save