test: enhance worker selection strategies UTs
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 6 Apr 2023 07:58:45 +0000 (09:58 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 6 Apr 2023 07:58:45 +0000 (09:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/selection-strategies/worker-choice-strategy-context.test.js

index 7c46601f8df578d0050d6cf262004b7a5efaddae..2c0250efba1ad99544e0818b4bf018ed880c623a 100644 (file)
@@ -106,6 +106,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.ROUND_ROBIN
+      ).isDynamicPool
+    ).toBe(false)
     expect(
       workerChoiceStrategyContext.workerChoiceStrategies.get(
         WorkerChoiceStrategies.ROUND_ROBIN
@@ -131,6 +136,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       dynamicPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.ROUND_ROBIN
+      ).isDynamicPool
+    ).toBe(true)
     expect(
       workerChoiceStrategyContext.workerChoiceStrategies.get(
         WorkerChoiceStrategies.ROUND_ROBIN
@@ -156,6 +166,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.LESS_USED
+      ).isDynamicPool
+    ).toBe(false)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_USED
     )
@@ -173,6 +188,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       dynamicPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.LESS_USED
+      ).isDynamicPool
+    ).toBe(true)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_USED
     )
@@ -190,6 +210,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.LESS_BUSY
+      ).isDynamicPool
+    ).toBe(false)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_BUSY
     )
@@ -207,6 +232,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       dynamicPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.LESS_BUSY
+      ).isDynamicPool
+    ).toBe(true)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_BUSY
     )
@@ -224,6 +254,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.FAIR_SHARE
+      ).isDynamicPool
+    ).toBe(false)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.FAIR_SHARE
     )
@@ -241,6 +276,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       dynamicPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.FAIR_SHARE
+      ).isDynamicPool
+    ).toBe(true)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.FAIR_SHARE
     )
@@ -258,6 +298,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+      ).isDynamicPool
+    ).toBe(false)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     )
@@ -275,6 +320,11 @@ describe('Worker choice strategy context test suite', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       dynamicPool
     )
+    expect(
+      workerChoiceStrategyContext.workerChoiceStrategies.get(
+        WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+      ).isDynamicPool
+    ).toBe(true)
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     )