test: improve WCS coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Sep 2023 10:56:51 +0000 (12:56 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Sep 2023 10:56:51 +0000 (12:56 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/selection-strategies/selection-strategies.test.js

index 055a2dbb64e6257bef21221f709c2e0756b89d84..51478a0620767d03730d8c441baf9e5ab4c18ea4 100644 (file)
@@ -128,12 +128,7 @@ describe('Selection strategies test suite', () => {
           pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
             workerChoiceStrategy
           ).workersVirtualTaskEndTimestamp
-        ).toBeInstanceOf(Array)
-        expect(
-          pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
-            workerChoiceStrategy
-          ).workersVirtualTaskEndTimestamp.length
-        ).toBe(0)
+        ).toStrictEqual([])
       } else if (
         workerChoiceStrategy === WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
       ) {
@@ -591,6 +586,16 @@ describe('Selection strategies test suite', () => {
         max * maxMultiplier
       )
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -639,6 +644,16 @@ describe('Selection strategies test suite', () => {
         max * maxMultiplier
       )
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -778,6 +793,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.waitTime.aggregate).toBeGreaterThan(0)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -836,6 +861,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.waitTime.aggregate).toBeGreaterThan(0)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -981,6 +1016,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.elu.utilization).toBeLessThanOrEqual(1)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -1045,6 +1090,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.elu.utilization).toBeLessThanOrEqual(1)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -1200,6 +1255,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.elu.utilization).toBeLessThanOrEqual(1)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
@@ -1279,6 +1344,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.elu.utilization).toBeLessThanOrEqual(1)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
@@ -1363,6 +1438,16 @@ describe('Selection strategies test suite', () => {
         expect(workerNode.usage.elu.utilization).toBeLessThanOrEqual(1)
       }
     }
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).nextWorkerNodeKey
+    ).toEqual(expect.any(Number))
+    expect(
+      pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy
+      ).previousWorkerNodeKey
+    ).toEqual(expect.any(Number))
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy