Commit | Line | Data |
---|---|---|
0220f124 JB |
1 | const { expect } = require('expect') |
2 | const sinon = require('sinon') | |
cdace0e5 | 3 | const { FixedThreadPool } = require('../../../lib') |
0220f124 JB |
4 | const { |
5 | WeightedRoundRobinWorkerChoiceStrategy | |
6 | } = require('../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy') | |
bac873bd | 7 | const { generateRandomInteger } = require('../../test-utils') |
0220f124 JB |
8 | |
9 | describe('Weighted round robin strategy worker choice strategy test suite', () => { | |
10 | // const min = 1 | |
11 | const max = 3 | |
12 | let pool | |
13 | ||
14 | before(() => { | |
15 | pool = new FixedThreadPool(max, './tests/worker-files/thread/testWorker.js') | |
16 | }) | |
17 | ||
18 | afterEach(() => { | |
19 | sinon.restore() | |
20 | }) | |
21 | ||
22 | after(async () => { | |
23 | await pool.destroy() | |
24 | }) | |
25 | ||
6cdd998c | 26 | it('Verify that reset() resets internals', () => { |
0220f124 | 27 | const strategy = new WeightedRoundRobinWorkerChoiceStrategy(pool) |
bac873bd JB |
28 | strategy.currentWorkerId = generateRandomInteger(Number.MAX_SAFE_INTEGER, 1) |
29 | strategy.workerVirtualTaskRunTime = generateRandomInteger( | |
08f3f44c JB |
30 | Number.MAX_SAFE_INTEGER, |
31 | 1 | |
32 | ) | |
0220f124 JB |
33 | const resetResult = strategy.reset() |
34 | expect(resetResult).toBe(true) | |
9b106837 | 35 | expect(strategy.nextWorkerNodeKey).toBe(0) |
08f3f44c | 36 | expect(strategy.workerVirtualTaskRunTime).toBe(0) |
0220f124 JB |
37 | }) |
38 | }) |