Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky test-http2-ping-flood #19395

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion test/sequential/sequential.status
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ test-inspector-async-call-stack : PASS, FLAKY
test-inspector-bindings : PASS, FLAKY
test-inspector-debug-end : PASS, FLAKY
test-inspector-async-hook-setup-at-signal: PASS, FLAKY
test-http2-ping-flood : PASS, FLAKY

[$system==linux]

Expand Down
24 changes: 14 additions & 10 deletions test/sequential/test-http2-ping-flood.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const http2 = require('http2');
const net = require('net');

const http2util = require('../common/http2');

// Test that ping flooding causes the session to be torn down
Expand All @@ -15,13 +17,15 @@ const kPing = new http2util.PingFrame();

const server = http2.createServer();

let interval;

server.on('stream', common.mustNotCall());
server.on('session', common.mustCall((session) => {
session.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
message:
'Flooding was detected in this HTTP/2 session, and it must be closed'
}));
session.on('error', (e) => {
Copy link
Member

@richardlau richardlau Mar 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe keep common.expectsError and have a second session.on('error', ... for clearInterval?

Edit: not blocking (let's get that CI green), I just find common.expectsError clearer.

assert.strictEqual(e.code, 'ERR_HTTP2_ERROR');
assert(e.message.includes('Flooding was detected'));
clearInterval(interval);
});
session.on('close', common.mustCall(() => {
server.close();
}));
Expand All @@ -31,9 +35,7 @@ server.listen(0, common.mustCall(() => {
const client = net.connect(server.address().port);

// nghttp2 uses a limit of 10000 items in it's outbound queue.
// If this number is exceeded, a flooding error is raised. Set
// this lim higher to account for the ones that nghttp2 is
// successfully able to respond to.
// If this number is exceeded, a flooding error is raised.
// TODO(jasnell): Unfortunately, this test is inherently flaky because
// it is entirely dependent on how quickly the server is able to handle
// the inbound frames and whether those just happen to overflow nghttp2's
Expand All @@ -42,8 +44,10 @@ server.listen(0, common.mustCall(() => {
client.on('connect', common.mustCall(() => {
client.write(http2util.kClientMagic, () => {
client.write(kSettings.data, () => {
for (let n = 0; n < 35000; n++)
client.write(kPing.data);
interval = setInterval(() => {
for (let n = 0; n < 10000; n++)
client.write(kPing.data);
}, 1);
});
});
}));
Expand Down