summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-timeout.js
diff options
context:
space:
mode:
authorMithun Sasidharan <mithunsasidharan89@gmail.com>2017-12-03 23:23:33 +0530
committerJon Moss <me@jonathanmoss.me>2017-12-04 17:40:17 -0500
commit996bfccd17b79e1eeac8d20fb91b6c378a3e22cc (patch)
treecc22bff966e2106497018e01894e4d3c25cfbf31 /test/parallel/test-http-timeout.js
parente1054abea0344f08bb6bba0b9aef342c690de8fd (diff)
downloadandroid-node-v8-996bfccd17b79e1eeac8d20fb91b6c378a3e22cc.tar.gz
android-node-v8-996bfccd17b79e1eeac8d20fb91b6c378a3e22cc.tar.bz2
android-node-v8-996bfccd17b79e1eeac8d20fb91b6c378a3e22cc.zip
test: update test-http-timeout to use countdown
PR-URL: https://github.com/nodejs/node/pull/17341 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'test/parallel/test-http-timeout.js')
-rw-r--r--test/parallel/test-http-timeout.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js
index 817bfe7a3c..c576f1c542 100644
--- a/test/parallel/test-http-timeout.js
+++ b/test/parallel/test-http-timeout.js
@@ -23,24 +23,25 @@
require('../common');
const http = require('http');
+const Countdown = require('../common/countdown');
const server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('OK');
});
+const MAX_COUNT = 11;
const agent = new http.Agent({ maxSockets: 1 });
+const countdown = new Countdown(MAX_COUNT, () => server.close());
server.listen(0, function() {
- for (let i = 0; i < 11; ++i) {
+ for (let i = 0; i < MAX_COUNT; ++i) {
createRequest().end();
}
function callback() {}
- let count = 0;
-
function createRequest() {
const req = http.request(
{ port: server.address().port, path: '/', agent: agent },
@@ -48,11 +49,7 @@ server.listen(0, function() {
req.clearTimeout(callback);
res.on('end', function() {
- count++;
-
- if (count === 11) {
- server.close();
- }
+ countdown.dec();
});
res.resume();