X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Fcluster%2Ffixed.test.js;h=a5790db075f400b3ff4ff93dd6c0a01a3beb62fd;hb=a25c335d7e5573a171fc96c445cb6092852b2c4a;hp=e563b0ba520c67f2f11b44221e61b88b098c6496;hpb=5bb5be17a795c3061bdb0a7748b42b2ba2060db3;p=poolifier.git diff --git a/tests/pools/cluster/fixed.test.js b/tests/pools/cluster/fixed.test.js index e563b0ba..a5790db0 100644 --- a/tests/pools/cluster/fixed.test.js +++ b/tests/pools/cluster/fixed.test.js @@ -92,12 +92,14 @@ describe('Fixed cluster pool test suite', () => { expect(poolReady).toBe(1) }) - it("Verify that 'busy' event is emitted", () => { + it("Verify that 'busy' event is emitted", async () => { + const promises = new Set() let poolBusy = 0 pool.emitter.on(PoolEvents.busy, () => ++poolBusy) for (let i = 0; i < numberOfWorkers * 2; i++) { - pool.execute() + promises.add(pool.execute()) } + await Promise.all(promises) // The `busy` event is triggered when the number of submitted tasks at once reach the number of fixed pool workers. // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the fixed pool. expect(poolBusy).toBe(numberOfWorkers + 1) @@ -134,6 +136,7 @@ describe('Fixed cluster pool test suite', () => { numberOfWorkers * (maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency) ) + expect(queuePool.info.backPressure).toBe(false) await Promise.all(promises) for (const workerNode of queuePool.workerNodes) { expect(workerNode.usage.tasks.executing).toBe(0)