From: Jérôme Benoit Date: Sat, 8 Jul 2023 23:33:05 +0000 (+0200) Subject: test: improve pool and worker readiness tests X-Git-Tag: v2.6.12~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2dca6cabeaaf9c19cca7574deff10ef7af183a92;p=poolifier.git test: improve pool and worker readiness tests Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 349521d2..05e4c34e 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -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 () => {