diff options
author | Santiago Gimeno <santiago.gimeno@gmail.com> | 2016-01-03 18:10:22 +0100 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-01-12 12:13:40 -0800 |
commit | 6018fa1f5710260ecf4c2b32d05e80cb3337decc (patch) | |
tree | 2b5d8543863842cd6bca91ec25b3c921ef58103e /test/parallel/test-http-upgrade-agent.js | |
parent | 3a7f106b8c38fffd8caebf368a870e0ca5b114ed (diff) | |
download | android-node-v8-6018fa1f5710260ecf4c2b32d05e80cb3337decc.tar.gz android-node-v8-6018fa1f5710260ecf4c2b32d05e80cb3337decc.tar.bz2 android-node-v8-6018fa1f5710260ecf4c2b32d05e80cb3337decc.zip |
test: fix `http-upgrade-agent` flakiness
It's not guaranteed that the socket data is received in the same chunk
as the upgrade response. Listen for the `data` event to make sure all
the data is received.
PR-URL: https://github.com/nodejs/node/pull/4520
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http-upgrade-agent.js')
-rw-r--r-- | test/parallel/test-http-upgrade-agent.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/parallel/test-http-upgrade-agent.js b/test/parallel/test-http-upgrade-agent.js index 91fe495da2..7590354f50 100644 --- a/test/parallel/test-http-upgrade-agent.js +++ b/test/parallel/test-http-upgrade-agent.js @@ -46,9 +46,14 @@ srv.listen(common.PORT, '127.0.0.1', function() { req.end(); req.on('upgrade', function(res, socket, upgradeHead) { - // XXX: This test isn't fantastic, as it assumes that the entire response - // from the server will arrive in a single data callback - assert.equal(upgradeHead, 'nurtzo'); + var recvData = upgradeHead; + socket.on('data', function(d) { + recvData += d; + }); + + socket.on('close', common.mustCall(function() { + assert.equal(recvData, 'nurtzo'); + })); console.log(res.headers); var expectedHeaders = { 'hello': 'world', |