RoundRobinWorkerChoiceStrategy
} = require('../../../lib/pools/selection-strategies/round-robin-worker-choice-strategy')
const {
- LessRecentlyUsedWorkerChoiceStrategy
-} = require('../../../lib/pools/selection-strategies/less-recently-used-worker-choice-strategy')
+ LessUsedWorkerChoiceStrategy
+} = require('../../../lib/pools/selection-strategies/less-used-worker-choice-strategy')
const {
FairShareWorkerChoiceStrategy
} = require('../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy')
}
)
workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
- const worker = workerChoiceStrategyContext.execute()
+ const chosenWorker = workerChoiceStrategyContext.execute()
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.choose.calledOnce
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().choose.calledOnce
).toBe(true)
- expect(worker).toBe('worker')
+ expect(chosenWorker).toBe('worker')
})
it('Verify that execute() return the worker chosen by the strategy with dynamic pool', () => {
}
)
workerChoiceStrategyContext.workerChoiceStrategy = WorkerChoiceStrategyStub
- const worker = workerChoiceStrategyContext.execute()
+ const chosenWorker = workerChoiceStrategyContext.execute()
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.choose.calledOnce
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().choose.calledOnce
).toBe(true)
- expect(worker).toBe('worker')
+ expect(chosenWorker).toBe('worker')
})
it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and fixed pool', () => {
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- RoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
})
it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and dynamic pool', () => {
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- DynamicPoolWorkerChoiceStrategy
- )
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
})
- it('Verify that setWorkerChoiceStrategy() works with LESS_RECENTLY_USED and fixed pool', () => {
+ it('Verify that setWorkerChoiceStrategy() works with LESS_USED and fixed pool', () => {
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_RECENTLY_USED
- )
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- LessRecentlyUsedWorkerChoiceStrategy
+ WorkerChoiceStrategies.LESS_USED
)
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
})
- it('Verify that setWorkerChoiceStrategy() works with LESS_RECENTLY_USED and dynamic pool', () => {
+ it('Verify that setWorkerChoiceStrategy() works with LESS_USED and dynamic pool', () => {
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_RECENTLY_USED
- )
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- DynamicPoolWorkerChoiceStrategy
+ WorkerChoiceStrategies.LESS_USED
)
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
- ).toBeInstanceOf(LessRecentlyUsedWorkerChoiceStrategy)
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
+ ).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
})
it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and fixed pool', () => {
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.FAIR_SHARE
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- FairShareWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(FairShareWorkerChoiceStrategy)
})
it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and dynamic pool', () => {
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.FAIR_SHARE
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- DynamicPoolWorkerChoiceStrategy
- )
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
).toBeInstanceOf(FairShareWorkerChoiceStrategy)
})
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- WeightedRoundRobinWorkerChoiceStrategy
- )
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
})
it('Verify that setWorkerChoiceStrategy() works with WEIGHTED_ROUND_ROBIN and dynamic pool', () => {
workerChoiceStrategyContext.setWorkerChoiceStrategy(
WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
)
- expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
- DynamicPoolWorkerChoiceStrategy
- )
expect(
- workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+ workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+ expect(
+ workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
})
})