X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.mjs;h=e17191557a96edb785748c1fb744bf55f81a15a3;hb=7b7d96315331635fa3c8a12b03b6893fe91bf8ec;hp=0feb5387ca7dcf162541023b3f0db56c472e4239;hpb=146eaa19f0f0ad8b0aecfef0ad3d8552dd064f33;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.mjs b/tests/pools/selection-strategies/selection-strategies.test.mjs index 0feb5387..e1719155 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.mjs +++ b/tests/pools/selection-strategies/selection-strategies.test.mjs @@ -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() @@ -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 @@ -1961,7 +1968,7 @@ describe('Selection strategies test suite', () => { await pool.destroy() }) - it.skip('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => { + it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => { const pool = new FixedThreadPool( max, './tests/worker-files/thread/testWorker.mjs', @@ -2027,17 +2034,24 @@ 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() }) - it.skip('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => { + it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => { const pool = new DynamicThreadPool( min, max, @@ -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() })