Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
test: fix flaky http(s)-set-timeout-server tests#14380
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Trott commented Jul 20, 2017
/cc @nodejs/testing |
refack commented Jul 20, 2017
Aren't we excluding an important step in the test? |
refack left a comment
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.
Let's discuss
Trott commented Jul 20, 2017
@refack You have a point. Less elegant but more correct fix coming in a bit... |
Trott commented Jul 20, 2017
This solution still fails under load. The connection handler still might never get called, and now without calling |
Trott commented Jul 20, 2017
Moving the Ultimately, may just add a test case: one that solution and one the solution that's here. Then we're getting at everything one way or another (hopefully). |
Trott commented Jul 20, 2017
Trott commented Jul 20, 2017
Trott commented Jul 20, 2017
Stress test showing failures on master (expected to fail): Stress test on this PR (expected to pass): |
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.
suggestion: If it "might" not be invoked maybe remove?
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.
If it is invoked, we want to make sure timeout event does not fire on req and res (I guess?).
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.
But that's what the new test case does.
Superficially this is not wrong or harmful, but might be distracting for future maintainers.
IMHO either remove, or add to the comment that the next test case makes sure this is always true.
refack commented Jul 20, 2017
Fast timeout makes sense. |
cjihrig commented Jul 20, 2017
LGTM |
Trott commented Jul 21, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
This PR fails in stress test, but much less frequently |
Trott commented Jul 21, 2017
Made some adjustments (PTAL, I did not squash the commits for hopefully easier review). Stress test on this PR: https://ci.nodejs.org/job/node-stress-single-test/1338/ |
refack commented Jul 21, 2017
|
refack commented Jul 21, 2017
P.S. constserver=http.createServer().on('connection',(req,res)=>{req.on('timeout',common.mustNotCall());res.on('timeout',common.mustNotCall());})Can a |
trevnorris commented Jul 21, 2017
@refack first need to correct your code. it should be: constprint=process._rawDebug;constserver=require('http').createServer();server.on('request',(req,res)=>{// this will never fire b/c the request is complete before this callback fires.req.on('timeout',()=>print('req timeout'));// will fire a default 2 mins in the future if the connection isn't closed.res.on('timeout',()=>print('res timeout'));});sever.listen(8080);The This is different from constprint=process._rawDebug;constreq=require('http').request({hostname: 'www.reddit.com'},res=>{print('req callback fired');});constt=process.hrtime();req.setTimeout(10,()=>{constu=process.hrtime(t);print('timeout:',(u[0]*1e3+u[1]/1e6)>>>0,'ms');});req.end();My machine prints
|
Trott commented Jul 22, 2017
@trevnorris wrote: // will fire a default 2 mins in the future if the connection isn't closed.res.on('timeout',()=>print('res timeout'));Ah, of course, but if we're calling Just confirmed running the test locally under heavy load that reducing the timeout to 1ms makes the test far more reliable and increasing it to 5000 makes it reliable under the amount of load I was using. I think the thing to do is remove the test for that timeout to not fire, as clearly it can. Probably won't solve the |
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). Fixes: nodejs#11768
Trott commented Jul 24, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Comments added per nits from @refack. Rebased against master, so running CI again for good measure. CI: https://ci.nodejs.org/job/node-test-pull-request/9332/ EDIT: Windows failure unrelated. |
refack left a comment
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.
👍
Trott commented Jul 25, 2017
Jenkins was restarted so previous CI either didn't run or we lost the results. |
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: nodejs#14380Fixes: nodejs#11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
Trott commented Jul 25, 2017
Landed in c5bed4c |
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: #14380Fixes: #11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: #14380Fixes: #11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: #14380Fixes: #11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: #14380Fixes: #11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
The tests include a callback that might not be invoked but is wrapped in common.mustCall(). Remove the common.mustCall() wrapper and add a comment explaining that it should not be added. Add a new test case that sets the timeout to 1ms and waits for both the connection handler and the timeout handler to be invoked. This version keeps the common.mustCall() wrapper intact around the connection handler (although it's mostly semantic and not necessary for the test as the test will certainly fail or time out if that handler isn't invoked). PR-URL: #14380Fixes: #11768 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]>
The tests include a callback that might not be invoked but is wrapped in
common.mustCall(). Remove the common.mustCall() wrapper and add a
comment explaining that it should not be added.
Fixes: #11768
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test http https