test: fix fair share strategy
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 5 May 2023 19:39:26 +0000 (21:39 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 5 May 2023 19:39:26 +0000 (21:39 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/selection-strategies/selection-strategies.test.js

index af63b3e976113702b98ec5947c54fc4ba03e44fe..1edc123407cceb7f2ac79252b34b358c52e25c6d 100644 (file)
@@ -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()
   })