From 2b4fddb81e6a35039aeea4ae20ec7d02e2c7aed8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 5 May 2023 21:39:26 +0200 Subject: [PATCH] test: fix fair share strategy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../selection-strategies.test.js | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/tests/pools/selection-strategies/selection-strategies.test.js b/tests/pools/selection-strategies/selection-strategies.test.js index af63b3e9..1edc1234 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.js +++ b/tests/pools/selection-strategies/selection-strategies.test.js @@ -461,13 +461,11 @@ describe('Selection strategies test suite', () => { promises.push(pool.execute()) } await Promise.all(promises) - if (process.platform !== 'win32') { - expect( - pool.workerChoiceStrategyContext.workerChoiceStrategies.get( - pool.workerChoiceStrategyContext.workerChoiceStrategy - ).workersVirtualTaskTimestamp.length - ).toBe(pool.workerNodes.length) - } + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).workersVirtualTaskTimestamp.length + ).toBe(pool.workerNodes.length) // We need to clean up the resources after our test await pool.destroy() }) @@ -497,13 +495,11 @@ describe('Selection strategies test suite', () => { expect(workerNode.tasksUsage.medRunTime).toBeDefined() expect(workerNode.tasksUsage.medRunTime).toBeGreaterThan(0) } - if (process.platform !== 'win32') { - expect( - pool.workerChoiceStrategyContext.workerChoiceStrategies.get( - pool.workerChoiceStrategyContext.workerChoiceStrategy - ).workersVirtualTaskTimestamp.length - ).toBe(pool.workerNodes.length) - } + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).workersVirtualTaskTimestamp.length + ).toBe(pool.workerNodes.length) // We need to clean up the resources after our test await pool.destroy() }) @@ -524,20 +520,25 @@ describe('Selection strategies test suite', () => { workerChoiceStrategy ).workersVirtualTaskTimestamp.length ).toBe(0) + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + workerChoiceStrategy + ).workersVirtualTaskTimestamp[0] = 0 + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + workerChoiceStrategy + ).workersVirtualTaskTimestamp.length + ).toBe(1) pool.setWorkerChoiceStrategy(workerChoiceStrategy) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( workerChoiceStrategy ).workersVirtualTaskTimestamp ).toBeInstanceOf(Array) - pool.workerChoiceStrategyContext.workerChoiceStrategies.get( - workerChoiceStrategy - ).workersVirtualTaskTimestamp[0] = 0 expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( workerChoiceStrategy ).workersVirtualTaskTimestamp.length - ).toBe(1) + ).toBe(0) await pool.destroy() pool = new DynamicThreadPool( min, @@ -549,6 +550,11 @@ describe('Selection strategies test suite', () => { workerChoiceStrategy ).workersVirtualTaskTimestamp ).toBeInstanceOf(Array) + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + workerChoiceStrategy + ).workersVirtualTaskTimestamp.length + ).toBe(0) pool.workerChoiceStrategyContext.workerChoiceStrategies.get( workerChoiceStrategy ).workersVirtualTaskTimestamp[0] = 0 @@ -652,18 +658,16 @@ describe('Selection strategies test suite', () => { promises.push(pool.execute()) } await Promise.all(promises) - if (process.platform !== 'win32') { - expect( - pool.workerChoiceStrategyContext.workerChoiceStrategies.get( - pool.workerChoiceStrategyContext.workerChoiceStrategy - ).defaultWorkerWeight - ).toBeGreaterThan(0) - expect( - pool.workerChoiceStrategyContext.workerChoiceStrategies.get( - pool.workerChoiceStrategyContext.workerChoiceStrategy - ).workerVirtualTaskRunTime - ).toBeGreaterThanOrEqual(0) - } + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).defaultWorkerWeight + ).toBeGreaterThan(0) + expect( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).workerVirtualTaskRunTime + ).toBeGreaterThanOrEqual(0) // We need to clean up the resources after our test await pool.destroy() }) -- 2.34.1