if (this.emitter != null) {
this.emitter.emit(PoolEvents.error, error)
}
- if (this.opts.enableTasksQueue === true) {
- this.redistributeQueuedTasks(worker)
- }
if (this.opts.restartWorkerOnError === true && !this.starting) {
if (this.getWorkerInfo(this.getWorkerNodeKey(worker)).dynamic) {
this.createAndSetupDynamicWorker()
this.createAndSetupWorker()
}
}
+ if (this.opts.enableTasksQueue === true) {
+ this.redistributeQueuedTasks(worker)
+ }
})
worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
worker.on('exit', this.opts.exitHandler ?? EMPTY_FUNCTION)
}
await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
- expect(workerNode.usage).toStrictEqual({
+ expect(workerNode.usage).toMatchObject({
tasks: {
executed: expect.any(Number),
executing: 0,
failed: 0
},
runTime: {
- aggregate: expect.any(Number),
- maximum: expect.any(Number),
- minimum: expect.any(Number),
history: expect.any(CircularArray)
},
waitTime: {
- aggregate: expect.any(Number),
- maximum: expect.any(Number),
- minimum: expect.any(Number),
history: expect.any(CircularArray)
},
elu: {
expect(workerNode.usage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.usage.runTime.aggregate).toBeGreaterThanOrEqual(0)
- expect(workerNode.usage.waitTime.aggregate).toBeGreaterThanOrEqual(0)
+ if (workerNode.usage.runTime.aggregate == null) {
+ expect(workerNode.usage.runTime.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.runTime.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.waitTime.aggregate == null) {
+ expect(workerNode.usage.waitTime.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.waitTime.aggregate).toBeGreaterThan(0)
+ }
}
// We need to clean up the resources after our test
await pool.destroy()
}
await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
- expect(workerNode.usage).toStrictEqual({
+ expect(workerNode.usage).toMatchObject({
tasks: {
executed: expect.any(Number),
executing: 0,
failed: 0
},
runTime: {
- aggregate: expect.any(Number),
- maximum: expect.any(Number),
- minimum: expect.any(Number),
history: expect.any(CircularArray)
},
waitTime: {
- aggregate: expect.any(Number),
- maximum: expect.any(Number),
- minimum: expect.any(Number),
history: expect.any(CircularArray)
},
elu: {
expect(workerNode.usage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.usage.runTime.aggregate).toBeGreaterThanOrEqual(0)
- expect(workerNode.usage.waitTime.aggregate).toBeGreaterThanOrEqual(0)
+ if (workerNode.usage.runTime.aggregate == null) {
+ expect(workerNode.usage.runTime.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.runTime.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.waitTime.aggregate == null) {
+ expect(workerNode.usage.waitTime.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.waitTime.aggregate).toBeGreaterThan(0)
+ }
}
// We need to clean up the resources after our test
await pool.destroy()