errorHandler: e => console.error(e)
}
)
- // simulate worker not found.
+ // Simulate worker not found.
pool.removeAllWorker()
expect(() => pool.increaseWorkersTask()).toThrowError(expectedError)
})
errorHandler: e => console.error(e)
}
)
- // simulate worker not found.
+ // Simulate worker not found.
pool.removeAllWorker()
expect(() => pool.decreaseWorkersTasks()).toThrowError(expectedError)
})
errorHandler: e => console.error(e)
}
)
-
const asyncErrorPool = new FixedClusterPool(
1,
'./tests/worker-files/cluster/asyncErrorWorker.js',
)
const res = await pool1.execute({ test: 'test' })
expect(res).toBeFalsy()
+ // We need to clean up the resources after our test
+ await pool1.destroy()
})
it('Verify scale thread up and down is working when long running task is used:hard', async () => {
expect(longRunningPool.workers.length).toBe(max)
await TestUtils.waitExits(longRunningPool, max - min)
expect(longRunningPool.workers.length).toBe(min)
+ // We need to clean up the resources after our test
+ await longRunningPool.destroy()
})
it('Verify scale thread up and down is working when long running task is used:soft', async () => {
await TestUtils.sleep(1500)
// Here we expect the workers to be at the max size since that the task is still running
expect(longRunningPool.workers.length).toBe(max)
+ // We need to clean up the resources after our test
+ await longRunningPool.destroy()
})
})
)
describe('Fixed thread pool test suite', () => {
+ after('Destroy all pools', async () => {
+ // We need to clean up the resources after our test
+ await echoPool.destroy()
+ await asyncPool.destroy()
+ await errorPool.destroy()
+ await emptyPool.destroy()
+ })
+
it('Choose worker round robin test', async () => {
const results = new Set()
for (let i = 0; i < numberOfThreads; i++) {
)
const res = await pool1.execute({ test: 'test' })
expect(res).toBeFalsy()
+ // We need to clean up the resources after our test
+ await pool1.destroy()
})
})