} = require('../../../lib/index')
describe('Selection strategies test suite', () => {
+ const min = 0
+ const max = 3
+
it('Verify that WorkerChoiceStrategies enumeration provides string values', () => {
expect(WorkerChoiceStrategies.ROUND_ROBIN).toBe('ROUND_ROBIN')
expect(WorkerChoiceStrategies.LESS_RECENTLY_USED).toBe('LESS_RECENTLY_USED')
})
it('Verify ROUND_ROBIN strategy is the default at pool creation', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify ROUND_ROBIN strategy can be set after pool creation', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
- const min = 0
- const max = 3
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify ROUND_ROBIN strategy can be run in a fixed pool', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify LESS_RECENTLY_USED strategy is taken at pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify LESS_RECENTLY_USED strategy can be set after pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify LESS_RECENTLY_USED strategy default tasks usage statistics requirements', async () => {
- const min = 0
- const max = 3
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify LESS_RECENTLY_USED strategy can be run in a fixed pool', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify LESS_RECENTLY_USED strategy can be run in a dynamic pool', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify FAIR_SHARE strategy is taken at pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify FAIR_SHARE strategy can be set after pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify FAIR_SHARE strategy default tasks usage statistics requirements', async () => {
- const min = 0
- const max = 3
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify FAIR_SHARE strategy can be run in a fixed pool', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify FAIR_SHARE strategy can be run in a dynamic pool', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify WEIGHTED_ROUND_ROBIN strategy is taken at pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify WEIGHTED_ROUND_ROBIN strategy can be set after pool creation', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify WEIGHTED_ROUND_ROBIN strategy default tasks usage statistics requirements', async () => {
- const min = 0
- const max = 3
let pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js'
})
it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
- const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
})
it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a dynamic pool', async () => {
- const min = 0
- const max = 3
const pool = new DynamicThreadPool(
min,
max,
})
it('Verify unknown strategies throw error', () => {
- const min = 1
- const max = 3
expect(
() =>
new DynamicThreadPool(