executingTasks: expect.any(Number),
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: Math.floor(numberOfWorkers / 2),
ready: true,
started: true,
strategyRetries: expect.any(Number),
type: PoolTypes.dynamic,
version,
worker: WorkerTypes.cluster,
- workerNodes: expect.any(Number),
+ workerNodes: Math.floor(numberOfWorkers / 2),
})
await pool.destroy()
})
executingTasks: expect.any(Number),
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: numberOfWorkers,
ready: true,
started: true,
strategyRetries: expect.any(Number),
type: PoolTypes.fixed,
version,
worker: WorkerTypes.thread,
- workerNodes: expect.any(Number),
+ workerNodes: numberOfWorkers,
})
expect(poolBusyEnd).toBe(1)
expect(poolBusyEndInfo).toStrictEqual({
executingTasks: expect.any(Number),
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: numberOfWorkers,
ready: true,
started: true,
strategyRetries: expect.any(Number),
type: PoolTypes.fixed,
version,
worker: WorkerTypes.thread,
- workerNodes: expect.any(Number),
+ workerNodes: numberOfWorkers,
})
await pool.destroy()
})
- it("Verify that pool event emitter 'full' event can register a callback", async () => {
+ it("Verify that pool event emitter 'full' and 'fullEnd' events can register a callback", async () => {
const pool = new DynamicClusterPool(
Math.floor(numberOfWorkers / 2),
numberOfWorkers,
expect(pool.emitter.eventNames()).toStrictEqual([])
const promises = new Set()
let poolFull = 0
- let poolInfo
+ let poolFullInfo
pool.emitter.on(PoolEvents.full, info => {
++poolFull
- poolInfo = info
+ poolFullInfo = info
})
- expect(pool.emitter.eventNames()).toStrictEqual([PoolEvents.full])
+ let poolFullEnd = 0
+ let poolFullEndInfo
+ pool.emitter.on(PoolEvents.fullEnd, info => {
+ ++poolFullEnd
+ poolFullEndInfo = info
+ })
+ expect(pool.emitter.eventNames()).toStrictEqual([
+ PoolEvents.full,
+ PoolEvents.fullEnd,
+ ])
for (let i = 0; i < numberOfWorkers * 2; i++) {
promises.add(pool.execute())
}
await Promise.all(promises)
expect(poolFull).toBe(1)
- expect(poolInfo).toStrictEqual({
+ expect(poolFullInfo).toStrictEqual({
busyWorkerNodes: expect.any(Number),
defaultStrategy: WorkerChoiceStrategies.ROUND_ROBIN,
executedTasks: expect.any(Number),
executingTasks: expect.any(Number),
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: Math.floor(numberOfWorkers / 2),
ready: true,
started: true,
strategyRetries: expect.any(Number),
type: PoolTypes.dynamic,
version,
worker: WorkerTypes.cluster,
- workerNodes: expect.any(Number),
+ workerNodes: numberOfWorkers,
+ })
+ await waitPoolEvents(pool, PoolEvents.fullEnd, 1)
+ expect(poolFullEnd).toBe(1)
+ expect(poolFullEndInfo).toStrictEqual({
+ busyWorkerNodes: expect.any(Number),
+ defaultStrategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ executedTasks: expect.any(Number),
+ executingTasks: expect.any(Number),
+ failedTasks: expect.any(Number),
+ idleWorkerNodes: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: Math.floor(numberOfWorkers / 2),
+ ready: true,
+ started: true,
+ strategyRetries: expect.any(Number),
+ type: PoolTypes.dynamic,
+ version,
+ worker: WorkerTypes.cluster,
+ workerNodes: Math.floor(numberOfWorkers / 2),
})
await pool.destroy()
})
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
maxQueuedTasks: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: numberOfWorkers,
queuedTasks: expect.any(Number),
ready: true,
started: true,
type: PoolTypes.fixed,
version,
worker: WorkerTypes.thread,
- workerNodes: expect.any(Number),
+ workerNodes: numberOfWorkers,
})
expect(poolBackPressureEnd).toBe(1)
expect(poolBackPressureEndInfo).toStrictEqual({
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
maxQueuedTasks: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: numberOfWorkers,
queuedTasks: expect.any(Number),
ready: true,
started: true,
type: PoolTypes.fixed,
version,
worker: WorkerTypes.thread,
- workerNodes: expect.any(Number),
+ workerNodes: numberOfWorkers,
})
await pool.destroy()
})
executingTasks: expect.any(Number),
failedTasks: expect.any(Number),
idleWorkerNodes: expect.any(Number),
- maxSize: expect.any(Number),
- minSize: expect.any(Number),
+ maxSize: numberOfWorkers,
+ minSize: 0,
ready: true,
started: true,
strategyRetries: expect.any(Number),
type: PoolTypes.dynamic,
version,
worker: WorkerTypes.cluster,
- workerNodes: expect.any(Number),
+ workerNodes: 0,
})
await pool.destroy()
})