Skip to content

Commit

Permalink
test: fix flaky http timeout test
Browse files Browse the repository at this point in the history
There is no guarantee that a timeout won't be delayed considerably due
to unrelated activity on the host. Instead of checking that the timeout
happens within a certain tolerance, simply check that it did not happen
too soon.

Fixes: #22041

PR-URL: #22403
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and targos committed Sep 3, 2018
1 parent 33994d8 commit 5aa3100
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/sequential/test-http-client-timeout-option-with-agent.js
Expand Up @@ -42,8 +42,9 @@ function doRequest() {
timeout_events += 1;
const duration = Date.now() - start;
// The timeout event cannot be precisely timed. It will delay
// some number of milliseconds, so test it in second units.
assert.strictEqual(duration / 1000 | 0, HTTP_CLIENT_TIMEOUT / 1000);
// some number of milliseconds.
assert.ok(duration >= HTTP_CLIENT_TIMEOUT,
`${duration} < ${HTTP_CLIENT_TIMEOUT}`);
}));
req.end();

Expand Down

0 comments on commit 5aa3100

Please sign in to comment.