test: add test to reproduce issue #1748
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 5 Jan 2024 15:44:58 +0000 (16:44 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 5 Jan 2024 15:44:58 +0000 (16:44 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/cluster/dynamic.test.mjs
tests/pools/thread/dynamic.test.mjs

index 870a5f4df9aa0f3bc997b4463f67746d3e7d8c42..cc8f2c0c5a866f675ecde96eb8d8d80ea02ec76d 100644 (file)
@@ -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()
   })
index 9d35ce8aa8088b58809b4c54d67ec2712e06d974..7b951aaf38576f9ffb3f05fb50ee60ace4882a28 100644 (file)
@@ -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()
   })