Skip to content

Commit 01749f0

Browse files
TrottMylesBorins
authored andcommitted
test: fix flaky test-http2-settings-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. Fixes: #18251 PR-URL: #19349 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
1 parent c1fa092 commit 01749f0

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎test/sequential/sequential.status‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ test-inspector-bindings : PASS, FLAKY
1212
test-inspector-debug-end : PASS, FLAKY
1313
test-inspector-async-hook-setup-at-signal: PASS, FLAKY
1414
test-http2-ping-flood : PASS, FLAKY
15-
test-http2-settings-flood : PASS, FLAKY
1615

1716
[$system==linux]
1817

‎test/sequential/test-http2-settings-flood.js‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const common = require('../common');
44
if(!common.hasCrypto)
55
common.skip('missing crypto');
66

7+
constassert=require('assert');
78
consthttp2=require('http2');
89
constnet=require('net');
10+
911
consthttp2util=require('../common/http2');
1012

1113
// Test that settings flooding causes the session to be torn down
@@ -14,13 +16,16 @@ const kSettings = new http2util.SettingsFrame();
1416

1517
constserver=http2.createServer();
1618

19+
letinterval;
20+
1721
server.on('stream',common.mustNotCall());
1822
server.on('session',common.mustCall((session)=>{
19-
session.on('error',common.expectsError({
20-
code: 'ERR_HTTP2_ERROR',
21-
message:
22-
'Flooding was detected in this HTTP/2 session, and it must be closed'
23-
}));
23+
session.on('error',(e)=>{
24+
assert.strictEqual(e.code,'ERR_HTTP2_ERROR');
25+
assert(e.message.includes('Flooding was detected'));
26+
clearInterval(interval);
27+
});
28+
2429
session.on('close',common.mustCall(()=>{
2530
server.close();
2631
}));
@@ -30,18 +35,18 @@ server.listen(0, common.mustCall(() => {
3035
constclient=net.connect(server.address().port);
3136

3237
// nghttp2 uses a limit of 10000 items in it's outbound queue.
33-
// If this number is exceeded, a flooding error is raised. Set
34-
// this lim higher to account for the ones that nghttp2 is
35-
// successfully able to respond to.
38+
// If this number is exceeded, a flooding error is raised.
3639
// TODO(jasnell): Unfortunately, this test is inherently flaky because
3740
// it is entirely dependent on how quickly the server is able to handle
3841
// the inbound frames and whether those just happen to overflow nghttp2's
3942
// outbound queue. The threshold at which the flood error occurs can vary
4043
// from one system to another, and from one test run to another.
4144
client.on('connect',common.mustCall(()=>{
4245
client.write(http2util.kClientMagic,()=>{
43-
for(letn=0;n<35000;n++)
44-
client.write(kSettings.data);
46+
interval=setInterval(()=>{
47+
for(letn=0;n<10000;n++)
48+
client.write(kSettings.data);
49+
},1);
4550
});
4651
}));
4752

0 commit comments

Comments
 (0)