expect(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN).toBe(
'WEIGHTED_ROUND_ROBIN'
)
+ expect(WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN).toBe(
+ 'INTERLEAVED_WEIGHTED_ROUND_ROBIN'
+ )
})
it('Verify ROUND_ROBIN strategy is the default at pool creation', async () => {
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp
+ ).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(0)
} else if (
workerChoiceStrategy === WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(pool.workerNodes.length)
// We need to clean up the resources after our test
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(pool.workerNodes.length)
// We need to clean up the resources after our test
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(pool.workerNodes.length)
// We need to clean up the resources after our test
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp
+ ).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(0)
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp[0] = 0
+ ).workersVirtualTaskEndTimestamp[0] = performance.now()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(1)
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp
+ ).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(0)
await pool.destroy()
pool = new DynamicThreadPool(
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp
+ ).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(0)
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp[0] = 0
+ ).workersVirtualTaskEndTimestamp[0] = performance.now()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(1)
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp
+ ).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
- ).workersVirtualTaskTimestamp.length
+ ).workersVirtualTaskEndTimestamp.length
).toBe(0)
// We need to clean up the resources after our test
await pool.destroy()