Tests: check strategy internal statistics at pool creation
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 12 Oct 2022 17:45:31 +0000 (19:45 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 12 Oct 2022 17:45:31 +0000 (19:45 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/selection-strategies/selection-strategies.test.js

index 7b11bf402e06f981d53dda669809808dbb3c9ca8..49e87a92dcd1649878c7d5659c4aac1ed5928db7 100644 (file)
@@ -202,6 +202,18 @@ describe('Selection strategies test suite', () => {
     expect(pool.opts.workerChoiceStrategy).toBe(
       WorkerChoiceStrategies.FAIR_SHARE
     )
+    for (const worker of pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
+      expect(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
+          worker
+        ).start
+      ).toBe(0)
+      expect(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(
+          worker
+        ).end
+      ).toBe(0)
+    }
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -335,6 +347,13 @@ describe('Selection strategies test suite', () => {
     expect(pool.opts.workerChoiceStrategy).toBe(
       WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     )
+    for (const worker of pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.keys()) {
+      expect(
+        pool.workerChoiceStrategyContext.workerChoiceStrategy.workersTaskRunTime.get(
+          worker
+        ).runTime
+      ).toBe(0)
+    }
     // We need to clean up the resources after our test
     await pool.destroy()
   })