Skip to content

Commit 1b8c238

Browse files
Trottitaloacasas
authored andcommitted
test: fix flaky test-regress-nodejsGH-897
Even after being moved to `sequential` in 1ce05ad, `test-regress-nodejsGH-897` still was occasionally flaky on Raspberry Pi devices on CI. The test is especially sensitive to resource constraints. It failed reliably on my laptop if I moved it to `parallel` and ran 32 competing node test processes. Even for a flaky test, that's unusually low. I typically don't see problems, even for flaky tests, until I get up to around four times that number. On a Raspberry Pi, of course, that sensitivity to resource constraints will manifest much sooner. This change checks the order of timers firing, rather than the duration before a timer is fired. This eliminates the sensitivity to resource constraints. The test can now be moved back to `parallel`. I am able to run many copies of the test simultaneously without seeing test failures. PR-URL: nodejs#10903 Fixes: nodejs#10073 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 35db3ce commit 1b8c238

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

test/parallel/test-regress-GH-897.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
// Test for bug where a timer duration greater than 0 ms but less than 1 ms
4+
// resulted in the duration being set for 1000 ms. The expected behavior is
5+
// that the timeout would be set for 1 ms, and thus fire before timers set
6+
// with values greater than 1ms.
7+
//
8+
// Ref: https://github.com/nodejs/node-v0.x-archive/pull/897
9+
10+
const common = require('../common');
11+
12+
let timer;
13+
14+
setTimeout(function() {
15+
clearTimeout(timer);
16+
}, 0.1); // 0.1 should be treated the same as 1, not 1000...
17+
18+
timer = setTimeout(function() {
19+
common.fail('timers fired out of order');
20+
}, 2); // ...so this timer should fire second.

test/sequential/test-regress-GH-897.js

-17
This file was deleted.

0 commit comments

Comments
 (0)