EMPTY_FUNCTION,
availableParallelism,
average,
+ buildInternalWorkerChoiceStrategyOptions,
exponentialDelay,
- getDefaultInternalWorkerChoiceStrategyOptions,
getWorkerId,
getWorkerType,
isAsyncFunction,
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', () => {
expect(EMPTY_FUNCTION).toStrictEqual(expect.any(Function))
})
- it('Verify getDefaultInternalWorkerChoiceStrategyOptions() values', () => {
- const poolMaxSize = 10
- expect(
- getDefaultInternalWorkerChoiceStrategyOptions(poolMaxSize)
- ).toStrictEqual({
- retries: poolMaxSize,
- runTime: { median: false },
- waitTime: { median: false },
- elu: { median: false }
- })
- })
-
it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => {
expect(DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS).toStrictEqual({
aggregate: false,
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