test: adapt for tasks usage wait time introduction
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 30 May 2023 10:32:41 +0000 (12:32 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 30 May 2023 10:32:41 +0000 (12:32 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.eslintrc.js
src/utils.ts
tests/pools/abstract/abstract-pool.test.js
tests/pools/selection-strategies/selection-strategies.test.js

index d7004cc55ff8460161f54f766086dd78d7612eb8..0b465dadff597167df9220f9715c1f8724b010c3 100644 (file)
@@ -38,6 +38,10 @@ module.exports = defineConfig({
       {
         skipWords: [
           'Benoit',
+          'Uint8',
+          'Uint16',
+          'Uint32',
+          'Uint64',
           'benny',
           'browserslist',
           'builtins',
index 164a2aca5eeeec3ae86b9bfcdeeb72d872c32cb7..baaf1c1ca62499106a4ce0ea41148204dda75d2b 100644 (file)
@@ -12,7 +12,8 @@ export const EMPTY_FUNCTION: () => void = Object.freeze(() => {
  */
 export const DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS: WorkerChoiceStrategyOptions =
   {
-    medRunTime: false
+    medRunTime: false,
+    medWaitTime: false
   }
 
 /**
index 02baefaf93b5639867d8bb6e852dce39c25dfa57..db45fa077620d225d4a8367ebd3d37c9d7cc9da7 100644 (file)
@@ -90,7 +90,8 @@ describe('Abstract pool test suite', () => {
       WorkerChoiceStrategies.ROUND_ROBIN
     )
     expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
-      medRunTime: false
+      medRunTime: false,
+      medWaitTime: false
     })
     expect(pool.opts.messageHandler).toBeUndefined()
     expect(pool.opts.errorHandler).toBeUndefined()
@@ -177,18 +178,26 @@ describe('Abstract pool test suite', () => {
       { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
     )
     expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
-      medRunTime: false
+      medRunTime: false,
+      medWaitTime: false
     })
     for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
       .workerChoiceStrategies) {
-      expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: false })
+      expect(workerChoiceStrategy.opts).toStrictEqual({
+        medRunTime: false,
+        medWaitTime: false
+      })
     }
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     pool.setWorkerChoiceStrategyOptions({ medRunTime: true })
     expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
       medRunTime: true
@@ -198,11 +207,15 @@ describe('Abstract pool test suite', () => {
       expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: true })
     }
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(true)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: false,
+      medRunTime: true,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     pool.setWorkerChoiceStrategyOptions({ medRunTime: false })
     expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
       medRunTime: false
@@ -212,11 +225,15 @@ describe('Abstract pool test suite', () => {
       expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: false })
     }
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
   })
 
@@ -275,15 +292,19 @@ describe('Abstract pool test suite', () => {
       './tests/worker-files/cluster/testWorker.js'
     )
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage).toBeDefined()
-      expect(workerNode.tasksUsage.run).toBe(0)
-      expect(workerNode.tasksUsage.running).toBe(0)
-      expect(workerNode.tasksUsage.runTime).toBe(0)
-      expect(workerNode.tasksUsage.runTimeHistory).toBeInstanceOf(CircularArray)
-      expect(workerNode.tasksUsage.runTimeHistory.length).toBe(0)
-      expect(workerNode.tasksUsage.avgRunTime).toBe(0)
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
-      expect(workerNode.tasksUsage.error).toBe(0)
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: 0,
+        running: 0,
+        runTime: 0,
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
     }
     await pool.destroy()
   })
@@ -311,27 +332,35 @@ describe('Abstract pool test suite', () => {
       promises.push(pool.execute())
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage).toBeDefined()
-      expect(workerNode.tasksUsage.run).toBe(0)
-      expect(workerNode.tasksUsage.running).toBe(numberOfWorkers * 2)
-      expect(workerNode.tasksUsage.runTime).toBe(0)
-      expect(workerNode.tasksUsage.runTimeHistory).toBeInstanceOf(CircularArray)
-      expect(workerNode.tasksUsage.runTimeHistory.length).toBe(0)
-      expect(workerNode.tasksUsage.avgRunTime).toBe(0)
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
-      expect(workerNode.tasksUsage.error).toBe(0)
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: 0,
+        running: numberOfWorkers * 2,
+        runTime: 0,
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
     }
     await Promise.all(promises)
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage).toBeDefined()
-      expect(workerNode.tasksUsage.run).toBe(numberOfWorkers * 2)
-      expect(workerNode.tasksUsage.running).toBe(0)
-      expect(workerNode.tasksUsage.runTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.runTimeHistory).toBeInstanceOf(CircularArray)
-      expect(workerNode.tasksUsage.runTimeHistory.length).toBe(0)
-      expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
-      expect(workerNode.tasksUsage.error).toBe(0)
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: numberOfWorkers * 2,
+        running: 0,
+        runTime: 0,
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
     }
     await pool.destroy()
   })
@@ -348,27 +377,39 @@ describe('Abstract pool test suite', () => {
     }
     await Promise.all(promises)
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage).toBeDefined()
-      expect(workerNode.tasksUsage.run).toBe(numberOfWorkers * 2)
-      expect(workerNode.tasksUsage.running).toBe(0)
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: numberOfWorkers * 2,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.runTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.runTimeHistory).toBeInstanceOf(CircularArray)
-      expect(workerNode.tasksUsage.runTimeHistory.length).toBe(0)
       expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
-      expect(workerNode.tasksUsage.error).toBe(0)
     }
     pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
     for (const workerNode of pool.workerNodes) {
       expect(workerNode.tasksUsage).toBeDefined()
-      expect(workerNode.tasksUsage.run).toBe(0)
-      expect(workerNode.tasksUsage.running).toBe(0)
-      expect(workerNode.tasksUsage.runTime).toBe(0)
-      expect(workerNode.tasksUsage.runTimeHistory).toBeInstanceOf(CircularArray)
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: 0,
+        running: 0,
+        runTime: 0,
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.runTimeHistory.length).toBe(0)
-      expect(workerNode.tasksUsage.avgRunTime).toBe(0)
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
-      expect(workerNode.tasksUsage.error).toBe(0)
     }
     await pool.destroy()
   })
index 9e3e99e3ba3f1291ea4ebe1893588c084ed064f7..8ab971589a7f6af2d34c45e3d1aabf9d84361a42 100644 (file)
@@ -5,6 +5,7 @@ const {
   FixedThreadPool,
   FixedClusterPool
 } = require('../../../lib')
+const { CircularArray } = require('../../../lib/circular-array')
 
 describe('Selection strategies test suite', () => {
   const min = 0
@@ -118,14 +119,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: false,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -134,14 +136,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: false,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -251,14 +254,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: false,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -267,14 +271,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: false,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -318,14 +323,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -334,14 +340,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(false)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: false,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -385,14 +392,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -401,14 +409,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -425,10 +434,20 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: expect.any(Number),
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
     }
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -452,10 +471,20 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: max * maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: expect.any(Number),
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
     }
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -484,9 +513,19 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.avgRunTime).toBe(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: max * maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: expect.any(Number),
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.medRunTime).toBeGreaterThanOrEqual(0)
     }
     expect(
@@ -580,14 +619,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     await pool.destroy()
     pool = new DynamicThreadPool(
       min,
@@ -596,14 +636,15 @@ describe('Selection strategies test suite', () => {
       { workerChoiceStrategy }
     )
     expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime
-    ).toBe(true)
-    expect(
-      pool.workerChoiceStrategyContext.getRequiredStatistics().medRunTime
-    ).toBe(false)
+      pool.workerChoiceStrategyContext.getRequiredStatistics()
+    ).toStrictEqual({
+      runTime: true,
+      avgRunTime: true,
+      medRunTime: false,
+      waitTime: false,
+      avgWaitTime: false,
+      medWaitTime: false
+    })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
@@ -620,10 +661,20 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: max * maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: expect.any(Number),
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
     }
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -652,10 +703,20 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: max * maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: expect.any(Number),
+        medRunTime: 0,
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.medRunTime).toBe(0)
     }
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -689,9 +750,19 @@ describe('Selection strategies test suite', () => {
       await pool.execute()
     }
     for (const workerNode of pool.workerNodes) {
-      expect(workerNode.tasksUsage.avgRunTime).toBeDefined()
-      expect(workerNode.tasksUsage.avgRunTime).toBe(0)
-      expect(workerNode.tasksUsage.medRunTime).toBeDefined()
+      expect(workerNode.tasksUsage).toStrictEqual({
+        run: max * maxMultiplier,
+        running: 0,
+        runTime: expect.any(Number),
+        runTimeHistory: expect.any(CircularArray),
+        avgRunTime: 0,
+        medRunTime: expect.any(Number),
+        waitTime: 0,
+        waitTimeHistory: expect.any(CircularArray),
+        avgWaitTime: 0,
+        medWaitTime: 0,
+        error: 0
+      })
       expect(workerNode.tasksUsage.medRunTime).toBeGreaterThanOrEqual(0)
     }
     expect(