describe('Abstract pool test suite', () => {
const numberOfWorkers = 2
- class StubPoolWithRemoveAllWorker extends FixedThreadPool {
- removeAllWorker () {
- this.workerNodes = []
- this.promiseResponseMap.clear()
- this.handleWorkerReadyMessage = () => {}
- }
- }
class StubPoolWithIsMain extends FixedThreadPool {
isMain () {
return false
'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
)
)
+ expect(
+ () =>
+ new DynamicThreadPool(0, 0, './tests/worker-files/thread/testWorker.js')
+ ).toThrowError(
+ new RangeError(
+ 'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
+ )
+ )
})
it('Verify that pool options are checked', async () => {
await pool.destroy()
})
- it('Simulate worker not found', async () => {
- const pool = new StubPoolWithRemoveAllWorker(
- numberOfWorkers,
- './tests/worker-files/thread/testWorker.js',
- {
- errorHandler: e => console.error(e)
- }
- )
- expect(pool.workerNodes.length).toBe(numberOfWorkers)
- // Simulate worker not found.
- pool.removeAllWorker()
- expect(pool.workerNodes.length).toBe(0)
- await pool.destroy()
- })
-
it('Verify that pool worker tasks usage are initialized', async () => {
const pool = new FixedClusterPool(
numberOfWorkers,