test: refine pool event tests expectation
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 29 Aug 2024 17:12:32 +0000 (19:12 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 29 Aug 2024 17:12:32 +0000 (19:12 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/abstract-pool.test.mjs

index 2e6ba76ba4a94eecd053a25aa8597ede9d0cf810..63162e3ae5fa8b3c5910f2b1e76ab57f4fdaa1fd 100644 (file)
@@ -1178,12 +1178,12 @@ describe('Abstract pool test suite', () => {
     await Promise.all(promises)
     expect(poolBusy).toBe(1)
     expect(poolBusyInfo).toStrictEqual({
-      busyWorkerNodes: expect.any(Number),
+      busyWorkerNodes: numberOfWorkers,
       defaultStrategy: WorkerChoiceStrategies.ROUND_ROBIN,
       executedTasks: expect.any(Number),
       executingTasks: expect.any(Number),
       failedTasks: expect.any(Number),
-      idleWorkerNodes: expect.any(Number),
+      idleWorkerNodes: 0,
       maxSize: numberOfWorkers,
       minSize: numberOfWorkers,
       ready: true,
@@ -1212,6 +1212,7 @@ describe('Abstract pool test suite', () => {
       worker: WorkerTypes.thread,
       workerNodes: numberOfWorkers,
     })
+    expect(poolBusyEndInfo.busyWorkerNodes).toBeLessThan(numberOfWorkers)
     await pool.destroy()
   })
 
@@ -1316,7 +1317,7 @@ describe('Abstract pool test suite', () => {
     expect(poolBackPressure).toBe(1)
     expect(poolBackPressureInfo).toStrictEqual({
       backPressure: true,
-      backPressureWorkerNodes: expect.any(Number),
+      backPressureWorkerNodes: numberOfWorkers,
       busyWorkerNodes: expect.any(Number),
       defaultStrategy: WorkerChoiceStrategies.ROUND_ROBIN,
       executedTasks: expect.any(Number),
@@ -1361,6 +1362,9 @@ describe('Abstract pool test suite', () => {
       worker: WorkerTypes.thread,
       workerNodes: numberOfWorkers,
     })
+    expect(poolBackPressureEndInfo.backPressureWorkerNodes).toBeLessThan(
+      numberOfWorkers
+    )
     await pool.destroy()
   })