test: improve IWRR coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 21 Dec 2023 00:10:02 +0000 (01:10 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 21 Dec 2023 00:10:02 +0000 (01:10 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/selection-strategies/selection-strategies.test.mjs

index 0feb5387ca7dcf162541023b3f0db56c472e4239..a13d1dade9d0c704e0d7025cf1596cbec739d49f 100644 (file)
@@ -157,6 +157,13 @@ describe('Selection strategies test suite', () => {
             workerChoiceStrategy
           ).roundWeights.length
         ).toBe(1)
+        expect(
+          Number.isSafeInteger(
+            pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+              workerChoiceStrategy
+            ).roundWeights[0]
+          )
+        ).toBe(true)
       }
     }
     await pool.destroy()
@@ -1961,7 +1968,7 @@ describe('Selection strategies test suite', () => {
     await pool.destroy()
   })
 
-  it.skip('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
+  it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
       './tests/worker-files/thread/testWorker.mjs',
@@ -2033,11 +2040,18 @@ describe('Selection strategies test suite', () => {
         pool.workerChoiceStrategyContext.workerChoiceStrategy
       ).roundWeights.length
     ).toBe(1)
+    expect(
+      Number.isSafeInteger(
+        pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+          pool.workerChoiceStrategyContext.workerChoiceStrategy
+        ).roundWeights[0]
+      )
+    ).toBe(true)
     // We need to clean up the resources after our test
     await pool.destroy()
   })
 
-  it.skip('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
+  it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
     const pool = new DynamicThreadPool(
       min,
       max,
@@ -2110,6 +2124,13 @@ describe('Selection strategies test suite', () => {
         pool.workerChoiceStrategyContext.workerChoiceStrategy
       ).roundWeights.length
     ).toBe(1)
+    expect(
+      Number.isSafeInteger(
+        pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+          pool.workerChoiceStrategyContext.workerChoiceStrategy
+        ).roundWeights[0]
+      )
+    ).toBe(true)
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -2172,6 +2193,13 @@ describe('Selection strategies test suite', () => {
         pool.workerChoiceStrategyContext.workerChoiceStrategy
       ).roundWeights.length
     ).toBe(1)
+    expect(
+      Number.isSafeInteger(
+        pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+          pool.workerChoiceStrategyContext.workerChoiceStrategy
+        ).roundWeights[0]
+      )
+    ).toBe(true)
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -2229,6 +2257,13 @@ describe('Selection strategies test suite', () => {
         pool.workerChoiceStrategyContext.workerChoiceStrategy
       ).roundWeights.length
     ).toBe(1)
+    expect(
+      Number.isSafeInteger(
+        pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+          pool.workerChoiceStrategyContext.workerChoiceStrategy
+        ).roundWeights[0]
+      )
+    ).toBe(true)
     // We need to clean up the resources after our test
     await pool.destroy()
   })