X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.mjs;h=bca3c82b1647e22146b6094321d7c9ac60485403;hb=3bcbd4c5be5678988281342a1fc1f6a62f9c77d7;hp=e17191557a96edb785748c1fb744bf55f81a15a3;hpb=11cc661fdc70e6afb4bd8bc36755ba2014bbf6f6;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.mjs b/tests/pools/selection-strategies/selection-strategies.test.mjs index e1719155..bca3c82b 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.mjs +++ b/tests/pools/selection-strategies/selection-strategies.test.mjs @@ -5,8 +5,8 @@ import { FixedClusterPool, FixedThreadPool, WorkerChoiceStrategies -} from '../../../lib/index.js' -import { CircularArray } from '../../../lib/circular-array.js' +} from '../../../lib/index.cjs' +import { CircularArray } from '../../../lib/circular-array.cjs' describe('Selection strategies test suite', () => { const min = 0 @@ -66,45 +66,19 @@ describe('Selection strategies test suite', () => { expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe( workerChoiceStrategy ) - expect(pool.opts.workerChoiceStrategyOptions).toBeUndefined() - expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({ - retries: - pool.info.maxSize + - Object.keys(pool.workerChoiceStrategyContext.opts.weights).length, - runTime: { median: false }, - waitTime: { median: false }, - elu: { median: false }, - weights: expect.objectContaining({ - 0: expect.any(Number), - [pool.info.maxSize - 1]: expect.any(Number) - }) - }) await pool.destroy() } for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) { const pool = new DynamicClusterPool( min, max, - './tests/worker-files/cluster/testWorker.js' + './tests/worker-files/cluster/testWorker.cjs' ) pool.setWorkerChoiceStrategy(workerChoiceStrategy) expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy) expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe( workerChoiceStrategy ) - expect(pool.opts.workerChoiceStrategyOptions).toBeUndefined() - expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({ - retries: - pool.info.maxSize + - Object.keys(pool.workerChoiceStrategyContext.opts.weights).length, - runTime: { median: false }, - waitTime: { median: false }, - elu: { median: false }, - weights: expect.objectContaining({ - 0: expect.any(Number), - [pool.info.maxSize - 1]: expect.any(Number) - }) - }) await pool.destroy() } }) @@ -169,25 +143,6 @@ 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' - ) - 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( @@ -389,7 +344,7 @@ describe('Selection strategies test suite', () => { const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN let pool = new FixedClusterPool( max, - './tests/worker-files/cluster/testWorker.js', + './tests/worker-files/cluster/testWorker.cjs', { workerChoiceStrategy } ) let results = new Set()