Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: remove race condition in http flood test
Timer race results in some flakiness on slower devices in CI.
  • Loading branch information
Trott committed Jan 21, 2016
commit 85bd4220cda2b99a8e43602c937df53b53b87128
20 changes: 5 additions & 15 deletions test/parallel/test-http-pipeline-flood.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ switch (process.argv[2]) {
function parent() {
const http = require('http');
const bigResponse = new Buffer(10240).fill('x');
var gotTimeout = false;
var childClosed = false;
var requests = 0;
var connections = 0;
var backloggedReqs = 0;
Expand Down Expand Up @@ -57,20 +55,16 @@ function parent() {
const spawn = require('child_process').spawn;
const args = [__filename, 'child'];
const child = spawn(process.execPath, args, { stdio: 'inherit' });
child.on('close', function() {
childClosed = true;
child.on('close', common.mustCall(function() {
server.close();
});
}));

server.setTimeout(common.platformTimeout(200), function(conn) {
gotTimeout = true;
server.setTimeout(common.platformTimeout(200), common.mustCall(function() {
child.kill();
});
}));
});

process.on('exit', function() {
assert(gotTimeout);
assert(childClosed);
assert.equal(connections, 1);
});
}
Expand All @@ -85,11 +79,7 @@ function child() {

req = new Array(10241).join(req);

conn.on('connect', function() {
// Terminate child after flooding.
setTimeout(function() { conn.destroy(); }, common.platformTimeout(1000));
write();
});
conn.on('connect', write);

conn.on('drain', write);

Expand Down