X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Futils.test.mjs;h=3842c8c5e223e3e89fdea92e581b0d7f8e41fb52;hb=2eee72204bc851f616ded11cb5381f96c6dc5cbf;hp=c6cc06d31487f2b492850203fb64ceda79d2ae87;hpb=ded253e27e59ae936fe91d789d8454b7eb11dd6a;p=poolifier.git diff --git a/tests/pools/utils.test.mjs b/tests/pools/utils.test.mjs index c6cc06d3..3842c8c5 100644 --- a/tests/pools/utils.test.mjs +++ b/tests/pools/utils.test.mjs @@ -7,17 +7,11 @@ import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../../lib/circular-array.cjs' +import { WorkerTypes } from '../../lib/index.cjs' import { - FixedClusterPool, - FixedThreadPool, - WorkerTypes -} from '../../lib/index.cjs' -import { - buildWorkerChoiceStrategyOptions, createWorker, DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, getDefaultTasksQueueOptions, - getWorkerChoiceStrategyRetries, getWorkerId, getWorkerType, updateMeasurementStatistics @@ -38,66 +32,11 @@ describe('Pool utils test suite', () => { concurrency: 1, size: Math.pow(poolMaxSize, 2), taskStealing: true, - tasksStealingOnBackPressure: true, + tasksStealingOnBackPressure: false, tasksFinishedTimeout: 2000 }) }) - it('Verify getWorkerChoiceStrategyRetries() behavior', async () => { - const numberOfThreads = 4 - const pool = new FixedThreadPool( - numberOfThreads, - './tests/worker-files/thread/testWorker.mjs' - ) - expect(getWorkerChoiceStrategyRetries(pool)).toBe(pool.info.maxSize * 2) - const workerChoiceStrategyOptions = { - runTime: { median: true }, - waitTime: { median: true }, - elu: { median: true }, - weights: { - 0: 100, - 1: 100 - } - } - expect( - getWorkerChoiceStrategyRetries(pool, workerChoiceStrategyOptions) - ).toBe( - pool.info.maxSize + - Object.keys(workerChoiceStrategyOptions.weights).length - ) - await pool.destroy() - }) - - it('Verify buildWorkerChoiceStrategyOptions() behavior', async () => { - const numberOfWorkers = 4 - const pool = new FixedClusterPool( - numberOfWorkers, - './tests/worker-files/cluster/testWorker.cjs' - ) - expect(buildWorkerChoiceStrategyOptions(pool)).toStrictEqual({ - runTime: { median: false }, - waitTime: { median: false }, - elu: { median: false }, - weights: expect.objectContaining({ - 0: expect.any(Number), - [pool.info.maxSize - 1]: expect.any(Number) - }) - }) - const workerChoiceStrategyOptions = { - runTime: { median: true }, - waitTime: { median: true }, - elu: { median: true }, - weights: { - 0: 100, - 1: 100 - } - } - expect( - buildWorkerChoiceStrategyOptions(pool, workerChoiceStrategyOptions) - ).toStrictEqual(workerChoiceStrategyOptions) - await pool.destroy() - }) - it('Verify updateMeasurementStatistics() behavior', () => { const measurementStatistics = { history: new CircularArray()