From 333593ecfe5e41dec70499c292919a01e4b6a3a2 Mon Sep 17 00:00:00 2001 From: hyj1991 Date: Fri, 21 Oct 2022 09:42:18 +0800 Subject: [PATCH] chore: make test more reliable (#205) --- .gitignore | 6 +++-- test/commands.test.js | 21 +++++++++++------ test/config.test.js | 2 +- .../{command.test.js => cases/command.js} | 4 ++-- .../{config.test.js => cases/config.js} | 2 +- .../{hooks.test.js => cases/hooks.js} | 14 ++++++----- .../{logbypass.test.js => cases/logbypass.js} | 8 +++---- .../unfinished.js} | 23 +++++++++++-------- test/fixtures/{ => scripts}/exit.js | 6 ++--- .../fatal_error.js} | 4 ++-- .../process_blocking.js} | 6 ++--- .../process_normal.js} | 6 ++--- .../fixtures/{ => scripts}/worker_blocking.js | 6 ++--- .../{ => scripts}/worker_indefinite.js | 2 +- .../{worker.js => scripts/worker_normal.js} | 4 ++-- test/fixtures/utils.js | 3 +++ test/hooks.test.js | 2 +- test/logbypass.test.js | 2 +- test/unfinished.test.js | 20 ++++++++++++---- test/worker_threads.test.js | 8 +++---- 20 files changed, 88 insertions(+), 61 deletions(-) rename test/fixtures/{command.test.js => cases/command.js} (99%) rename test/fixtures/{config.test.js => cases/config.js} (98%) rename test/fixtures/{hooks.test.js => cases/hooks.js} (87%) rename test/fixtures/{logbypass.test.js => cases/logbypass.js} (96%) rename test/fixtures/{unfinished.test.js => cases/unfinished.js} (85%) rename test/fixtures/{ => scripts}/exit.js (78%) rename test/fixtures/{fatal-error.js => scripts/fatal_error.js} (86%) rename test/fixtures/{blocking.js => scripts/process_blocking.js} (92%) rename test/fixtures/{non-blocking.js => scripts/process_normal.js} (89%) rename test/fixtures/{ => scripts}/worker_blocking.js (88%) rename test/fixtures/{ => scripts}/worker_indefinite.js (91%) rename test/fixtures/{worker.js => scripts/worker_normal.js} (79%) diff --git a/.gitignore b/.gitignore index a50ad81..31b3a91 100644 --- a/.gitignore +++ b/.gitignore @@ -70,7 +70,9 @@ demo.js client.js -logdir - release +logdir* + +tmphome* + diff --git a/test/commands.test.js b/test/commands.test.js index a470cad..41518e0 100644 --- a/test/commands.test.js +++ b/test/commands.test.js @@ -5,6 +5,8 @@ const fs = require('fs'); const path = require('path'); const cp = require('child_process'); const promisify = require('util').promisify; +const readdir = promisify(fs.readdir); +const unlink = promisify(fs.unlink); const exec = promisify(cp.exec); const mm = require('mm'); const expect = require('expect.js'); @@ -14,22 +16,22 @@ const xctl = require('../lib/xctl'); const utils = require('./fixtures/utils'); const currentPlatform = os.platform(); -const commandTestFixture = require('./fixtures/command.test'); +const commandTestFixture = require('./fixtures/cases/command'); const { checkProfile } = commandTestFixture; const logdir = utils.createLogDir('logdir_command'); const tmphome = utils.createLogDir('tmphome_command'); const testConfig = commandTestFixture(logdir); const testFiles = [ { - jspath: path.join(__dirname, './fixtures/blocking.js'), - desc: 'when js main thread blocking' + jspath: path.join(__dirname, './fixtures/scripts/process_normal.js'), + desc: 'when js main thread normal execute' }, { - jspath: path.join(__dirname, './fixtures/non-blocking.js'), - desc: 'when js main thread non blocking' + jspath: path.join(__dirname, './fixtures/scripts/process_blocking.js'), + desc: 'when js main thread blocking' }, { - jspath: path.join(__dirname, './fixtures/worker_blocking.js'), + jspath: path.join(__dirname, './fixtures/scripts/worker_blocking.js'), desc: 'when js worker thread blocking', threadId: 1, }, @@ -78,6 +80,7 @@ describe('commands', () => { // wait for xprofiler to start await new Promise(resolve => p.on('message', msg => msg.type === utils.clientConst.xprofilerDone && resolve())); + await utils.sleep(500); // send cmd with xctl (function) console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}]`, 'send xctl cmd.'); @@ -102,8 +105,12 @@ describe('commands', () => { exitInfo = await utils.getChildProcessExitInfo(p); }); - after(function () { + after(async function () { mm.restore(); + const files = await readdir(logdir); + for (const file of files) { + await unlink(path.join(logdir, file)); + } if (i === testConfig.length - 1 && j === testFiles.length - 1) { utils.cleanDir(logdir); utils.cleanDir(tmphome); diff --git a/test/config.test.js b/test/config.test.js index 42a3b68..d6403fa 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const mm = require('mm'); const expect = require('expect.js'); const xprofiler = require('../xprofiler'); -const testXprofilerConfigKeys = require('./fixtures/config.test'); +const testXprofilerConfigKeys = require('./fixtures/cases/config'); const utils = require('./fixtures/utils'); const testKeys = Object.keys(testXprofilerConfigKeys); diff --git a/test/fixtures/command.test.js b/test/fixtures/cases/command.js similarity index 99% rename from test/fixtures/command.test.js rename to test/fixtures/cases/command.js index e4af8f5..af723e9 100644 --- a/test/fixtures/command.test.js +++ b/test/fixtures/cases/command.js @@ -4,8 +4,8 @@ const os = require('os'); const cp = require('child_process'); const moment = require('moment'); const expect = require('expect.js'); -const { filterTestCaseByPlatform } = require('./utils'); -const pkg = require('../../package.json'); +const { filterTestCaseByPlatform } = require('../utils'); +const pkg = require('../../../package.json'); const currentPlatform = os.platform(); diff --git a/test/fixtures/config.test.js b/test/fixtures/cases/config.js similarity index 98% rename from test/fixtures/config.test.js rename to test/fixtures/cases/config.js index 34086d0..04dcb21 100644 --- a/test/fixtures/config.test.js +++ b/test/fixtures/cases/config.js @@ -2,7 +2,7 @@ const os = require('os'); const path = require('path'); -const utils = require('./utils'); +const utils = require('../utils'); function getExtra(key, expected, ext) { return ext.map(item => { diff --git a/test/fixtures/hooks.test.js b/test/fixtures/cases/hooks.js similarity index 87% rename from test/fixtures/hooks.test.js rename to test/fixtures/cases/hooks.js index 49e04bb..41faf7a 100644 --- a/test/fixtures/hooks.test.js +++ b/test/fixtures/cases/hooks.js @@ -4,15 +4,17 @@ const fs = require('fs'); const path = require('path'); const expect = require('expect.js'); -const { profileRule: { diag }, checkProfile, checkCoreDump } = require('./command.test'); -const { filterTestCaseByPlatform } = require('./utils'); +const { profileRule: { diag }, checkProfile, checkCoreDump } = require('./command'); +const { filterTestCaseByPlatform } = require('../utils'); + +const exitFatalErrorScriptPath = path.join(__dirname, '../scripts/fatal_error.js'); exports = module.exports = function () { const list = [ { title: 'fatal error hook is valid', subTitle: 'x-fatal-error.diag is created when fatal error occured.', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, regexp: /x-fatal-error-(\d+)-(\d+)-(\d+).diag/, check(file) { const content = fs.readFileSync(file, 'utf8').trim(); @@ -24,7 +26,7 @@ exports = module.exports = function () { platform: 'linux', title: 'fatal error hook is valid', subTitle: 'x-fatal-error.core is created when fatal error occured.', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, regexp: /x-fatal-error-(\d+)-(\d+)-(\d+).core/, check(file) { checkCoreDump(file, 'fatal error core elf information'); @@ -38,7 +40,7 @@ exports = module.exports = function () { platform: 'win32', title: 'fatal error hook is valid', subTitle: 'x-fatal-error.core is created when fatal error occured.', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, regexp: /x-fatal-error-(\d+)-(\d+)-(\d+).core/, check(file) { const content = fs.readFileSync(file, 'utf8').trim(); @@ -54,7 +56,7 @@ exports = module.exports = function () { platform: 'darwin', title: 'fatal error hook is valid', subTitle: 'x-fatal-error.core is created when fatal error occured.', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, regexp: /x-fatal-error-(\d+)-(\d+)-(\d+).core/, check(file) { const content = fs.readFileSync(file, 'utf8').trim(); diff --git a/test/fixtures/logbypass.test.js b/test/fixtures/cases/logbypass.js similarity index 96% rename from test/fixtures/logbypass.test.js rename to test/fixtures/cases/logbypass.js index 49389b8..3fe76d2 100644 --- a/test/fixtures/logbypass.test.js +++ b/test/fixtures/cases/logbypass.js @@ -2,9 +2,9 @@ const path = require('path'); const moment = require('moment'); -const utils = require('./utils'); -const blocking = path.join(__dirname, 'blocking.js'); -const nonBlocking = path.join(__dirname, 'non-blocking.js'); +const utils = require('../utils'); +const blocking = path.join(__dirname, '../scripts/process_blocking.js'); +const nonBlocking = path.join(__dirname, '../scripts/process_normal.js'); function setRules(list, alinode, { alinodeRule, xprofilerRule }) { const rules = {}; @@ -113,7 +113,7 @@ function getTestCases(title, logdirBlocking, logdirNonBlocking, envConfig, struc env: { XPROFILER_LOG_DIR: logdirBlocking } }; const nonBlockingTarget = { - title: `${subtitle} non-blocking`, + title: `${subtitle} normal`, file: nonBlocking, env: { XPROFILER_LOG_DIR: logdirNonBlocking } }; diff --git a/test/fixtures/unfinished.test.js b/test/fixtures/cases/unfinished.js similarity index 85% rename from test/fixtures/unfinished.test.js rename to test/fixtures/cases/unfinished.js index faa60f5..a849827 100644 --- a/test/fixtures/unfinished.test.js +++ b/test/fixtures/cases/unfinished.js @@ -2,14 +2,17 @@ const fs = require('fs'); const path = require('path'); -const { profileRule: { cpuprofile, heapprofile, gcprofile }, checkProfile } = require('./command.test'); +const { profileRule: { cpuprofile, heapprofile, gcprofile }, checkProfile } = require('./command'); + +const exitFatalErrorScriptPath = path.join(__dirname, '../scripts/fatal_error.js'); +const exitNormalScriptPath = path.join(__dirname, '../scripts/exit.js'); exports = module.exports = function () { const list = [ // fatal error { title: ' cpu profiling', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, tid: 0, cmd: 'start_cpu_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -21,7 +24,7 @@ exports = module.exports = function () { }, { title: ' heap profiling', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, tid: 0, cmd: 'start_heap_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -33,7 +36,7 @@ exports = module.exports = function () { }, { title: ' gc profiling', - jspath: path.join(__dirname, 'fatal-error.js'), + jspath: exitFatalErrorScriptPath, tid: 0, cmd: 'start_gc_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -47,7 +50,7 @@ exports = module.exports = function () { // exit 0 with profiling time { title: ' cpu profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_cpu_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -59,7 +62,7 @@ exports = module.exports = function () { }, { title: ' heap profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_heap_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -71,7 +74,7 @@ exports = module.exports = function () { }, { title: ' gc profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_gc_profiling', options: { profiling_time: 5 * 60 * 1000 }, @@ -85,7 +88,7 @@ exports = module.exports = function () { // exit 0 with no profiling time { title: ' cpu profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_cpu_profiling', options: undefined, @@ -97,7 +100,7 @@ exports = module.exports = function () { }, { title: ' heap profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_heap_profiling', options: undefined, @@ -109,7 +112,7 @@ exports = module.exports = function () { }, { title: ' gc profiling', - jspath: path.join(__dirname, 'exit.js'), + jspath: exitNormalScriptPath, tid: 0, cmd: 'start_gc_profiling', options: undefined, diff --git a/test/fixtures/exit.js b/test/fixtures/scripts/exit.js similarity index 78% rename from test/fixtures/exit.js rename to test/fixtures/scripts/exit.js index b64550d..12920d4 100644 --- a/test/fixtures/exit.js +++ b/test/fixtures/scripts/exit.js @@ -2,8 +2,8 @@ const os = require('os'); const mm = require('mm'); -const xprofiler = require('../../'); -const utils = require('./utils'); +const xprofiler = require('../../../'); +const utils = require('../utils'); if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); @@ -15,4 +15,4 @@ process.send({ type: utils.clientConst.xprofilerDone }); setTimeout(() => { // empty exit -}, 2000); \ No newline at end of file +}, 5000); \ No newline at end of file diff --git a/test/fixtures/fatal-error.js b/test/fixtures/scripts/fatal_error.js similarity index 86% rename from test/fixtures/fatal-error.js rename to test/fixtures/scripts/fatal_error.js index 8a988e7..d01b762 100644 --- a/test/fixtures/fatal-error.js +++ b/test/fixtures/scripts/fatal_error.js @@ -2,8 +2,8 @@ const os = require('os'); const mm = require('mm'); -const xprofiler = require('../../'); -const utils = require('./utils'); +const xprofiler = require('../../../'); +const utils = require('../utils'); if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); diff --git a/test/fixtures/blocking.js b/test/fixtures/scripts/process_blocking.js similarity index 92% rename from test/fixtures/blocking.js rename to test/fixtures/scripts/process_blocking.js index 7852ef2..7840a04 100644 --- a/test/fixtures/blocking.js +++ b/test/fixtures/scripts/process_blocking.js @@ -5,10 +5,10 @@ const mm = require('mm'); const moment = require('moment'); const { v4: uuid } = require('uuid'); const traceid = uuid(); -const utils = require('./utils'); +const utils = require('../utils'); console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}]`, traceid, 'blocking start.'); -const xprofiler = require('../../'); +const xprofiler = require('../../../'); if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); @@ -38,7 +38,7 @@ process.send({ type: utils.clientConst.xprofilerDone }); /*eslint no-empty: "off"*/ const start = Date.now(); -while (Date.now() - start < 8000) { +while (Date.now() - start < 10000) { } diff --git a/test/fixtures/non-blocking.js b/test/fixtures/scripts/process_normal.js similarity index 89% rename from test/fixtures/non-blocking.js rename to test/fixtures/scripts/process_normal.js index e294607..95b0104 100644 --- a/test/fixtures/non-blocking.js +++ b/test/fixtures/scripts/process_normal.js @@ -3,8 +3,8 @@ const mm = require('mm'); const os = require('os'); const http = require('http'); -const utils = require('./utils'); -const xprofiler = require('../../'); +const utils = require('../utils'); +const xprofiler = require('../../../'); if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); @@ -35,7 +35,7 @@ server.unref(); function sendRequest(abort) { const req = http.request('http://localhost:8445'); - req.on('error', err => console.error('non-blocking', err.message)); + req.on('error', err => console.error('normal process', err.message)); req.end(); if (abort) { diff --git a/test/fixtures/worker_blocking.js b/test/fixtures/scripts/worker_blocking.js similarity index 88% rename from test/fixtures/worker_blocking.js rename to test/fixtures/scripts/worker_blocking.js index 8523544..3e58d90 100644 --- a/test/fixtures/worker_blocking.js +++ b/test/fixtures/scripts/worker_blocking.js @@ -5,7 +5,7 @@ const os = require('os'); const mm = require('mm'); const moment = require('moment'); const { v4: uuid } = require('uuid'); -const utils = require('./utils'); +const utils = require('../utils'); const traceid = uuid(); @@ -13,7 +13,7 @@ if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); } -const xprofiler = require('../../xprofiler'); +const xprofiler = require('../../../'); xprofiler.start({ check_throw: false }); if (workerThreads.isMainThread) { @@ -30,7 +30,7 @@ if (workerThreads.isMainThread) { console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}]`, traceid, 'blocking start.'); const start = Date.now(); - while (Date.now() - start < 8000) { /** ignore */ } + while (Date.now() - start < 10000) { /** ignore */ } console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}]`, traceid, 'blocking done.'); } diff --git a/test/fixtures/worker_indefinite.js b/test/fixtures/scripts/worker_indefinite.js similarity index 91% rename from test/fixtures/worker_indefinite.js rename to test/fixtures/scripts/worker_indefinite.js index 73a9b22..5372084 100644 --- a/test/fixtures/worker_indefinite.js +++ b/test/fixtures/scripts/worker_indefinite.js @@ -8,7 +8,7 @@ if (process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR) { mm(os, 'homedir', () => process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR); } -const xprofiler = require('../../xprofiler'); +const xprofiler = require('../../../'); xprofiler.start(); if (workerThreads.isMainThread) { diff --git a/test/fixtures/worker.js b/test/fixtures/scripts/worker_normal.js similarity index 79% rename from test/fixtures/worker.js rename to test/fixtures/scripts/worker_normal.js index 590ddf6..129c698 100644 --- a/test/fixtures/worker.js +++ b/test/fixtures/scripts/worker_normal.js @@ -1,7 +1,7 @@ 'use strict'; const workerThreads = require('worker_threads'); -require('../../xprofiler'); +require('../../../').start(); if (workerThreads.isMainThread) { const w = new workerThreads.Worker(__filename); @@ -9,5 +9,5 @@ if (workerThreads.isMainThread) { console.log('worker exited', code); }); } else { - setTimeout(() => {}, 1000); + setTimeout(() => { }, 1000); } diff --git a/test/fixtures/utils.js b/test/fixtures/utils.js index 68c66c9..29d14fb 100644 --- a/test/fixtures/utils.js +++ b/test/fixtures/utils.js @@ -66,6 +66,9 @@ exports.arrayEqual = function (arr1, arr2) { exports.getChildProcessExitInfo = function (proc) { return new Promise(resolve => { + if (!proc.connected) { + return resolve({ code: proc.exitCode, signal: proc.signalCode }); + } if (proc.exitCode !== null) { return resolve({ code: proc.exitCode, signal: proc.signalCode }); } diff --git a/test/hooks.test.js b/test/hooks.test.js index cc66a2d..6e86100 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -12,7 +12,7 @@ const exists = promisify(fs.exists); const readFile = promisify(fs.readFile); const stat = promisify(fs.stat); const utils = require('./fixtures/utils'); -const cases = require('./fixtures/hooks.test')(); +const cases = require('./fixtures/cases/hooks')(); const currentPlatform = os.platform(); diff --git a/test/logbypass.test.js b/test/logbypass.test.js index eb4e847..01b2019 100644 --- a/test/logbypass.test.js +++ b/test/logbypass.test.js @@ -6,7 +6,7 @@ const expect = require('expect.js'); const moment = require('moment'); const pack = require('../package.json'); const utils = require('./fixtures/utils'); -const getTestCases = require('./fixtures/logbypass.test'); +const getTestCases = require('./fixtures/cases/logbypass'); const logdirBlocking = utils.createLogDir('log_bypass_blocking'); const logdirNonBlocking = utils.createLogDir('log_bypass_non_blocking'); diff --git a/test/unfinished.test.js b/test/unfinished.test.js index b7f1e38..f5db033 100644 --- a/test/unfinished.test.js +++ b/test/unfinished.test.js @@ -2,13 +2,17 @@ const os = require('os'); const fs = require('fs'); +const path = require('path'); const cp = require('child_process'); const mm = require('mm'); const expect = require('expect.js'); const moment = require('moment'); +const promisify = require('util').promisify; +const readdir = promisify(fs.readdir); +const unlink = promisify(fs.unlink); const utils = require('./fixtures/utils'); const xctl = require('../lib/xctl'); -const cases = require('./fixtures/unfinished.test')(); +const cases = require('./fixtures/cases/unfinished')(); const casesLength = cases.length; @@ -25,32 +29,38 @@ describe('unfinished sampling before process exit', function () { before(async function () { mm(os, 'homedir', () => tmphome); const p = cp.fork(cse.jspath, { - execArgv: ['--max-old-space-size=128'], + execArgv: ['--max-old-space-size=256'], env: Object.assign({}, process.env, { XPROFILER_LOG_DIR: logdir, XPROFILER_UNIT_TEST_TMP_HOMEDIR: tmphome, XPROFILER_LOG_LEVEL: 2, XPROFILER_LOG_TYPE: 1, - XPROFILER_FATAL_ERROR_INTERVAL: 100, + XPROFILER_FATAL_ERROR_INTERVAL: 1000, }) }); // wait for xprofiler to start await new Promise(resolve => p.on('message', msg => msg.type === utils.clientConst.xprofilerDone && resolve())); + await utils.sleep(500); // send cmd const pid = p.pid; resByXctl = await xctl(pid, cse.tid, cse.cmd, cse.options); + await utils.sleep(500); // process exit exitInfo = await utils.getChildProcessExitInfo(p); await utils.sleep(2000); }); - after(function () { + after(async function () { + mm.restore(); + const files = await readdir(logdir); + for (const file of files) { + await unlink(path.join(logdir, file)); + } if (cse === cases[casesLength - 1]) { - mm.restore(); utils.cleanDir(logdir); utils.cleanDir(tmphome); } diff --git a/test/worker_threads.test.js b/test/worker_threads.test.js index c841bf7..3bcd9e3 100644 --- a/test/worker_threads.test.js +++ b/test/worker_threads.test.js @@ -31,7 +31,7 @@ describe('worker_threads', () => { describe('load', () => { it('should load xprofiler and exit cleanly', async () => { - proc = fork(path.join(__dirname, 'fixtures/worker.js'), { + proc = fork(path.join(__dirname, 'fixtures/scripts/worker_normal.js'), { env: Object.assign({}, process.env, { XPROFILER_LOG_DIR: logdir, XPROFILER_LOG_LEVEL: 2, @@ -46,14 +46,14 @@ describe('worker_threads', () => { describe('xctl', () => { it('list_environments', async () => { - proc = fork(path.join(__dirname, 'fixtures/worker_indefinite.js'), { + proc = fork(path.join(__dirname, 'fixtures/scripts/worker_indefinite.js'), { env: Object.assign({}, process.env, { XPROFILER_LOG_DIR: logdir, XPROFILER_LOG_LEVEL: 2, XPROFILER_LOG_TYPE: 1, }), }); - await sleep(2000); + await sleep(5000); console.log('perform list_environments'); const result = await xctl(proc.pid, 0, 'list_environments', { logdir, @@ -69,7 +69,7 @@ describe('worker_threads', () => { includesWorker = true; } /** uptime(s) */ - assert(env.uptime < 5); + assert(env.uptime < 10); } assert(includesWorker);