summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Dawson <michael_dawson@ca.ibm.com>2015-02-23 14:13:20 -0500
committercjihrig <cjihrig@gmail.com>2015-02-27 12:14:06 -0500
commit3e40e126eb078634c08ee59aa20229bd85570167 (patch)
treee529e8dfe1ee8dc9c76c713798addc4f78b8217c
parent5d821fe0beec775fa3fbb0fd7ac1cbc3fff983c5 (diff)
downloadnode-3e40e126eb078634c08ee59aa20229bd85570167.tar.gz
test: make destroyed-socket-write2.js more robust
test/simple/test-http-destroyed-socket-write2.js validates that you get an appropriate error when trying to write to a request when the response on the other side has been destroyed. The test uses http.request to get a request and then keeps writing to it until either it hits 128 writes or gets the expected error. Since the writes are asynchronous we see that the writes just end up adding events to the event loop, which then later get processed once the connection supporting the request is fully ready. The test is timing dependent and if takes too long for the connection to be made the limit of 128 writes is exceeded and the test fails. The fact that the test allows a number of writes is probably to allow some delay for the connection to be ready for writing. On AIX, in the default configuration using the loopback interface is slower and the test fails because the delay is such that many more writes can be queued up before the connection takes place. If we use the host ip instead of defaulting to the loopback then the test passes. The test needs to be made more robust to delays. Since each write simply enqueues an additional write to the event queue there is probably no point in doing the second write until the first has completed. This patch schedules the next write when the first one completes and allows the test to pass even if it takes longer for the connection to be ready for writing PR-URL: https://github.com/joyent/node/pull/9270 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
-rw-r--r--test/simple/test-http-destroyed-socket-write2.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/simple/test-http-destroyed-socket-write2.js b/test/simple/test-http-destroyed-socket-write2.js
index 3347f3ccc..ebb80c9a2 100644
--- a/test/simple/test-http-destroyed-socket-write2.js
+++ b/test/simple/test-http-destroyed-socket-write2.js
@@ -49,8 +49,9 @@ server.listen(common.PORT, function() {
req.end();
test();
} else {
- timer = setImmediate(write);
- req.write('hello');
+ req.write('hello', function() {
+ timer = setImmediate(write);
+ });
}
}