{ workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: 0,
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
)
// TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: 0,
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED }
)
// TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: 0,
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED }
)
// TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: 0,
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_BUSY }
)
// TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: expect.any(Number),
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_BUSY }
)
// TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
+ }
+ await Promise.all(promises)
+ for (const workerNode of pool.workerNodes) {
+ expect(workerNode.tasksUsage).toStrictEqual({
+ run: expect.any(Number),
+ running: 0,
+ runTime: expect.any(Number),
+ runTimeHistory: expect.any(CircularArray),
+ avgRunTime: 0,
+ medRunTime: 0,
+ waitTime: 0,
+ waitTimeHistory: expect.any(CircularArray),
+ avgWaitTime: 0,
+ medWaitTime: 0,
+ error: 0
+ })
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
{ workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
)
// TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- run: maxMultiplier,
+ run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
runTimeHistory: expect.any(CircularArray),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
{ workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
)
// TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- run: max * maxMultiplier,
+ run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
runTimeHistory: expect.any(CircularArray),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
}
)
// TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- run: max * maxMultiplier,
+ run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
runTimeHistory: expect.any(CircularArray),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.medRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.medRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
// TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- // FIXME: it should be:
- // run: max * maxMultiplier,
run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
// TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- run: max * maxMultiplier,
+ run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
runTimeHistory: expect.any(CircularArray),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.avgRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
}
)
// TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
+ const promises = []
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
+ promises.push(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
expect(workerNode.tasksUsage).toStrictEqual({
- run: max * maxMultiplier,
+ run: expect.any(Number),
running: 0,
runTime: expect.any(Number),
runTimeHistory: expect.any(CircularArray),
medWaitTime: 0,
error: 0
})
- expect(workerNode.tasksUsage.medRunTime).toBeGreaterThanOrEqual(0)
+ expect(workerNode.tasksUsage.run).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.runTime).toBeGreaterThan(0)
+ expect(workerNode.tasksUsage.medRunTime).toBeGreaterThan(0)
}
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(