Skip to content

Commit

Permalink
test: fix flaky test-https-client-get-url
Browse files Browse the repository at this point in the history
Fixed test-https-client-get-url by waiting on HTTPS GET requests
to finish before closing the server.

PR-URL: nodejs#12876
Fixes: nodejs#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>
  • Loading branch information
Sebastian Plesciuc authored and Olivier Martin committed May 19, 2017
1 parent 2406749 commit 078e28d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/parallel/test-https-client-get-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
}));
}));
}));

0 comments on commit 078e28d

Please sign in to comment.