From 7fd82a1cb4d9d43e0f44333db35d3c4ad694e010 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 12 Oct 2022 00:40:20 +0200 Subject: [PATCH] Tests: simplify tasks usage reset MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/pools/abstract/abstract-pool.test.js | 29 ++-------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index e1c83b6f..4224f4ff 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -234,37 +234,12 @@ describe('Abstract pool test suite', () => { }) it('Verify that worker pool tasks usage are reset at worker choice strategy change', async () => { - let pool = new FixedThreadPool( - numberOfWorkers, - './tests/worker-files/thread/testWorker.js' - ) - const promises = [] - for (let i = 0; i < numberOfWorkers * 2; i++) { - promises.push(pool.execute()) - } - await Promise.all(promises) - for (const tasksUsage of pool.workersTasksUsage.values()) { - expect(tasksUsage).toBeDefined() - expect(tasksUsage.run).toBe(numberOfWorkers * 2) - expect(tasksUsage.running).toBe(0) - expect(tasksUsage.runTime).toBeGreaterThanOrEqual(0) - expect(tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0) - } - pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE) - for (const tasksUsage of pool.workersTasksUsage.values()) { - expect(tasksUsage).toBeDefined() - expect(tasksUsage.run).toBe(0) - expect(tasksUsage.running).toBe(0) - expect(tasksUsage.runTime).toBe(0) - expect(tasksUsage.avgRunTime).toBe(0) - } - await pool.destroy() - pool = new DynamicThreadPool( + const pool = new DynamicThreadPool( numberOfWorkers, numberOfWorkers, './tests/worker-files/thread/testWorker.js' ) - promises.length = 0 + const promises = [] for (let i = 0; i < numberOfWorkers * 2; i++) { promises.push(pool.execute()) } -- 2.34.1