await pool.destroy()
})
- it('Verify ROUND_ROBIN strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).nextWorkerNodeId
- ).toBe(0)
- // We need to clean up the resources after our test
- await pool.destroy()
+ it('Verify available strategies are taken at pool creation', async () => {
+ for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
+ const pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
+ expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ await pool.destroy()
+ }
})
- it('Verify ROUND_ROBIN strategy can be set after pool creation', async () => {
- const pool = new DynamicThreadPool(
- min,
+ it('Verify available strategies can be set after pool creation', async () => {
+ for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
+ const pool = new DynamicThreadPool(
+ min,
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
+ expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
+ expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ await pool.destroy()
+ }
+ })
+
+ it('Verify available strategies default internals at pool creation', async () => {
+ const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
)
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- // We need to clean up the resources after our test
+ for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
+ if (workerChoiceStrategy === WorkerChoiceStrategies.ROUND_ROBIN) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).nextWorkerNodeId
+ ).toBe(0)
+ } else if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) {
+ for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workerLastVirtualTaskTimestamp.keys()) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workerLastVirtualTaskTimestamp.get(workerNodeKey).start
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workerLastVirtualTaskTimestamp.get(workerNodeKey).end
+ ).toBe(0)
+ }
+ } else if (
+ workerChoiceStrategy === WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ ) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).currentWorkerNodeId
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).defaultWorkerWeight
+ ).toBeGreaterThan(0)
+ for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workersTaskRunTime.keys()) {
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workersTaskRunTime.get(workerNodeKey).weight
+ ).toBeGreaterThan(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies
+ .get(workerChoiceStrategy)
+ .workersTaskRunTime.get(workerNodeKey).runTime
+ ).toBe(0)
+ }
+ }
+ }
await pool.destroy()
})
it('Verify ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.ROUND_ROBIN }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
})
it('Verify ROUND_ROBIN strategy runtime behavior', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
let pool = new FixedClusterPool(
max,
- './tests/worker-files/cluster/testWorker.js'
+ './tests/worker-files/cluster/testWorker.js',
+ { workerChoiceStrategy }
)
let results = new Set()
for (let i = 0; i < max; i++) {
}
expect(results.size).toBe(max)
await pool.destroy()
- pool = new FixedThreadPool(max, './tests/worker-files/thread/testWorker.js')
+ pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy }
+ )
results = new Set()
for (let i = 0; i < max; i++) {
results.add(pool.chooseWorkerNode()[1].worker.threadId)
})
it('Verify ROUND_ROBIN strategy internals are resets after setting it', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
).nextWorkerNodeId
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
).nextWorkerNodeId
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.ROUND_ROBIN)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
await pool.destroy()
})
- it('Verify LESS_USED strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify LESS_USED strategy can be set after pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js'
- )
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_USED)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
it('Verify LESS_USED strategy default tasks usage statistics requirements', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_USED
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
await pool.destroy()
})
- it('Verify LESS_BUSY strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify LESS_BUSY strategy can be set after pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js'
- )
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_BUSY)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
it('Verify LESS_BUSY strategy default tasks usage statistics requirements', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_BUSY
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
await pool.destroy()
})
- it('Verify FAIR_SHARE strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )
- for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workerLastVirtualTaskTimestamp.keys()) {
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workerLastVirtualTaskTimestamp.get(workerNodeKey).start
- ).toBe(0)
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workerLastVirtualTaskTimestamp.get(workerNodeKey).end
- ).toBe(0)
- }
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify FAIR_SHARE strategy can be set after pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js'
- )
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
it('Verify FAIR_SHARE strategy default tasks usage statistics requirements', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
})
it('Verify FAIR_SHARE strategy internals are resets after setting it', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
).workerLastVirtualTaskTimestamp
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
.get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
.workerLastVirtualTaskTimestamp.keys()) {
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
).workerLastVirtualTaskTimestamp
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
.get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
.workerLastVirtualTaskTimestamp.keys()) {
await pool.destroy()
})
- it('Verify WEIGHTED_ROUND_ROBIN strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).currentWorkerNodeId
- ).toBe(0)
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).defaultWorkerWeight
- ).toBeGreaterThan(0)
- for (const workerNodeKey of pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workersTaskRunTime.keys()) {
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workersTaskRunTime.get(workerNodeKey).weight
- ).toBeGreaterThan(0)
- expect(
- pool.workerChoiceStrategyContext.workerChoiceStrategies
- .get(pool.workerChoiceStrategyContext.workerChoiceStrategy)
- .workersTaskRunTime.get(workerNodeKey).runTime
- ).toBe(0)
- }
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify WEIGHTED_ROUND_ROBIN strategy can be set after pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js'
- )
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
- expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
min,
max,
'./tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
+ { workerChoiceStrategy }
)
expect(
pool.workerChoiceStrategyContext.getRequiredStatistics().runTime
})
it('Verify WEIGHTED_ROUND_ROBIN strategy internals are resets after setting it', async () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).currentWorkerNodeId
).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).defaultWorkerWeight
).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).workersTaskRunTime
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).currentWorkerNodeId
).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).defaultWorkerWeight
).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).workersTaskRunTime
).toBeDefined()
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
})
it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
).isDynamicPool
).toBe(false)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
).isDynamicPool
).toBe(true)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
- )
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.ROUND_ROBIN
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with LESS_USED and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_USED
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
).isDynamicPool
).toBe(false)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_USED
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
)
).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with LESS_USED and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_USED
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
).isDynamicPool
).toBe(true)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_USED
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
)
).toBeInstanceOf(LessUsedWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_USED
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with LESS_BUSY and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_BUSY
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
).isDynamicPool
).toBe(false)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_BUSY
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
)
).toBeInstanceOf(LessBusyWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with LESS_BUSY and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.LESS_BUSY
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
).isDynamicPool
).toBe(true)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.LESS_BUSY
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
)
).toBeInstanceOf(LessBusyWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.LESS_BUSY
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
).isDynamicPool
).toBe(false)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.FAIR_SHARE
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
)
).toBeInstanceOf(FairShareWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
).isDynamicPool
).toBe(true)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.FAIR_SHARE
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
)
).toBeInstanceOf(FairShareWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with WEIGHTED_ROUND_ROBIN and fixed pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).isDynamicPool
).toBe(false)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
)
})
it('Verify that setWorkerChoiceStrategy() works with WEIGHTED_ROUND_ROBIN and dynamic pool', () => {
+ const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool
)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
).isDynamicPool
).toBe(true)
- workerChoiceStrategyContext.setWorkerChoiceStrategy(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
- )
+ workerChoiceStrategyContext.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
workerChoiceStrategyContext.workerChoiceStrategies.get(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
)
).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
expect(workerChoiceStrategyContext.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
+ workerChoiceStrategy
)
})
})