X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fselection-strategies%2Fselection-strategies.test.js;h=535f5f974559ab7748ac885c476f064084e148e6;hb=3f7d99f5a6b9783554886f1850aa45c5bc237b65;hp=6671b57781b1f51c15bdf0717f3c96cafcf0ca76;hpb=3d6dd312a7825521cce506ebb7443bae36a111e6;p=poolifier.git diff --git a/tests/pools/selection-strategies/selection-strategies.test.js b/tests/pools/selection-strategies/selection-strategies.test.js index 6671b577..535f5f97 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.js +++ b/tests/pools/selection-strategies/selection-strategies.test.js @@ -3,9 +3,11 @@ const { DynamicThreadPool, FixedClusterPool, FixedThreadPool, + PoolEvents, WorkerChoiceStrategies } = require('../../../lib') const { CircularArray } = require('../../../lib/circular-array') +const { waitPoolEvents } = require('../../test-utils') describe('Selection strategies test suite', () => { const min = 0 @@ -1715,6 +1717,9 @@ describe('Selection strategies test suite', () => { WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN } ) + if (!pool.info.ready) { + await waitPoolEvents(pool, PoolEvents.ready, 1) + } // TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose` const promises = new Set() const maxMultiplier = 2 @@ -1785,6 +1790,9 @@ describe('Selection strategies test suite', () => { WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN } ) + if (!pool.info.ready) { + await waitPoolEvents(pool, PoolEvents.ready, 1) + } // TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose` const promises = new Set() const maxMultiplier = 2 @@ -1795,7 +1803,7 @@ describe('Selection strategies test suite', () => { for (const workerNode of pool.workerNodes) { expect(workerNode.usage).toStrictEqual({ tasks: { - executed: maxMultiplier, + executed: expect.any(Number), executing: 0, queued: 0, maxQueued: 0, @@ -1831,7 +1839,7 @@ describe('Selection strategies test suite', () => { pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy ).nextWorkerNodeKey - ).toBe(0) + ).toBe(1) expect( pool.workerChoiceStrategyContext.workerChoiceStrategies.get( pool.workerChoiceStrategyContext.workerChoiceStrategy