X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Futils.test.mjs;h=2d1ee9e6f3c70d70bf103793fea14d0dbadb80d2;hb=8b81cdcfe1ff18b5cded9883600455cb4c54d698;hp=26056bd2c7a6a4133b6e678a96826190ba174b05;hpb=b91134ce1c0d673b62091e945a1271d08749af55;p=poolifier.git diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index 26056bd2..2d1ee9e6 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -6,10 +6,10 @@ import { expect } from 'expect' import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, DEFAULT_TASK_NAME, - DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS, EMPTY_FUNCTION, availableParallelism, average, + buildInternalWorkerChoiceStrategyOptions, exponentialDelay, getWorkerId, getWorkerType, @@ -23,8 +23,8 @@ import { round, secureRandom, sleep -} from '../lib/utils.js' -import { KillBehaviors, WorkerTypes } from '../lib/index.js' +} from '../lib/utils.cjs' +import { KillBehaviors, WorkerTypes } from '../lib/index.cjs' describe('Utils test suite', () => { it('Verify DEFAULT_TASK_NAME value', () => { @@ -35,15 +35,6 @@ describe('Utils test suite', () => { expect(EMPTY_FUNCTION).toStrictEqual(expect.any(Function)) }) - it('Verify DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS values', () => { - expect(DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS).toStrictEqual({ - retries: 6, - runTime: { median: false }, - waitTime: { median: false }, - elu: { median: false } - }) - }) - it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => { expect(DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS).toStrictEqual({ aggregate: false, @@ -240,6 +231,24 @@ describe('Utils test suite', () => { expect(max(1, 1)).toBe(1) }) + it('Verify buildInternalWorkerChoiceStrategyOptions() behavior', () => { + const poolMaxSize = 10 + const internalWorkerChoiceStrategyOptions = + buildInternalWorkerChoiceStrategyOptions(poolMaxSize) + expect(internalWorkerChoiceStrategyOptions).toStrictEqual({ + retries: + poolMaxSize + + Object.keys(internalWorkerChoiceStrategyOptions.weights).length, + runTime: { median: false }, + waitTime: { median: false }, + elu: { median: false }, + weights: expect.objectContaining({ + 0: expect.any(Number), + [poolMaxSize - 1]: expect.any(Number) + }) + }) + }) + // it('Verify once()', () => { // let called = 0 // const fn = () => ++called