Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: fix flaky http timeout test
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
  • Loading branch information
Trott committed Aug 19, 2018
commit 90f3e2ff86198d78551ac94bd3966cb1c69bdfac
5 changes: 3 additions & 2 deletions test/sequential/test-http-client-timeout-option-with-agent.js
Original file line number Diff line number Diff line change
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