X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.mjs;h=39a2ccc3f7ce0cd84ad995165a85a9227341c688;hb=d4efe3b82d415e455c8e6c300f2a6845ff3edc80;hp=33fad179148ded73e33a9b683a97d734e1111751;hpb=bcc9e518ccacb739018c92de22011fa4e8d47ece;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.mjs b/tests/pools/selection-strategies/selection-strategies.test.mjs index 33fad179..39a2ccc3 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 @@ -85,7 +85,7 @@ describe('Selection strategies test suite', () => { 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) @@ -157,6 +157,13 @@ describe('Selection strategies test suite', () => { workerChoiceStrategy ).roundWeights.length ).toBe(1) + expect( + Number.isSafeInteger( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + workerChoiceStrategy + ).roundWeights[0] + ) + ).toBe(true) } } await pool.destroy() @@ -382,7 +389,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() @@ -1636,7 +1643,7 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).previousWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy @@ -1705,12 +1712,12 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).nextWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).previousWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy @@ -1784,12 +1791,12 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).nextWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).previousWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy @@ -2027,12 +2034,19 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).previousWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).roundWeights.length ).toBe(1) + expect( + Number.isSafeInteger( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).roundWeights[0] + ) + ).toBe(true) // We need to clean up the resources after our test await pool.destroy() }) @@ -2104,12 +2118,19 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).previousWorkerNodeKey - ).toEqual(expect.any(Number)) + ).toEqual(0) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).roundWeights.length ).toBe(1) + expect( + Number.isSafeInteger( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).roundWeights[0] + ) + ).toBe(true) // We need to clean up the resources after our test await pool.destroy() }) @@ -2172,6 +2193,13 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategy ).roundWeights.length ).toBe(1) + expect( + Number.isSafeInteger( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).roundWeights[0] + ) + ).toBe(true) await pool.destroy() pool = new DynamicThreadPool( min, @@ -2229,6 +2257,13 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategy ).roundWeights.length ).toBe(1) + expect( + Number.isSafeInteger( + pool.workerChoiceStrategyContext.workerChoiceStrategies.get( + pool.workerChoiceStrategyContext.workerChoiceStrategy + ).roundWeights[0] + ) + ).toBe(true) // We need to clean up the resources after our test await pool.destroy() })