const {
LeastBusyWorkerChoiceStrategy
} = require('../../../lib/pools/selection-strategies/least-busy-worker-choice-strategy')
+const {
+ LeastEluWorkerChoiceStrategy
+} = require('../../../lib/pools/selection-strategies/least-elu-worker-choice-strategy')
const {
FairShareWorkerChoiceStrategy
} = require('../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy')
expect(chosenWorkerKey).toBe(0)
})
- it('Verify that execute() throws error if null or undefined is returned', () => {
+ it('Verify that execute() throws error if null or undefined is returned after retries', () => {
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
WorkerChoiceStrategyUndefinedStub
)
expect(() => workerChoiceStrategyContext.execute()).toThrowError(
- new Error('Worker node key chosen is null or undefined')
+ new Error('Worker node key chosen is null or undefined after 6 retries')
)
workerChoiceStrategyContext.workerChoiceStrategies.set(
workerChoiceStrategyContext.workerChoiceStrategy,
WorkerChoiceStrategyNullStub
)
expect(() => workerChoiceStrategyContext.execute()).toThrowError(
- new Error('Worker node key chosen is null or undefined')
+ new Error('Worker node key chosen is null or undefined after 6 retries')
)
})
)
})
+ it('Verify that setWorkerChoiceStrategy() works with LEAST_ELU and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
+ const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
+ fixedPool
+ )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ )
+ ).toBeInstanceOf(LeastEluWorkerChoiceStrategy)
+ expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ })
+
+ it('Verify that setWorkerChoiceStrategy() works with LEAST_ELU and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
+ const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
+ dynamicPool
+ )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ )
+ ).toBeInstanceOf(LeastEluWorkerChoiceStrategy)
+ expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ })
+
it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and fixed pool', () => {
const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(