+ workerChoiceStrategyStub
+ )
+ const chosenWorkerKey = workerChoiceStrategyContext.execute()
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategyContext.workerChoiceStrategy
+ ).hasPoolWorkerNodesReady.callCount
+ ).toBe(6)
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategyContext.workerChoiceStrategy
+ ).choose.callCount
+ ).toBe(1)
+ expect(chosenWorkerKey).toBe(1)
+ })
+
+ it('Verify that execute() throws error if worker choice strategy recursion reach the maximum depth', () => {
+ const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
+ fixedPool
+ )
+ const workerChoiceStrategyStub = createStubInstance(
+ RoundRobinWorkerChoiceStrategy,
+ {
+ hasPoolWorkerNodesReady: stub().returns(false),
+ choose: stub().returns(0)
+ }