Skip to content

Commit

Permalink
test: fix http-upgrade-client flakiness
Browse files Browse the repository at this point in the history
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: #4602
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
santigimeno authored and jasnell committed Jan 12, 2016
1 parent 6018fa1 commit d8ba2c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/parallel/test-http-upgrade-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ srv.listen(common.PORT, '127.0.0.1', function() {
}
});
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',
Expand Down

0 comments on commit d8ba2c0

Please sign in to comment.