1 const { expect
} = require('expect')
3 WorkerChoiceStrategies
,
7 } = require('../../../lib')
8 const { CircularArray
} = require('../../../lib/circular-array')
10 describe('Selection strategies test suite', () => {
14 it('Verify that WorkerChoiceStrategies enumeration provides string values', () => {
15 expect(WorkerChoiceStrategies
.ROUND_ROBIN
).toBe('ROUND_ROBIN')
16 expect(WorkerChoiceStrategies
.LEAST_USED
).toBe('LEAST_USED')
17 expect(WorkerChoiceStrategies
.LEAST_BUSY
).toBe('LEAST_BUSY')
18 expect(WorkerChoiceStrategies
.FAIR_SHARE
).toBe('FAIR_SHARE')
19 expect(WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
).toBe(
20 'WEIGHTED_ROUND_ROBIN'
24 it('Verify ROUND_ROBIN strategy is the default at pool creation', async () => {
25 const pool
= new DynamicThreadPool(
28 './tests/worker-files/thread/testWorker.js'
30 expect(pool
.opts
.workerChoiceStrategy
).toBe(
31 WorkerChoiceStrategies
.ROUND_ROBIN
33 // We need to clean up the resources after our test
37 it('Verify available strategies are taken at pool creation', async () => {
38 for (const workerChoiceStrategy
of Object
.values(WorkerChoiceStrategies
)) {
39 const pool
= new FixedThreadPool(
41 './tests/worker-files/thread/testWorker.js',
42 { workerChoiceStrategy
}
44 expect(pool
.opts
.workerChoiceStrategy
).toBe(workerChoiceStrategy
)
45 expect(pool
.workerChoiceStrategyContext
.workerChoiceStrategy
).toBe(
52 it('Verify available strategies can be set after pool creation', async () => {
53 for (const workerChoiceStrategy
of Object
.values(WorkerChoiceStrategies
)) {
54 const pool
= new DynamicThreadPool(
57 './tests/worker-files/thread/testWorker.js'
59 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
60 expect(pool
.opts
.workerChoiceStrategy
).toBe(workerChoiceStrategy
)
61 expect(pool
.workerChoiceStrategyContext
.workerChoiceStrategy
).toBe(
68 it('Verify available strategies default internals at pool creation', async () => {
69 const pool
= new FixedThreadPool(
71 './tests/worker-files/thread/testWorker.js'
73 for (const workerChoiceStrategy
of Object
.values(WorkerChoiceStrategies
)) {
74 if (workerChoiceStrategy
=== WorkerChoiceStrategies
.ROUND_ROBIN
) {
76 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
80 } else if (workerChoiceStrategy
=== WorkerChoiceStrategies
.FAIR_SHARE
) {
82 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
84 ).workersVirtualTaskEndTimestamp
85 ).toBeInstanceOf(Array
)
87 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
89 ).workersVirtualTaskEndTimestamp
.length
92 workerChoiceStrategy
=== WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
95 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
100 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
102 ).defaultWorkerWeight
105 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
107 ).workerVirtualTaskRunTime
114 it('Verify ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
115 const workerChoiceStrategy
= WorkerChoiceStrategies
.ROUND_ROBIN
116 let pool
= new FixedThreadPool(
118 './tests/worker-files/thread/testWorker.js',
119 { workerChoiceStrategy
}
122 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
132 pool
= new DynamicThreadPool(
135 './tests/worker-files/thread/testWorker.js',
136 { workerChoiceStrategy
}
139 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
148 // We need to clean up the resources after our test
152 it('Verify ROUND_ROBIN strategy can be run in a fixed pool', async () => {
153 const pool
= new FixedThreadPool(
155 './tests/worker-files/thread/testWorker.js',
156 { workerChoiceStrategy
: WorkerChoiceStrategies
.ROUND_ROBIN
}
158 // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
159 const maxMultiplier
= 2
160 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
163 // We need to clean up the resources after our test
167 it('Verify ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
168 const pool
= new DynamicThreadPool(
171 './tests/worker-files/thread/testWorker.js',
172 { workerChoiceStrategy
: WorkerChoiceStrategies
.ROUND_ROBIN
}
174 // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
175 const maxMultiplier
= 2
176 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
179 // We need to clean up the resources after our test
183 it('Verify ROUND_ROBIN strategy runtime behavior', async () => {
184 const workerChoiceStrategy
= WorkerChoiceStrategies
.ROUND_ROBIN
185 let pool
= new FixedClusterPool(
187 './tests/worker-files/cluster/testWorker.js',
188 { workerChoiceStrategy
}
190 let results
= new Set()
191 for (let i
= 0; i
< max
; i
++) {
192 results
.add(pool
.workerNodes
[pool
.chooseWorkerNode()].worker
.id
)
194 expect(results
.size
).toBe(max
)
196 pool
= new FixedThreadPool(
198 './tests/worker-files/thread/testWorker.js',
199 { workerChoiceStrategy
}
202 for (let i
= 0; i
< max
; i
++) {
203 results
.add(pool
.workerNodes
[pool
.chooseWorkerNode()].worker
.threadId
)
205 expect(results
.size
).toBe(max
)
209 it('Verify ROUND_ROBIN strategy internals are resets after setting it', async () => {
210 const workerChoiceStrategy
= WorkerChoiceStrategies
.ROUND_ROBIN
211 let pool
= new FixedThreadPool(
213 './tests/worker-files/thread/testWorker.js',
214 { workerChoiceStrategy
: WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
}
217 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
221 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
223 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
224 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
228 pool
= new DynamicThreadPool(
231 './tests/worker-files/thread/testWorker.js',
232 { workerChoiceStrategy
: WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
}
235 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
239 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
241 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
242 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
245 // We need to clean up the resources after our test
249 it('Verify LEAST_USED strategy default tasks usage statistics requirements', async () => {
250 const workerChoiceStrategy
= WorkerChoiceStrategies
.LEAST_USED
251 let pool
= new FixedThreadPool(
253 './tests/worker-files/thread/testWorker.js',
254 { workerChoiceStrategy
}
257 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
267 pool
= new DynamicThreadPool(
270 './tests/worker-files/thread/testWorker.js',
271 { workerChoiceStrategy
}
274 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
283 // We need to clean up the resources after our test
287 it('Verify LEAST_USED strategy can be run in a fixed pool', async () => {
288 const pool
= new FixedThreadPool(
290 './tests/worker-files/thread/testWorker.js',
291 { workerChoiceStrategy
: WorkerChoiceStrategies
.LEAST_USED
}
293 // TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
294 const maxMultiplier
= 2
295 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
298 // We need to clean up the resources after our test
302 it('Verify LEAST_USED strategy can be run in a dynamic pool', async () => {
303 const pool
= new DynamicThreadPool(
306 './tests/worker-files/thread/testWorker.js',
307 { workerChoiceStrategy
: WorkerChoiceStrategies
.LEAST_USED
}
309 // TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
310 const maxMultiplier
= 2
311 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
314 // We need to clean up the resources after our test
318 it('Verify LEAST_BUSY strategy default tasks usage statistics requirements', async () => {
319 const workerChoiceStrategy
= WorkerChoiceStrategies
.LEAST_BUSY
320 let pool
= new FixedThreadPool(
322 './tests/worker-files/thread/testWorker.js',
323 { workerChoiceStrategy
}
326 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
336 pool
= new DynamicThreadPool(
339 './tests/worker-files/thread/testWorker.js',
340 { workerChoiceStrategy
}
343 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
352 // We need to clean up the resources after our test
356 it('Verify LEAST_BUSY strategy can be run in a fixed pool', async () => {
357 const pool
= new FixedThreadPool(
359 './tests/worker-files/thread/testWorker.js',
360 { workerChoiceStrategy
: WorkerChoiceStrategies
.LEAST_BUSY
}
362 // TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
363 const maxMultiplier
= 2
364 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
367 // We need to clean up the resources after our test
371 it('Verify LEAST_BUSY strategy can be run in a dynamic pool', async () => {
372 const pool
= new DynamicThreadPool(
375 './tests/worker-files/thread/testWorker.js',
376 { workerChoiceStrategy
: WorkerChoiceStrategies
.LEAST_BUSY
}
378 // TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
379 const maxMultiplier
= 2
380 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
383 // We need to clean up the resources after our test
387 it('Verify FAIR_SHARE strategy default tasks usage statistics requirements', async () => {
388 const workerChoiceStrategy
= WorkerChoiceStrategies
.FAIR_SHARE
389 let pool
= new FixedThreadPool(
391 './tests/worker-files/thread/testWorker.js',
392 { workerChoiceStrategy
}
395 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
405 pool
= new DynamicThreadPool(
408 './tests/worker-files/thread/testWorker.js',
409 { workerChoiceStrategy
}
412 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
421 // We need to clean up the resources after our test
425 it('Verify FAIR_SHARE strategy can be run in a fixed pool', async () => {
426 const pool
= new FixedThreadPool(
428 './tests/worker-files/thread/testWorker.js',
429 { workerChoiceStrategy
: WorkerChoiceStrategies
.FAIR_SHARE
}
431 // TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
432 const maxMultiplier
= 2
433 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
436 for (const workerNode
of pool
.workerNodes
) {
437 expect(workerNode
.tasksUsage
).toStrictEqual({
440 runTime
: expect
.any(Number
),
441 runTimeHistory
: expect
.any(CircularArray
),
442 avgRunTime
: expect
.any(Number
),
445 waitTimeHistory
: expect
.any(CircularArray
),
450 expect(workerNode
.tasksUsage
.avgRunTime
).toBeGreaterThanOrEqual(0)
453 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
454 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
455 ).workersVirtualTaskEndTimestamp
.length
456 ).toBe(pool
.workerNodes
.length
)
457 // We need to clean up the resources after our test
461 it('Verify FAIR_SHARE strategy can be run in a dynamic pool', async () => {
462 const pool
= new DynamicThreadPool(
465 './tests/worker-files/thread/testWorker.js',
466 { workerChoiceStrategy
: WorkerChoiceStrategies
.FAIR_SHARE
}
468 // TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
469 const maxMultiplier
= 2
470 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
473 for (const workerNode
of pool
.workerNodes
) {
474 expect(workerNode
.tasksUsage
).toStrictEqual({
475 run
: max
* maxMultiplier
,
477 runTime
: expect
.any(Number
),
478 runTimeHistory
: expect
.any(CircularArray
),
479 avgRunTime
: expect
.any(Number
),
482 waitTimeHistory
: expect
.any(CircularArray
),
487 expect(workerNode
.tasksUsage
.avgRunTime
).toBeGreaterThanOrEqual(0)
490 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
491 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
492 ).workersVirtualTaskEndTimestamp
.length
493 ).toBe(pool
.workerNodes
.length
)
494 // We need to clean up the resources after our test
498 it('Verify FAIR_SHARE strategy can be run in a dynamic pool with median runtime statistic', async () => {
499 const pool
= new DynamicThreadPool(
502 './tests/worker-files/thread/testWorker.js',
504 workerChoiceStrategy
: WorkerChoiceStrategies
.FAIR_SHARE
,
505 workerChoiceStrategyOptions
: {
510 // TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
511 const maxMultiplier
= 2
512 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
515 for (const workerNode
of pool
.workerNodes
) {
516 expect(workerNode
.tasksUsage
).toStrictEqual({
517 run
: max
* maxMultiplier
,
519 runTime
: expect
.any(Number
),
520 runTimeHistory
: expect
.any(CircularArray
),
522 medRunTime
: expect
.any(Number
),
524 waitTimeHistory
: expect
.any(CircularArray
),
529 expect(workerNode
.tasksUsage
.medRunTime
).toBeGreaterThanOrEqual(0)
532 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
533 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
534 ).workersVirtualTaskEndTimestamp
.length
535 ).toBe(pool
.workerNodes
.length
)
536 // We need to clean up the resources after our test
540 it('Verify FAIR_SHARE strategy internals are resets after setting it', async () => {
541 const workerChoiceStrategy
= WorkerChoiceStrategies
.FAIR_SHARE
542 let pool
= new FixedThreadPool(
544 './tests/worker-files/thread/testWorker.js'
547 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
549 ).workersVirtualTaskEndTimestamp
550 ).toBeInstanceOf(Array
)
552 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
554 ).workersVirtualTaskEndTimestamp
.length
556 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
558 ).workersVirtualTaskEndTimestamp
[0] = performance
.now()
560 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
562 ).workersVirtualTaskEndTimestamp
.length
564 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
566 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
568 ).workersVirtualTaskEndTimestamp
569 ).toBeInstanceOf(Array
)
571 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
573 ).workersVirtualTaskEndTimestamp
.length
576 pool
= new DynamicThreadPool(
579 './tests/worker-files/thread/testWorker.js'
582 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
584 ).workersVirtualTaskEndTimestamp
585 ).toBeInstanceOf(Array
)
587 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
589 ).workersVirtualTaskEndTimestamp
.length
591 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
593 ).workersVirtualTaskEndTimestamp
[0] = performance
.now()
595 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
597 ).workersVirtualTaskEndTimestamp
.length
599 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
601 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
603 ).workersVirtualTaskEndTimestamp
604 ).toBeInstanceOf(Array
)
606 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
608 ).workersVirtualTaskEndTimestamp
.length
610 // We need to clean up the resources after our test
614 it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
615 const workerChoiceStrategy
= WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
616 let pool
= new FixedThreadPool(
618 './tests/worker-files/thread/testWorker.js',
619 { workerChoiceStrategy
}
622 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
632 pool
= new DynamicThreadPool(
635 './tests/worker-files/thread/testWorker.js',
636 { workerChoiceStrategy
}
639 pool
.workerChoiceStrategyContext
.getRequiredStatistics()
648 // We need to clean up the resources after our test
652 it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
653 const pool
= new FixedThreadPool(
655 './tests/worker-files/thread/testWorker.js',
656 { workerChoiceStrategy
: WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
}
658 // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
659 const maxMultiplier
= 2
660 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
663 for (const workerNode
of pool
.workerNodes
) {
664 expect(workerNode
.tasksUsage
).toStrictEqual({
665 // FIXME: it should be:
666 // run: max * maxMultiplier,
667 run
: expect
.any(Number
),
669 runTime
: expect
.any(Number
),
670 runTimeHistory
: expect
.any(CircularArray
),
671 avgRunTime
: expect
.any(Number
),
674 waitTimeHistory
: expect
.any(CircularArray
),
679 expect(workerNode
.tasksUsage
.avgRunTime
).toBeGreaterThanOrEqual(0)
682 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
683 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
684 ).defaultWorkerWeight
687 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
688 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
689 ).workerVirtualTaskRunTime
690 ).toBeGreaterThanOrEqual(0)
691 // We need to clean up the resources after our test
695 it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
696 const pool
= new DynamicThreadPool(
699 './tests/worker-files/thread/testWorker.js',
700 { workerChoiceStrategy
: WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
}
702 // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
703 const maxMultiplier
= 2
704 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
707 for (const workerNode
of pool
.workerNodes
) {
708 expect(workerNode
.tasksUsage
).toStrictEqual({
709 run
: max
* maxMultiplier
,
711 runTime
: expect
.any(Number
),
712 runTimeHistory
: expect
.any(CircularArray
),
713 avgRunTime
: expect
.any(Number
),
716 waitTimeHistory
: expect
.any(CircularArray
),
721 expect(workerNode
.tasksUsage
.avgRunTime
).toBeGreaterThanOrEqual(0)
724 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
725 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
726 ).defaultWorkerWeight
729 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
730 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
731 ).workerVirtualTaskRunTime
732 ).toBeGreaterThanOrEqual(0)
733 // We need to clean up the resources after our test
737 it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool with median runtime statistic', async () => {
738 const pool
= new DynamicThreadPool(
741 './tests/worker-files/thread/testWorker.js',
743 workerChoiceStrategy
: WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
,
744 workerChoiceStrategyOptions
: {
749 // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
750 const maxMultiplier
= 2
751 for (let i
= 0; i
< max
* maxMultiplier
; i
++) {
754 for (const workerNode
of pool
.workerNodes
) {
755 expect(workerNode
.tasksUsage
).toStrictEqual({
756 run
: max
* maxMultiplier
,
758 runTime
: expect
.any(Number
),
759 runTimeHistory
: expect
.any(CircularArray
),
761 medRunTime
: expect
.any(Number
),
763 waitTimeHistory
: expect
.any(CircularArray
),
768 expect(workerNode
.tasksUsage
.medRunTime
).toBeGreaterThanOrEqual(0)
771 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
772 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
773 ).defaultWorkerWeight
776 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
777 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
778 ).workerVirtualTaskRunTime
779 ).toBeGreaterThanOrEqual(0)
780 // We need to clean up the resources after our test
784 it('Verify WEIGHTED_ROUND_ROBIN strategy internals are resets after setting it', async () => {
785 const workerChoiceStrategy
= WorkerChoiceStrategies
.WEIGHTED_ROUND_ROBIN
786 let pool
= new FixedThreadPool(
788 './tests/worker-files/thread/testWorker.js'
791 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
793 ).currentWorkerNodeId
796 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
798 ).defaultWorkerWeight
801 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
803 ).workerVirtualTaskRunTime
805 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
807 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
808 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
809 ).currentWorkerNodeId
812 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
813 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
814 ).defaultWorkerWeight
817 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
819 ).workerVirtualTaskRunTime
822 pool
= new DynamicThreadPool(
825 './tests/worker-files/thread/testWorker.js'
828 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
830 ).currentWorkerNodeId
833 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
835 ).defaultWorkerWeight
838 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
840 ).workerVirtualTaskRunTime
842 pool
.setWorkerChoiceStrategy(workerChoiceStrategy
)
844 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
845 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
846 ).currentWorkerNodeId
849 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
850 pool
.workerChoiceStrategyContext
.workerChoiceStrategy
851 ).defaultWorkerWeight
854 pool
.workerChoiceStrategyContext
.workerChoiceStrategies
.get(
856 ).workerVirtualTaskRunTime
858 // We need to clean up the resources after our test
862 it('Verify unknown strategy throw error', () => {
865 new DynamicThreadPool(
868 './tests/worker-files/thread/testWorker.js',
869 { workerChoiceStrategy
: 'UNKNOWN_STRATEGY' }
871 ).toThrowError("Invalid worker choice strategy 'UNKNOWN_STRATEGY'")