summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
086fd84)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
})
it('Verify ROUND_ROBIN strategy can be run in a fixed pool', async () => {
})
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',
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()
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
).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
).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 () => {
})
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',
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()
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
).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
).previousWorkerNodeKey
).toBe(pool.workerNodes.length - 1)
// We need to clean up the resources after our test
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
}
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(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
}
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(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
expect(workerNode.usage.runTime.median).toBeGreaterThan(0)
}
}
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
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
Number.MAX_SAFE_INTEGER,
1
)
Number.MAX_SAFE_INTEGER,
1
)
- const resetResult = strategy.reset()
- expect(resetResult).toBe(true)
+ expect(strategy.reset()).toBe(true)
expect(strategy.nextWorkerNodeKey).toBe(0)
expect(strategy.previousWorkerNodeKey).toBe(0)
expect(strategy.workerVirtualTaskRunTime).toBe(0)
expect(strategy.nextWorkerNodeKey).toBe(0)
expect(strategy.previousWorkerNodeKey).toBe(0)
expect(strategy.workerVirtualTaskRunTime).toBe(0)