Improve strategies internals reset tests
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 13 Oct 2022 19:09:44 +0000 (21:09 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 13 Oct 2022 19:09:44 +0000 (21:09 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/selection-strategies/selection-strategies.test.js

index d9a01684e9b5b54c85675d3eb9f7573df0b1ea0d..64b26cd54c15426a61f857fe068f7466d11c814d 100644 (file)
@@ -131,6 +131,9 @@ describe('Selection strategies test suite', () => {
       './tests/worker-files/thread/testWorker.js',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy().nextWorkerIndex
+    ).toBeUndefined()
     pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
     expect(
       pool.workerChoiceStrategyContext.getWorkerChoiceStrategy().nextWorkerIndex
@@ -142,6 +145,10 @@ describe('Selection strategies test suite', () => {
       './tests/worker-files/thread/testWorker.js',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .workerChoiceStrategy.nextWorkerIndex
+    ).toBeUndefined()
     pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
     expect(
       pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
@@ -501,6 +508,18 @@ describe('Selection strategies test suite', () => {
       max,
       './tests/worker-files/thread/testWorker.js'
     )
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .previousWorkerIndex
+    ).toBeUndefined()
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .currentWorkerIndex
+    ).toBeUndefined()
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .defaultWorkerWeight
+    ).toBeUndefined()
     expect(
       pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
         .workersTaskRunTime
@@ -533,6 +552,18 @@ describe('Selection strategies test suite', () => {
       max,
       './tests/worker-files/thread/testWorker.js'
     )
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .workerChoiceStrategy.previousWorkerIndex
+    ).toBeUndefined()
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .workerChoiceStrategy.currentWorkerIndex
+    ).toBeUndefined()
+    expect(
+      pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+        .workerChoiceStrategy.defaultWorkerWeight
+    ).toBeUndefined()
     expect(
       pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
         .workerChoiceStrategy.workersTaskRunTime