-
Notifications
You must be signed in to change notification settings - Fork 30k
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-session-timeout #20692
Conversation
This version of the test is demonstrably more reliable than the current version when tested this way:
You may need to adjust the value of the Current version of test: 142/50, 159/33, 153/39 /cc @apapirovski |
@@ -34,12 +34,14 @@ server.listen(0, common.mustCall(() => { | |||
request.end(); | |||
|
|||
request.on('end', () => { | |||
if (attempts) { | |||
setTimeout(() => makeReq(attempts - 1), callTimeout); | |||
const diff = process.hrtime(startTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm -1 on this change. process.hrtime
isn't cheap so it's more — not less — likely to create situations where this test fails on slow platforms.
Actually, scratch that, I see what's making this more reliable.
const diff = process.hrtime(startTime); | ||
const milliseconds = (diff[0] * 1e3 + diff[1] / 1e6); | ||
if (milliseconds < serverTimeout * 2) { | ||
setTimeout(() => makeReq(), callTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: if I'm not wrong we can pass makeReq
directly without wrapping it in another function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Changed. Thanks!
#20692 (comment) suggests this doesn't fix the test but instead makes it less likely to fail, i.e., it's still flaky? If so can we reword the commit to something other than |
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. Fixes: nodejs#20628
@richardlau I went with "improve reliability" although I had to abbreviate the test name to keep it under 50 chars. (I removed |
Landed in 9e4ae56 |
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. PR-URL: #20692 Fixes: #20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. PR-URL: #20692 Fixes: #20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. PR-URL: nodejs#20692 Fixes: nodejs#20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. PR-URL: nodejs#20692 Fixes: nodejs#20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. PR-URL: nodejs#20692 Fixes: nodejs#20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to setTimeout() in test-http2-session-timeout more robust. Backport-PR-URL: #22850 PR-URL: #20692 Fixes: #20628 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Check actual expired time rather than relying on a number of calls to
setTimeout()
in test-http2-session-timeout more robust.Fixes: #20628
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes