1 const { expect
} = require('expect')
2 const sinon
= require('sinon')
3 const { FixedThreadPool
} = require('../../../lib')
5 WeightedRoundRobinWorkerChoiceStrategy
6 } = require('../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy')
7 const { generateRandomInteger
} = require('../../test-utils')
9 describe('Weighted round robin strategy worker choice strategy test suite', () => {
15 pool
= new FixedThreadPool(max
, './tests/worker-files/thread/testWorker.js')
26 it('Verify that reset() resets internals', () => {
27 const strategy
= new WeightedRoundRobinWorkerChoiceStrategy(pool
)
28 strategy
.currentWorkerId
= generateRandomInteger(Number
.MAX_SAFE_INTEGER
, 1)
29 strategy
.workerVirtualTaskRunTime
= generateRandomInteger(
30 Number
.MAX_SAFE_INTEGER
,
33 expect(strategy
.reset()).toBe(true)
34 expect(strategy
.nextWorkerNodeKey
).toBe(0)
35 expect(strategy
.previousWorkerNodeKey
).toBe(0)
36 expect(strategy
.workerNodeVirtualTaskRunTime
).toBe(0)