private checkAndEmitEmptyEvent (): void {
if (this.empty) {
this.emitter?.emit(PoolEvents.empty, this.info)
- this.readyEventEmitted = false
}
}
* @returns The pool readiness boolean status.
*/
private get ready (): boolean {
- if (this.empty) {
+ if (!this.started) {
return false
}
+ if (this.empty) {
+ return true
+ }
return (
this.workerNodes.reduce(
(accumulator, workerNode) =>
expect(pool.starting).toBe(false)
expect(pool.destroying).toBe(false)
await pool.destroy()
+ expect(pool.started).toBe(false)
+ expect(pool.starting).toBe(false)
+ expect(pool.destroying).toBe(false)
})
it('Verify that filePath is checked', () => {
])
await pool.destroy()
const numberOfExitEvents = await exitPromise
- expect(pool.started).toBe(false)
+ expect(pool.info.started).toBe(false)
expect(pool.emitter.eventNames()).toStrictEqual([
PoolEvents.busy,
PoolEvents.destroy,
max,
'./tests/worker-files/cluster/testWorker.cjs',
{
+ startWorkers: false,
workerChoiceStrategy,
}
)
- expect(pool.starting).toBe(false)
- expect(pool.readyEventEmitted).toBe(false)
for (let run = 0; run < 2; run++) {
+ expect(pool.info.started).toBe(false)
+ expect(pool.info.ready).toBe(false)
+ pool.start()
+ expect(pool.info.started).toBe(true)
+ expect(pool.info.ready).toBe(true)
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
run % 2 !== 0 && pool.enableTasksQueue(true)
const maxMultiplier = 4
promises.add(pool.execute())
}
await Promise.all(promises)
- expect(pool.readyEventEmitted).toBe(true)
expect(pool.workerNodes.length).toBeGreaterThan(pool.info.minSize)
expect(pool.workerNodes.length).toBeLessThanOrEqual(pool.info.maxSize)
await waitPoolEvents(pool, PoolEvents.empty, 1)
- expect(pool.readyEventEmitted).toBe(false)
expect(pool.workerNodes.length).toBe(pool.info.minSize)
+ // We need to clean up the resources after our test
+ await pool.destroy()
}
- // We need to clean up the resources after our test
- await pool.destroy()
}
})
})
])
await pool.destroy()
const numberOfExitEvents = await exitPromise
- expect(pool.started).toBe(false)
+ expect(pool.info.started).toBe(false)
expect(pool.emitter.eventNames()).toStrictEqual([
PoolEvents.busy,
PoolEvents.destroy,
])
await pool.destroy()
const numberOfExitEvents = await exitPromise
- expect(pool.started).toBe(false)
+ expect(pool.info.started).toBe(false)
expect(pool.emitter.eventNames()).toStrictEqual([
PoolEvents.busy,
PoolEvents.destroy,
max,
'./tests/worker-files/thread/testWorker.mjs',
{
+ startWorkers: false,
workerChoiceStrategy,
}
)
- expect(pool.starting).toBe(false)
- expect(pool.readyEventEmitted).toBe(false)
for (let run = 0; run < 2; run++) {
+ expect(pool.info.started).toBe(false)
+ expect(pool.info.ready).toBe(false)
+ pool.start()
+ expect(pool.info.started).toBe(true)
+ expect(pool.info.ready).toBe(true)
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
run % 2 !== 0 && pool.enableTasksQueue(true)
const maxMultiplier = 4
promises.add(pool.execute())
}
await Promise.all(promises)
- expect(pool.readyEventEmitted).toBe(true)
expect(pool.workerNodes.length).toBeGreaterThan(pool.info.minSize)
expect(pool.workerNodes.length).toBeLessThanOrEqual(pool.info.maxSize)
await waitPoolEvents(pool, PoolEvents.empty, 1)
- expect(pool.readyEventEmitted).toBe(false)
expect(pool.workerNodes.length).toBe(pool.info.minSize)
+ // We need to clean up the resources after our test
+ await pool.destroy()
}
- // We need to clean up the resources after our test
- await pool.destroy()
}
})
})
])
await pool.destroy()
const numberOfExitEvents = await exitPromise
- expect(pool.started).toBe(false)
+ expect(pool.info.started).toBe(false)
expect(pool.emitter.eventNames()).toStrictEqual([
PoolEvents.busy,
PoolEvents.destroy,