test: fix flaky test-http2-ping-flood
The test is unreliable on some Windows platforms in its current form. Make it more robust by using `setInterval()` to repeat the flooding until an error is triggered. PR-URL: https://github.com/nodejs/node/pull/19395 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f24d0ec201
commit
0fb017d684
@ -11,7 +11,6 @@ test-inspector-async-call-stack : PASS, FLAKY
|
|||||||
test-inspector-bindings : PASS, FLAKY
|
test-inspector-bindings : PASS, FLAKY
|
||||||
test-inspector-debug-end : PASS, FLAKY
|
test-inspector-debug-end : PASS, FLAKY
|
||||||
test-inspector-async-hook-setup-at-signal: PASS, FLAKY
|
test-inspector-async-hook-setup-at-signal: PASS, FLAKY
|
||||||
test-http2-ping-flood : PASS, FLAKY
|
|
||||||
|
|
||||||
[$system==linux]
|
[$system==linux]
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@ const common = require('../common');
|
|||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const http2util = require('../common/http2');
|
const http2util = require('../common/http2');
|
||||||
|
|
||||||
// Test that ping flooding causes the session to be torn down
|
// Test that ping flooding causes the session to be torn down
|
||||||
@ -15,13 +17,15 @@ const kPing = new http2util.PingFrame();
|
|||||||
|
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
|
|
||||||
|
let interval;
|
||||||
|
|
||||||
server.on('stream', common.mustNotCall());
|
server.on('stream', common.mustNotCall());
|
||||||
server.on('session', common.mustCall((session) => {
|
server.on('session', common.mustCall((session) => {
|
||||||
session.on('error', common.expectsError({
|
session.on('error', (e) => {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
assert.strictEqual(e.code, 'ERR_HTTP2_ERROR');
|
||||||
message:
|
assert(e.message.includes('Flooding was detected'));
|
||||||
'Flooding was detected in this HTTP/2 session, and it must be closed'
|
clearInterval(interval);
|
||||||
}));
|
});
|
||||||
session.on('close', common.mustCall(() => {
|
session.on('close', common.mustCall(() => {
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
@ -31,9 +35,7 @@ server.listen(0, common.mustCall(() => {
|
|||||||
const client = net.connect(server.address().port);
|
const client = net.connect(server.address().port);
|
||||||
|
|
||||||
// nghttp2 uses a limit of 10000 items in it's outbound queue.
|
// nghttp2 uses a limit of 10000 items in it's outbound queue.
|
||||||
// If this number is exceeded, a flooding error is raised. Set
|
// If this number is exceeded, a flooding error is raised.
|
||||||
// this lim higher to account for the ones that nghttp2 is
|
|
||||||
// successfully able to respond to.
|
|
||||||
// TODO(jasnell): Unfortunately, this test is inherently flaky because
|
// TODO(jasnell): Unfortunately, this test is inherently flaky because
|
||||||
// it is entirely dependent on how quickly the server is able to handle
|
// 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
|
// the inbound frames and whether those just happen to overflow nghttp2's
|
||||||
@ -42,8 +44,10 @@ server.listen(0, common.mustCall(() => {
|
|||||||
client.on('connect', common.mustCall(() => {
|
client.on('connect', common.mustCall(() => {
|
||||||
client.write(http2util.kClientMagic, () => {
|
client.write(http2util.kClientMagic, () => {
|
||||||
client.write(kSettings.data, () => {
|
client.write(kSettings.data, () => {
|
||||||
for (let n = 0; n < 35000; n++)
|
interval = setInterval(() => {
|
||||||
|
for (let n = 0; n < 10000; n++)
|
||||||
client.write(kPing.data);
|
client.write(kPing.data);
|
||||||
|
}, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user