Skip to content

Commit 13e1131

Browse files
gireeshpunathilmhdawson
authored andcommitted
test: address timing issues in simple http tests
simple tests test-http-request-end.js, test-http-default-encoding.js hangs in AIX. The root cause for both the failures is related to the timing with which packets are sent between the client and server. On the client side, one factor that affects the timing is Nagle's algorithm. With Nagle enabled there may be a delay between two packets as the stack may wait until either: a. An acknowledgement for the first packet is received, or b. 200 ms elapses. before sending the second packet. Similarly at the server side 2 sequential packages can be delivered to the application either together or separatly. On AIX we see that they are delivered separately to the server, while on Linux delivered together. If we change the timing, for example disabling Nagle on AIX we see the 2 packets delivered together and the tests pass. In the test case simple/test-http-request-end.js, the client request handler of the server receives and stores the data in a data callback, closes the server in a request end callback, and writes to the client and ends the response, in-line with the request receipt. An HTTP parser module parses the incoming message, and invokes callback routines which are registered for HTTP events (such as header, body, end etc.) Because the termination sequence arrive in a separate packet, there is a delay in parsing that message and identify that the client request ended (and thereby invoke the request end call backhandler). Due to this delay, the response close happens first, which in-turn destroys the server socket leading to the fd and watcher removal from the uv loop abandoning further events on this connection, and end call back never being called, causing the reported hang. simple/test-http-default-encoding.js suffers from the same problem. Also, remove the timer logic from the test case. Test harness anyways contain a timer which controls the individual tests so remove such controls from the test case, as suggested by @tjfontaine Reviewed-By: Michael Dawson <[email protected]> PR-URL: nodejs/node-v0.x-archive#9432
1 parent 5dd5ce7 commit 13e1131

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

test/simple/test-http-default-encoding.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,11 @@ var server = http.Server(function(req, res) {
3131
req.on('data', function(chunk) {
3232
result += chunk;
3333
}).on('end', function() {
34-
clearTimeout(timeout);
3534
server.close();
35+
res.writeHead(200);
36+
res.end('hello world\n');
3637
});
3738

38-
var timeout = setTimeout(function() {
39-
process.exit(1);
40-
}, 100);
41-
42-
res.writeHead(200);
43-
res.end('hello world\n');
4439
});
4540

4641
server.listen(common.PORT, function() {

test/simple/test-http-request-end.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var server = http.Server(function(req, res) {
3434

3535
req.on('end', function() {
3636
server.close();
37+
res.writeHead(200);
38+
res.end('hello world\n');
3739
});
3840

39-
res.writeHead(200);
40-
res.end('hello world\n');
4141
});
4242

4343
server.listen(common.PORT, function() {

0 commit comments

Comments
 (0)