From 2dca6cabeaaf9c19cca7574deff10ef7af183a92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 9 Jul 2023 01:33:05 +0200 Subject: [PATCH] test: improve pool and worker readiness tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/pools/abstract/abstract-pool.test.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) 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 () => { -- 2.34.1