test: improve pool and worker readiness tests
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 8 Jul 2023 23:33:05 +0000 (01:33 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 8 Jul 2023 23:33:05 +0000 (01:33 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/abstract/abstract-pool.test.js

index 349521d277901ca29c82881d9d8e0bb690cb1847..05e4c34ea094023d61db4f0584c022af645e8c5e 100644 (file)
@@ -432,6 +432,24 @@ describe('Abstract pool test suite', () => {
       maxQueuedTasks: 0,
       failedTasks: 0
     })
+    await waitPoolEvents(pool, PoolEvents.ready, 1)
+    expect(pool.info).toStrictEqual({
+      version,
+      type: PoolTypes.fixed,
+      worker: WorkerTypes.thread,
+      ready: true,
+      strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+      minSize: numberOfWorkers,
+      maxSize: numberOfWorkers,
+      workerNodes: numberOfWorkers,
+      idleWorkerNodes: numberOfWorkers,
+      busyWorkerNodes: 0,
+      executedTasks: 0,
+      executingTasks: 0,
+      queuedTasks: 0,
+      maxQueuedTasks: 0,
+      failedTasks: 0
+    })
     await pool.destroy()
     pool = new DynamicClusterPool(
       Math.floor(numberOfWorkers / 2),
@@ -455,6 +473,24 @@ describe('Abstract pool test suite', () => {
       maxQueuedTasks: 0,
       failedTasks: 0
     })
+    await waitPoolEvents(pool, PoolEvents.ready, 1)
+    expect(pool.info).toStrictEqual({
+      version,
+      type: PoolTypes.dynamic,
+      worker: WorkerTypes.cluster,
+      ready: true,
+      strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+      minSize: Math.floor(numberOfWorkers / 2),
+      maxSize: numberOfWorkers,
+      workerNodes: Math.floor(numberOfWorkers / 2),
+      idleWorkerNodes: Math.floor(numberOfWorkers / 2),
+      busyWorkerNodes: 0,
+      executedTasks: 0,
+      executingTasks: 0,
+      queuedTasks: 0,
+      maxQueuedTasks: 0,
+      failedTasks: 0
+    })
     await pool.destroy()
   })
 
@@ -529,6 +565,15 @@ describe('Abstract pool test suite', () => {
         ready: false
       })
     }
+    await waitPoolEvents(pool, PoolEvents.ready, 1)
+    for (const workerNode of pool.workerNodes) {
+      expect(workerNode.info).toStrictEqual({
+        id: expect.any(Number),
+        type: WorkerTypes.cluster,
+        dynamic: false,
+        ready: true
+      })
+    }
     await pool.destroy()
     pool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
@@ -543,6 +588,15 @@ describe('Abstract pool test suite', () => {
         ready: false
       })
     }
+    await waitPoolEvents(pool, PoolEvents.ready, 1)
+    for (const workerNode of pool.workerNodes) {
+      expect(workerNode.info).toStrictEqual({
+        id: expect.any(Number),
+        type: WorkerTypes.thread,
+        dynamic: false,
+        ready: true
+      })
+    }
   })
 
   it('Verify that pool worker tasks usage are computed', async () => {