diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index d52f06659b..5b71d4b00a 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -42,16 +42,18 @@ function runAb(opts, callback) { }); } -runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) { - keepAliveReqSec = reqSec; - assert.equal(true, keepAliveRequests > 0); - puts("keep-alive: " + keepAliveReqSec + " req/sec"); - - runAb("-c 100 -t 2", function (reqSec, keepAliveRequests) { - normalReqSec = reqSec; - assert.equal(0, keepAliveRequests); - puts("normal: " + normalReqSec + " req/sec"); - server.close(); +server.addListener('listening', function () { + runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) { + keepAliveReqSec = reqSec; + assert.equal(true, keepAliveRequests > 0); + puts("keep-alive: " + keepAliveReqSec + " req/sec"); + + runAb("-c 100 -t 2", function (reqSec, keepAliveRequests) { + normalReqSec = reqSec; + assert.equal(0, keepAliveRequests); + puts("normal: " + normalReqSec + " req/sec"); + server.close(); + }); }); }); diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js index e81a5c502f..f333b5e7d9 100644 --- a/test/simple/test-http-cat.js +++ b/test/simple/test-http-cat.js @@ -16,22 +16,24 @@ server.listen(PORT); var got_good_server_content = false; var bad_server_got_error = false; -http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) { - if (err) { - throw err; - } else { - puts("got response"); - got_good_server_content = true; - assert.equal(body, content); - server.close(); - } -}); +server.addListener('listening', function () { + http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) { + if (err) { + throw err; + } else { + puts("got response"); + got_good_server_content = true; + assert.equal(body, content); + server.close(); + } + }); -http.cat("http://localhost:12312/", "utf8", function (err, content) { - if (err) { - puts("got error (this should happen)"); - bad_server_got_error = true; - } + http.cat("http://localhost:12312/", "utf8", function (err, content) { + if (err) { + puts("got error (this should happen)"); + bad_server_got_error = true; + } + }); }); process.addListener("exit", function () {