X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fcluster%2Fdynamic.test.js;h=b45b7ccac91308fcb1fe5193f0ffa3ea8d882b60;hb=4c35177b63cac8a87aa6de389e1232e94c59b8c9;hp=cd946cdab294877980f8322cea21aca5461541ae;hpb=8780c880a2cf08680092f6e41fb82600b196455c;p=poolifier.git diff --git a/tests/pools/cluster/dynamic.test.js b/tests/pools/cluster/dynamic.test.js index cd946cda..b45b7cca 100644 --- a/tests/pools/cluster/dynamic.test.js +++ b/tests/pools/cluster/dynamic.test.js @@ -87,11 +87,27 @@ describe('Dynamic cluster pool test suite ', () => { expect(res).toBeFalsy() }) - it('Verify scale processes up and down is working when long running task is used', async () => { + it('Verify scale processes up and down is working when long running task is used:hard', async () => { const longRunningPool = new DynamicClusterPool( min, max, - './tests/worker/cluster/longRunningWorker.js' + './tests/worker/cluster/longRunningWorkerHardBehavior.js' + ) + expect(longRunningPool.workers.length).toBe(min) + for (let i = 0; i < max * 10; i++) { + longRunningPool.execute({ test: 'test' }) + } + expect(longRunningPool.workers.length).toBe(max) + await new Promise(resolve => setTimeout(resolve, 3000)) + // Here we expect the workers to be at the max size since that the task is still running + expect(longRunningPool.workers.length).toBe(min) + }) + + it('Verify scale processes up and down is working when long running task is used:soft', async () => { + const longRunningPool = new DynamicClusterPool( + min, + max, + './tests/worker/cluster/longRunningWorkerSoftBehavior.js' ) expect(longRunningPool.workers.length).toBe(min) for (let i = 0; i < max * 10; i++) {