In tests, wait for 'listening' before connecting
This commit is contained in:
parent
b0d1d6c2b9
commit
0301adf9b4
@ -42,7 +42,8 @@ function runAb(opts, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) {
|
server.addListener('listening', function () {
|
||||||
|
runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) {
|
||||||
keepAliveReqSec = reqSec;
|
keepAliveReqSec = reqSec;
|
||||||
assert.equal(true, keepAliveRequests > 0);
|
assert.equal(true, keepAliveRequests > 0);
|
||||||
puts("keep-alive: " + keepAliveReqSec + " req/sec");
|
puts("keep-alive: " + keepAliveReqSec + " req/sec");
|
||||||
@ -53,6 +54,7 @@ runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) {
|
|||||||
puts("normal: " + normalReqSec + " req/sec");
|
puts("normal: " + normalReqSec + " req/sec");
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
process.addListener("exit", function () {
|
process.addListener("exit", function () {
|
||||||
|
@ -16,7 +16,8 @@ server.listen(PORT);
|
|||||||
var got_good_server_content = false;
|
var got_good_server_content = false;
|
||||||
var bad_server_got_error = false;
|
var bad_server_got_error = false;
|
||||||
|
|
||||||
http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) {
|
server.addListener('listening', function () {
|
||||||
|
http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
} else {
|
} else {
|
||||||
@ -25,13 +26,14 @@ http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) {
|
|||||||
assert.equal(body, content);
|
assert.equal(body, content);
|
||||||
server.close();
|
server.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
http.cat("http://localhost:12312/", "utf8", function (err, content) {
|
http.cat("http://localhost:12312/", "utf8", function (err, content) {
|
||||||
if (err) {
|
if (err) {
|
||||||
puts("got error (this should happen)");
|
puts("got error (this should happen)");
|
||||||
bad_server_got_error = true;
|
bad_server_got_error = true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
process.addListener("exit", function () {
|
process.addListener("exit", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user