test: improve task statistic requirements coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 7 May 2024 12:29:47 +0000 (14:29 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 7 May 2024 12:29:47 +0000 (14:29 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
docs/api.md
tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs

index 1b888173d13db4519a17dd786364ca3cd6247d8b..634ab08bbf12b8b319007d3de176b46e26e47b17 100644 (file)
@@ -99,7 +99,7 @@ An object with these properties:
 
   - `WorkerChoiceStrategies.ROUND_ROBIN`: Submit tasks to worker in a round robin fashion
   - `WorkerChoiceStrategies.LEAST_USED`: Submit tasks to the worker with the minimum number of executing and queued tasks
-  - `WorkerChoiceStrategies.LEAST_BUSY`: Submit tasks to the worker with the minimum tasks total execution and wait time
+  - `WorkerChoiceStrategies.LEAST_BUSY`: Submit tasks to the worker with the minimum tasks execution time
   - `WorkerChoiceStrategies.LEAST_ELU`: Submit tasks to the worker with the minimum event loop utilization (ELU)
   - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN`: Submit tasks to worker by using a [weighted round robin scheduling algorithm](./worker-choice-strategies.md#weighted-round-robin) based on tasks execution time
   - `WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN`: Submit tasks to worker by using an [interleaved weighted round robin scheduling algorithm](./worker-choice-strategies.md#interleaved-weighted-round-robin-experimental) based on tasks execution time (experimental)
index 8fcd90b22eeb5a753a2affad79a500dec41cc98a..aeb7db1797e6bb1389181a9b9a586c05cc277c88 100644 (file)
@@ -417,7 +417,8 @@ describe('Worker choice strategies context test suite', () => {
       fixedPool,
       [wwrWorkerChoiceStrategy],
       {
-        runTime: { median: true }
+        runTime: { median: true },
+        waitTime: { median: true }
       }
     )
     expect(
@@ -428,11 +429,20 @@ describe('Worker choice strategies context test suite', () => {
       workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime
         .median
     ).toBe(true)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .average
+    ).toBe(false)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .median
+    ).toBe(true)
     workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext(
       dynamicPool,
       [wwrWorkerChoiceStrategy],
       {
-        runTime: { median: true }
+        runTime: { median: true },
+        waitTime: { median: true }
       }
     )
     expect(
@@ -443,12 +453,21 @@ describe('Worker choice strategies context test suite', () => {
       workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime
         .median
     ).toBe(true)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .average
+    ).toBe(false)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .median
+    ).toBe(true)
     const fsWorkerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
     workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext(
       fixedPool,
       [fsWorkerChoiceStrategy],
       {
-        runTime: { median: true }
+        runTime: { median: true },
+        waitTime: { median: true }
       }
     )
     expect(
@@ -459,11 +478,20 @@ describe('Worker choice strategies context test suite', () => {
       workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime
         .median
     ).toBe(true)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .average
+    ).toBe(false)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .median
+    ).toBe(true)
     workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext(
       dynamicPool,
       [fsWorkerChoiceStrategy],
       {
-        runTime: { median: true }
+        runTime: { median: true },
+        waitTime: { median: true }
       }
     )
     expect(
@@ -474,5 +502,13 @@ describe('Worker choice strategies context test suite', () => {
       workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime
         .median
     ).toBe(true)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .average
+    ).toBe(false)
+    expect(
+      workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime
+        .median
+    ).toBe(true)
   })
 })