Skip to content

Commit

Permalink
test: raise sleep times in child process tests
Browse files Browse the repository at this point in the history
sequential/test-child-process-execsync and
parallel/test-child-process-spawnsync-timeout are both flaky
on azure Windows machines, where it may take longer for Node.js
to launch and receive output from child processes. These tests
work by spawning a child processes that is supposed to sleep
for a long time, but the option is configured so that Node.js
would terminate them early when a shorter timeout is reached.
Then the tests assert that the time taken for the whole thing
is shorter than the specified sleep time (meaning the process
don't actually get to sleep for that long). To make the tests
less brittle on azure Windows, this patch raises the sleep
times in those tests on Windows platform, so that the overhead
can be taken into account there.

PR-URL: nodejs/node#44375
Refs: nodejs/build#3014
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
  • Loading branch information
joyeecheung authored and guangwong committed Jan 3, 2023
1 parent 4d4f6fd commit 24442ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion test/parallel/test-child-process-spawnsync-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ const { debuglog, getSystemErrorName } = require('util');
const debug = debuglog('test');

const TIMER = 200;
const SLEEP = common.platformTimeout(5000);
let SLEEP = common.platformTimeout(5000);

if (common.isWindows) {
// Some of the windows machines in the CI need more time to launch
// and receive output from child processes.
// https://github.com/nodejs/build/issues/3014
SLEEP = common.platformTimeout(15000);
}

switch (process.argv[2]) {
case 'child':
Expand Down
8 changes: 7 additions & 1 deletion test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const { execFileSync, execSync, spawnSync } = require('child_process');
const { getSystemErrorName } = require('util');

const TIMER = 200;
const SLEEP = 2000;
let SLEEP = 2000;
if (common.isWindows) {
// Some of the windows machines in the CI need more time to launch
// and receive output from child processes.
// https://github.com/nodejs/build/issues/3014
SLEEP = 10000;
}

const execOpts = { encoding: 'utf8', shell: true };

Expand Down

0 comments on commit 24442ac

Please sign in to comment.