WorkerChoiceStrategies.ROUND_ROBIN
).nextWorkerNodeKey
).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ ).previousWorkerNodeKey
+ ).toBe(pool.workerNodes.length - 1)
// We need to clean up the resources after our test
await pool.destroy()
})
WorkerChoiceStrategies.ROUND_ROBIN
).nextWorkerNodeKey
).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ ).previousWorkerNodeKey
+ ).toBe(pool.workerNodes.length - 1)
// We need to clean up the resources after our test
await pool.destroy()
})
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
- ).toBeDefined()
- pool.setWorkerChoiceStrategy(workerChoiceStrategy)
+ ).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).nextWorkerNodeKey
+ ).previousWorkerNodeKey
).toBe(0)
await pool.destroy()
pool = new DynamicThreadPool(
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
)
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
- ).toBeDefined()
- pool.setWorkerChoiceStrategy(workerChoiceStrategy)
+ ).toBe(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
- ).nextWorkerNodeKey
+ ).previousWorkerNodeKey
).toBe(0)
// We need to clean up the resources after our test
await pool.destroy()
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workersVirtualTaskEndTimestamp.length
).toBe(0)
await pool.destroy()
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workersVirtualTaskEndTimestamp
).toBeInstanceOf(Array)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workersVirtualTaskEndTimestamp.length
).toBe(0)
// We need to clean up the resources after our test
workerChoiceStrategy
).nextWorkerNodeKey
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
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
).toBeGreaterThan(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workerVirtualTaskRunTime
).toBe(0)
await pool.destroy()
workerChoiceStrategy
).nextWorkerNodeKey
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
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
).toBeGreaterThan(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).workerVirtualTaskRunTime
).toBe(0)
// We need to clean up the resources after our test
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toEqual(expect.any(Number))
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toEqual(expect.any(Number))
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
workerChoiceStrategy
).roundId
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).workerNodeId
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
).nextWorkerNodeKey
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundId
).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).workerNodeId
+ ).toBe(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
).toBeGreaterThan(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights
).toStrictEqual([
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
).roundId
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).workerNodeId
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
).nextWorkerNodeKey
).toBeDefined()
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).previousWorkerNodeKey
+ ).toBeDefined()
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
workerChoiceStrategy
).roundWeights
).toBeDefined()
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).roundId
+ ).toBe(0)
+ expect(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).workerNodeId
+ ).toBe(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
).toBeGreaterThan(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
- workerChoiceStrategy
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights
).toStrictEqual([
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(