From: Jérôme Benoit Date: Fri, 25 Aug 2023 15:03:32 +0000 (+0200) Subject: test: add task stealing support X-Git-Tag: v2.6.35~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=56d1167079ce8b4a043a8d750389f0d00ecccbad;p=poolifier.git test: add task stealing support Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/cluster/fixed.test.js b/tests/pools/cluster/fixed.test.js index 900f0edc..85eb6a0a 100644 --- a/tests/pools/cluster/fixed.test.js +++ b/tests/pools/cluster/fixed.test.js @@ -4,7 +4,7 @@ const { TaskFunctions } = require('../../test-types') const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils') describe('Fixed cluster pool test suite', () => { - const numberOfWorkers = 6 + const numberOfWorkers = 8 const tasksConcurrency = 2 const pool = new FixedClusterPool( numberOfWorkers, @@ -124,7 +124,9 @@ describe('Fixed cluster pool test suite', () => { expect(workerNode.usage.tasks.maxQueued).toBe( maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency ) + expect(workerNode.usage.tasks.stolen).toBe(0) } + expect(queuePool.info.executedTasks).toBe(0) expect(queuePool.info.executingTasks).toBe( numberOfWorkers * queuePool.opts.tasksQueueOptions.concurrency ) @@ -137,6 +139,7 @@ describe('Fixed cluster pool test suite', () => { (maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency) ) expect(queuePool.info.backPressure).toBe(false) + expect(queuePool.info.stolenTasks).toBe(0) await Promise.all(promises) for (const workerNode of queuePool.workerNodes) { expect(workerNode.usage.tasks.executing).toBeGreaterThanOrEqual(0) @@ -148,7 +151,17 @@ describe('Fixed cluster pool test suite', () => { expect(workerNode.usage.tasks.maxQueued).toBe( maxMultiplier - queuePool.opts.tasksQueueOptions.concurrency ) + expect(workerNode.usage.tasks.stolen).toBeGreaterThanOrEqual(0) + expect(workerNode.usage.tasks.stolen).toBeLessThanOrEqual( + numberOfWorkers * maxMultiplier + ) } + expect(queuePool.info.executedTasks).toBe(numberOfWorkers * maxMultiplier) + expect(queuePool.info.backPressure).toBe(false) + expect(queuePool.info.stolenTasks).toBeGreaterThanOrEqual(0) + expect(queuePool.info.stolenTasks).toBeLessThanOrEqual( + numberOfWorkers * maxMultiplier + ) }) it('Verify that is possible to have a worker that return undefined', async () => {