- await Promise.all(promises)
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify FAIR_SHARE strategy is taken at pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js',
- { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
- )
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )
- for (const worker of pool.workerChoiceStrategyContext
- .getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.keys()) {
- expect(
- pool.workerChoiceStrategyContext
- .getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).start
- ).toBe(0)
- expect(
- pool.workerChoiceStrategyContext
- .getWorkerChoiceStrategy()
- .workerLastVirtualTaskTimestamp.get(worker).end
- ).toBe(0)
- }
- // We need to clean up the resources after our test
- await pool.destroy()
- })
-
- it('Verify FAIR_SHARE strategy can be set after pool creation', async () => {
- const pool = new FixedThreadPool(
- max,
- './tests/worker-files/thread/testWorker.js'
- )
- pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.FAIR_SHARE)
- expect(pool.opts.workerChoiceStrategy).toBe(
- WorkerChoiceStrategies.FAIR_SHARE
- )