X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.mjs;h=127377a26118c5d5be57cf98661eb9139fe5d81f;hb=722d55a0b7bdb6b03cc523e5debef6b612c332f8;hp=b7597b4c0c71d0f326fb866dbebb1d277474667f;hpb=5ad42e34cbc0302669952757c1ae1c2f284a96a4;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.mjs b/tests/pools/selection-strategies/selection-strategies.test.mjs index b7597b4c..127377a2 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.mjs +++ b/tests/pools/selection-strategies/selection-strategies.test.mjs @@ -7,6 +7,7 @@ import { WorkerChoiceStrategies } from '../../../lib/index.js' import { CircularArray } from '../../../lib/circular-array.js' +import { sleep } from '../../test-utils.js' describe('Selection strategies test suite', () => { const min = 0 @@ -174,6 +175,26 @@ describe('Selection strategies test suite', () => { await pool.destroy() }) + it('Verify strategies wait for worker node readiness in dynamic pool', async () => { + const pool = new DynamicThreadPool( + min, + max, + './tests/worker-files/thread/testWorker.mjs' + ) + await sleep(600) + expect(pool.starting).toBe(false) + expect(pool.workerNodes.length).toBe(min) + const maxMultiplier = 10000 + const promises = new Set() + for (let i = 0; i < max * maxMultiplier; i++) { + promises.add(pool.execute()) + } + await Promise.all(promises) + expect(pool.workerNodes.length).toBe(max) + // We need to clean up the resources after our test + await pool.destroy() + }) + it('Verify ROUND_ROBIN strategy default policy', async () => { const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN let pool = new FixedThreadPool(