})
it('Verify ROUND_ROBIN strategy can be run in a fixed pool', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
+ { workerChoiceStrategy }
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
).toBe(pool.workerNodes.length - 1)
// We need to clean up the resources after our test
})
it('Verify ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
const pool = new DynamicThreadPool(
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
+ { workerChoiceStrategy }
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
).toBe(pool.workerNodes.length - 1)
// We need to clean up the resources after our test
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
}
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).nextWorkerNodeKey
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
}
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).nextWorkerNodeKey
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
expect(workerNode.usage.runTime.median).toBeGreaterThan(0)
}
}
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).nextWorkerNodeKey
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy