From: Jérôme Benoit Date: Fri, 5 Jan 2024 15:44:58 +0000 (+0100) Subject: test: add test to reproduce issue #1748 X-Git-Tag: v3.1.18~3^2~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;ds=sidebyside;h=a2283a198407d558dd7fdca4bad77a032623fdef;hp=a4bc8d0e51cf7f72567c4def19e5f791f148fdca;p=poolifier.git test: add test to reproduce issue #1748 Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/cluster/dynamic.test.mjs b/tests/pools/cluster/dynamic.test.mjs index 870a5f4d..cc8f2c0c 100644 --- a/tests/pools/cluster/dynamic.test.mjs +++ b/tests/pools/cluster/dynamic.test.mjs @@ -168,6 +168,17 @@ describe('Dynamic cluster pool test suite', () => { } await Promise.all(promises) expect(pool.workerNodes.length).toBe(max) + await waitWorkerEvents(pool, 'exit', max) + expect(pool.workerNodes.length).toBe(pool.info.minSize) + // pool.enableTasksQueue(true, { concurrency: 2 }) + promises.clear() + for (let i = 0; i < max * maxMultiplier; i++) { + promises.add(pool.execute()) + } + await Promise.all(promises) + expect(pool.workerNodes.length).toBe(max) + await waitWorkerEvents(pool, 'exit', max) + expect(pool.workerNodes.length).toBe(pool.info.minSize) // We need to clean up the resources after our test await pool.destroy() }) diff --git a/tests/pools/thread/dynamic.test.mjs b/tests/pools/thread/dynamic.test.mjs index 9d35ce8a..7b951aaf 100644 --- a/tests/pools/thread/dynamic.test.mjs +++ b/tests/pools/thread/dynamic.test.mjs @@ -168,6 +168,17 @@ describe('Dynamic thread pool test suite', () => { } await Promise.all(promises) expect(pool.workerNodes.length).toBe(max) + await waitWorkerEvents(pool, 'exit', max) + expect(pool.workerNodes.length).toBe(pool.info.minSize) + // pool.enableTasksQueue(true, { concurrency: 2 }) + promises.clear() + for (let i = 0; i < max * maxMultiplier; i++) { + promises.add(pool.execute()) + } + await Promise.all(promises) + expect(pool.workerNodes.length).toBe(max) + await waitWorkerEvents(pool, 'exit', max) + expect(pool.workerNodes.length).toBe(pool.info.minSize) // We need to clean up the resources after our test await pool.destroy() })