- it('Verify that execute() return the worker node key chosen by the strategy with fixed pool', () => {
- const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
- fixedPool
- )
- const workerChoiceStrategyStub = createStubInstance(
- RoundRobinWorkerChoiceStrategy,
- {
- hasPoolWorkerNodesReady: stub().returns(true),
- choose: stub().returns(0)
- }
- )
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- workerChoiceStrategyContext.workerChoiceStrategies.set(
- workerChoiceStrategyContext.workerChoiceStrategy,
- workerChoiceStrategyStub
- )
- const chosenWorkerKey = workerChoiceStrategyContext.execute()
- expect(
- workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategyContext.workerChoiceStrategy
- ).choose.calledOnce
- ).toBe(true)
- expect(chosenWorkerKey).toBe(0)
- })
-