await emptyPool.destroy()
})
- it('Choose worker round robin test', async () => {
- const results = new Set()
- for (let i = 0; i < numberOfWorkers; i++) {
- results.add(pool.chooseWorker().id)
- }
- expect(results.size).toBe(numberOfWorkers)
- })
-
it('Verify that the function is executed in a worker cluster', async () => {
let result = await pool.execute({
function: WorkerFunctions.fibonacci
const {
WorkerChoiceStrategies,
DynamicThreadPool,
- FixedThreadPool
+ FixedThreadPool,
+ FixedClusterPool
} = require('../../../lib/index')
describe('Selection strategies test suite', () => {
await pool.destroy()
})
+ it('Verify ROUND_ROBIN strategy runtime behavior', async () => {
+ let pool = new FixedClusterPool(
+ max,
+ './tests/worker-files/cluster/testWorker.js'
+ )
+ let results = new Set()
+ for (let i = 0; i < max; i++) {
+ results.add(pool.chooseWorker().id)
+ }
+ expect(results.size).toBe(max)
+ await pool.destroy()
+ pool = new FixedThreadPool(max, './tests/worker-files/thread/testWorker.js')
+ results = new Set()
+ for (let i = 0; i < max; i++) {
+ results.add(pool.chooseWorker().threadId)
+ }
+ expect(results.size).toBe(max)
+ await pool.destroy()
+ })
+
it('Verify ROUND_ROBIN strategy internals are resets after setting it', async () => {
let pool = new FixedThreadPool(
max,
await emptyPool.destroy()
})
- it('Choose worker round robin test', async () => {
- const results = new Set()
- for (let i = 0; i < numberOfThreads; i++) {
- results.add(pool.chooseWorker().threadId)
- }
- expect(results.size).toBe(numberOfThreads)
- })
-
it('Verify that the function is executed in a worker thread', async () => {
let result = await pool.execute({
function: WorkerFunctions.fibonacci