Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
test: fix flaky http2 tests
  • Loading branch information
apapirovski committed May 10, 2018
commit 53eb58451a09db398505ffbb239ad9b098542ae5
8 changes: 0 additions & 8 deletions test/parallel/test-http2-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const server = http2.createServer();
server.on('stream', common.mustCall((stream) => {
const dest = stream.pipe(fs.createWriteStream(fn));

// we might get an ECONNRESET here
// or not
stream.on('error', () => {});

dest.on('finish', () => {
assert.strictEqual(fs.readFileSync(loc).length,
fs.readFileSync(fn).length);
Expand All @@ -38,10 +34,6 @@ server.listen(0, common.mustCall(() => {

const req = client.request({ ':method': 'POST' });

// we might get an ECONNRESET here
// or not
req.on('error', () => {});

req.on('response', common.mustCall());
req.resume();

Expand Down
12 changes: 5 additions & 7 deletions test/parallel/test-http2-server-close-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ const server = http2.createServer();

server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);

// depending on network events, this might or might not be emitted
client.on('error', () => {});

client.on('connect', common.mustCall(() => {
server.close(common.mustCall());
}));
client.on('error', (err) => {
if (err.code !== 'ECONNRESET')
throw err;
});
}));

server.on('session', common.mustCall((s) => {
setImmediate(() => {
server.close(common.mustCall());
s.destroy();
});
}));
12 changes: 9 additions & 3 deletions test/parallel/test-http2-server-stream-session-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ server.on('stream', common.mustCall((stream) => {

server.listen(0, common.mustCall(() => {
const client = h2.connect(`http://localhost:${server.address().port}`);
client.on('error', () => {});
client.on('error', (err) => {
if (err.code !== 'ECONNRESET')
throw err;
});
const req = client.request();
req.resume();
req.on('end', common.mustCall());
req.on('close', common.mustCall(() => server.close()));
req.on('error', () => {});
req.on('close', common.mustCall(() => server.close(common.mustCall())));
req.on('error', (err) => {
if (err.code !== 'ECONNRESET')
throw err;
});
}));
8 changes: 4 additions & 4 deletions test/sequential/test-http2-max-session-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const largeBuffer = Buffer.alloc(1e6);
const server = http2.createServer({ maxSessionMemory: 1 });

server.on('stream', common.mustCall((stream) => {
stream.on('error', common.expectsError({
code: 'ECONNRESET',
type: Error
}));
stream.on('error', (err) => {
if (err.code !== 'ECONNRESET')
throw err;
});
stream.respond();
stream.end(largeBuffer);
}));
Expand Down