FixedClusterPool,
FixedThreadPool,
WorkerChoiceStrategies
-} from '../../../lib/index.js'
-import { CircularArray } from '../../../lib/circular-array.js'
+} from '../../../lib/index.cjs'
+import { CircularArray } from '../../../lib/circular-array.cjs'
describe('Selection strategies test suite', () => {
const min = 0
const pool = new DynamicClusterPool(
min,
max,
- './tests/worker-files/cluster/testWorker.js'
+ './tests/worker-files/cluster/testWorker.cjs'
)
pool.setWorkerChoiceStrategy(workerChoiceStrategy)
expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
workerChoiceStrategy
).roundWeights.length
).toBe(1)
+ expect(
+ Number.isSafeInteger(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ workerChoiceStrategy
+ ).roundWeights[0]
+ )
+ ).toBe(true)
}
}
await pool.destroy()
const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
let pool = new FixedClusterPool(
max,
- './tests/worker-files/cluster/testWorker.js',
+ './tests/worker-files/cluster/testWorker.cjs',
{ workerChoiceStrategy }
)
let results = new Set()
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights.length
).toBe(1)
+ expect(
+ Number.isSafeInteger(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).roundWeights[0]
+ )
+ ).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
})
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).previousWorkerNodeKey
- ).toEqual(expect.any(Number))
+ ).toEqual(0)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights.length
).toBe(1)
+ expect(
+ Number.isSafeInteger(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).roundWeights[0]
+ )
+ ).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
})
pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights.length
).toBe(1)
+ expect(
+ Number.isSafeInteger(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).roundWeights[0]
+ )
+ ).toBe(true)
await pool.destroy()
pool = new DynamicThreadPool(
min,
pool.workerChoiceStrategyContext.workerChoiceStrategy
).roundWeights.length
).toBe(1)
+ expect(
+ Number.isSafeInteger(
+ pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
+ pool.workerChoiceStrategyContext.workerChoiceStrategy
+ ).roundWeights[0]
+ )
+ ).toBe(true)
// We need to clean up the resources after our test
await pool.destroy()
})