+ it('Verify ROUND_ROBIN strategy internals are resets after setting it', async () => {
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
+ )
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy().nextWorkerIndex
+ ).toBeUndefined()
+ pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy().nextWorkerIndex
+ ).toBe(0)
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
+ )
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ .workerChoiceStrategy.nextWorkerIndex
+ ).toBeUndefined()
+ pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ .workerChoiceStrategy.nextWorkerIndex
+ ).toBe(0)
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+