diff options
author | Rich Trott <rtrott@gmail.com> | 2018-08-19 09:15:04 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-08-20 18:59:00 -0700 |
commit | fd76a3d482db94aa06c28f10b1572bb492451a5e (patch) | |
tree | 0f1ed1c18ba4b7b066c9d45ab4e1d9891c118359 /test/sequential | |
parent | b1e26128f317a6f5a5808a0a727e98f80f088b84 (diff) | |
download | android-node-v8-fd76a3d482db94aa06c28f10b1572bb492451a5e.tar.gz android-node-v8-fd76a3d482db94aa06c28f10b1572bb492451a5e.tar.bz2 android-node-v8-fd76a3d482db94aa06c28f10b1572bb492451a5e.zip |
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: https://github.com/nodejs/node/issues/22041
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/sequential')
-rw-r--r-- | test/sequential/test-http-client-timeout-option-with-agent.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/sequential/test-http-client-timeout-option-with-agent.js b/test/sequential/test-http-client-timeout-option-with-agent.js index a7f750a42e..63f683975d 100644 --- a/test/sequential/test-http-client-timeout-option-with-agent.js +++ b/test/sequential/test-http-client-timeout-option-with-agent.js @@ -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(); |