X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fcluster%2Fdynamic.test.js;h=ed6340830ad4de242772fa3f8078974bf4d10968;hb=e8a4c3ea4d5123ff7c158d139ca142144ccc1117;hp=a5250e538a2eedf562d43981998adf4207092e72;hpb=1c6fe997dcb16b510da6587b992cd3f66d62a259;p=poolifier.git diff --git a/tests/pools/cluster/dynamic.test.js b/tests/pools/cluster/dynamic.test.js index a5250e53..ed634083 100644 --- a/tests/pools/cluster/dynamic.test.js +++ b/tests/pools/cluster/dynamic.test.js @@ -19,7 +19,7 @@ describe('Dynamic cluster pool test suite', () => { let result = await pool.execute({ function: WorkerFunctions.fibonacci }) - expect(result).toBe(121393) + expect(result).toBe(75025) result = await pool.execute({ function: WorkerFunctions.factorial }) @@ -37,7 +37,11 @@ describe('Dynamic cluster pool test suite', () => { // The `busy` event is triggered when the number of submitted tasks at once reach the max number of workers in the dynamic pool. // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool. expect(poolBusy).toBe(max + 1) - const numberOfExitEvents = await TestUtils.waitWorkerExits(pool, max - min) + const numberOfExitEvents = await TestUtils.waitWorkerEvents( + pool, + 'exit', + max - min + ) expect(numberOfExitEvents).toBe(max - min) }) @@ -47,18 +51,18 @@ describe('Dynamic cluster pool test suite', () => { pool.execute() } expect(pool.workerNodes.length).toBeGreaterThan(min) - await TestUtils.waitWorkerExits(pool, max - min) + await TestUtils.waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) for (let i = 0; i < max * 2; i++) { pool.execute() } expect(pool.workerNodes.length).toBeGreaterThan(min) - await TestUtils.waitWorkerExits(pool, max - min) + await TestUtils.waitWorkerEvents(pool, 'exit', max - min) expect(pool.workerNodes.length).toBe(min) }) it('Shutdown test', async () => { - const exitPromise = TestUtils.waitWorkerExits(pool, min) + const exitPromise = TestUtils.waitWorkerEvents(pool, 'exit', min) await pool.destroy() const numberOfExitEvents = await exitPromise expect(numberOfExitEvents).toBe(min) @@ -98,7 +102,7 @@ describe('Dynamic cluster pool test suite', () => { longRunningPool.execute() } expect(longRunningPool.workerNodes.length).toBe(max) - await TestUtils.waitWorkerExits(longRunningPool, max - min) + await TestUtils.waitWorkerEvents(longRunningPool, 'exit', max - min) expect(longRunningPool.workerNodes.length).toBe(min) expect( longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get(