)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(false)
await pool.destroy()
pool = new DynamicThreadPool(
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(false)
// We need to clean up the resources after our test
await pool.destroy()
)
let results = new Set()
for (let i = 0; i < max; i++) {
- results.add(pool.chooseWorker().id)
+ results.add(pool.chooseWorker()[1].id)
}
expect(results.size).toBe(max)
await pool.destroy()
pool = new FixedThreadPool(max, './tests/worker-files/thread/testWorker.js')
results = new Set()
for (let i = 0; i < max; i++) {
- results.add(pool.chooseWorker().threadId)
+ results.add(pool.chooseWorker()[1].threadId)
}
expect(results.size).toBe(max)
await pool.destroy()
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_USED)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(false)
await pool.destroy()
pool = new DynamicThreadPool(
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_USED)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(false)
// We need to clean up the resources after our test
await pool.destroy()
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_BUSY)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
await pool.destroy()
pool = new DynamicThreadPool(
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_BUSY)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
expect(pool.opts.workerChoiceStrategy).toBe(
WorkerChoiceStrategies.FAIR_SHARE
)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workerLastVirtualTaskTimestamp.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).start
+ .workerLastVirtualTaskTimestamp.get(workerKey).start
).toBe(0)
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).end
+ .workerLastVirtualTaskTimestamp.get(workerKey).end
).toBe(0)
}
// We need to clean up the resources after our test
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
await pool.destroy()
pool = new DynamicThreadPool(
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
promises.push(pool.execute())
}
await Promise.all(promises)
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ .workerLastVirtualTaskTimestamp.size
+ ).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
})
promises.push(pool.execute())
}
await Promise.all(promises)
+ // expect(
+ // pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ // .workerChoiceStrategy.workerLastVirtualTaskTimestamp.size
+ // ).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
})
.workerLastVirtualTaskTimestamp
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workerLastVirtualTaskTimestamp.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).start
+ .workerLastVirtualTaskTimestamp.get(workerKey).start
).toBe(0)
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).end
+ .workerLastVirtualTaskTimestamp.get(workerKey).end
).toBe(0)
}
await pool.destroy()
.workerChoiceStrategy.workerLastVirtualTaskTimestamp
).toBeUndefined()
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workerChoiceStrategy.workerLastVirtualTaskTimestamp.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(worker).start
+ .workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(workerKey)
+ .start
).toBe(0)
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(worker).end
+ .workerChoiceStrategy.workerLastVirtualTaskTimestamp.get(workerKey)
+ .end
).toBe(0)
}
// We need to clean up the resources after our test
pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
.defaultWorkerWeight
).toBeGreaterThan(0)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workersTaskRunTime.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workersTaskRunTime.get(worker).weight
+ .workersTaskRunTime.get(workerKey).weight
).toBeGreaterThan(0)
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workersTaskRunTime.get(worker).runTime
+ .workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
// We need to clean up the resources after our test
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
await pool.destroy()
pool = new DynamicThreadPool(
)
pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
expect(
- pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
- .requiredStatistics.runTime
+ pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
promises.push(pool.execute())
}
await Promise.all(promises)
+ expect(
+ pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ .workersTaskRunTime.size
+ ).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
})
promises.push(pool.execute())
}
await Promise.all(promises)
+ // expect(
+ // pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
+ // .workerChoiceStrategy.workersTaskRunTime.size
+ // ).toBe(pool.workers.length)
// We need to clean up the resources after our test
await pool.destroy()
})
pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
.defaultWorkerWeight
).toBeGreaterThan(0)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workersTaskRunTime.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workersTaskRunTime.get(worker).runTime
+ .workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
await pool.destroy()
pool.workerChoiceStrategyContext.getWorkerChoiceStrategy()
.workerChoiceStrategy.defaultWorkerWeight
).toBeGreaterThan(0)
- for (const worker of pool.workerChoiceStrategyContext
+ for (const workerKey of pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
.workerChoiceStrategy.workersTaskRunTime.keys()) {
expect(
pool.workerChoiceStrategyContext
.getWorkerChoiceStrategy()
- .workerChoiceStrategy.workersTaskRunTime.get(worker).runTime
+ .workerChoiceStrategy.workersTaskRunTime.get(workerKey).runTime
).toBe(0)
}
// We need to clean up the resources after our test