From e001aafee31078c654c7cfd9fa80360b9faa1f0d Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 25 Aug 2022 15:56:40 +0800 Subject: [PATCH] test: raise sleep times in child process tests 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: https://github.com/nodejs/node/pull/44375 Refs: https://github.com/nodejs/build/issues/3014 Reviewed-By: Moshe Atlow Reviewed-By: Nitzan Uziely --- test/parallel/test-child-process-spawnsync-timeout.js | 9 ++++++++- test/sequential/test-child-process-execsync.js | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-timeout.js b/test/parallel/test-child-process-spawnsync-timeout.js index aeb2be86608cf4..426ac05a43497c 100644 --- a/test/parallel/test-child-process-spawnsync-timeout.js +++ b/test/parallel/test-child-process-spawnsync-timeout.js @@ -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': diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 5512eaeed7af35..75acbc34a902bd 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -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 };