await pool.destroy()
})
- it('Verify ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
+ it('Verify ROUND_ROBIN strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify ROUND_ROBIN strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
let pool = new FixedThreadPool(
max,
await pool.destroy()
})
- it('Verify LEAST_USED strategy default tasks usage statistics requirements', async () => {
+ it('Verify LEAST_USED strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_USED
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify LEAST_USED strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_USED
let pool = new FixedThreadPool(
max,
await pool.destroy()
})
- it('Verify LEAST_BUSY strategy default tasks usage statistics requirements', async () => {
+ it('Verify LEAST_BUSY strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_BUSY
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify LEAST_BUSY strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_BUSY
let pool = new FixedThreadPool(
max,
utilization: 0
}
})
- expect(workerNode.workerUsage.tasks.executed).toBeGreaterThanOrEqual(0)
+ expect(workerNode.workerUsage.tasks.executed).toBeGreaterThan(0)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
await pool.destroy()
})
- it('Verify LEAST_ELU strategy default tasks usage statistics requirements', async () => {
+ it('Verify LEAST_ELU strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify LEAST_ELU strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
let pool = new FixedThreadPool(
max,
await pool.destroy()
})
- it('Verify FAIR_SHARE strategy default tasks usage statistics requirements', async () => {
+ it('Verify FAIR_SHARE strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: false
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify FAIR_SHARE strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
let pool = new FixedThreadPool(
max,
for (const workerNode of pool.workerNodes) {
expect(workerNode.workerUsage).toStrictEqual({
tasks: {
- executed: maxMultiplier,
+ executed: expect.any(Number),
executing: 0,
queued: 0,
failed: 0
utilization: expect.any(Number)
}
})
+ expect(workerNode.workerUsage.tasks.executed).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
+ max * maxMultiplier
+ )
expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.average).toBeGreaterThan(0)
expect(workerNode.workerUsage.elu.utilization).toBeGreaterThanOrEqual(0)
for (const workerNode of pool.workerNodes) {
expect(workerNode.workerUsage).toStrictEqual({
tasks: {
- executed: maxMultiplier,
+ executed: expect.any(Number),
executing: 0,
queued: 0,
failed: 0
utilization: expect.any(Number)
}
})
+ expect(workerNode.workerUsage.tasks.executed).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
+ max * maxMultiplier
+ )
expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.median).toBeGreaterThan(0)
expect(workerNode.workerUsage.elu.utilization).toBeGreaterThanOrEqual(0)
await pool.destroy()
})
- it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
+ it('Verify WEIGHTED_ROUND_ROBIN strategy default policy', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
let pool = new FixedThreadPool(
max,
utilization: 0
}
})
- expect(workerNode.workerUsage.tasks.executed).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.tasks.executed).toBeGreaterThanOrEqual(0)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
utilization: 0
}
})
- expect(workerNode.workerUsage.tasks.executed).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.tasks.executed).toBeGreaterThanOrEqual(0)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
await pool.destroy()
})
- it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
+ it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy default policy', async () => {
+ const workerChoiceStrategy =
+ WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
+ let pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ await pool.destroy()
+ pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
+ useDynamicWorker: true
+ })
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+
+ it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy default tasks statistics requirements', async () => {
const workerChoiceStrategy =
WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
let pool = new FixedThreadPool(