const { expect } = require('expect')
const {
+ DynamicClusterPool,
DynamicThreadPool,
FixedClusterPool,
FixedThreadPool,
expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
workerChoiceStrategy
)
+ expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
+ retries: 6,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
+ retries: 6,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ await pool.destroy()
+ }
+ for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
+ const pool = new DynamicClusterPool(
+ min,
+ max,
+ './tests/worker-files/cluster/testWorker.js'
+ )
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy, { retries: 3 })
+ expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
+ expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
+ retries: 3,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
+ retries: 3,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
await pool.destroy()
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
history: expect.any(CircularArray)
},
elu: {
- idle: expect.objectContaining({
+ idle: {
history: expect.any(CircularArray)
- }),
- active: expect.objectContaining({
+ },
+ active: {
history: expect.any(CircularArray)
- })
+ }
}
})
expect(workerNode.usage.tasks.executed).toBeGreaterThanOrEqual(0)
expect(workerNode.usage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
+ if (workerNode.usage.elu.active.aggregate == null) {
+ expect(workerNode.usage.elu.active.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.active.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.elu.idle.aggregate == null) {
+ expect(workerNode.usage.elu.idle.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.idle.aggregate).toBeGreaterThanOrEqual(0)
+ }
if (workerNode.usage.elu.utilization == null) {
expect(workerNode.usage.elu.utilization).toBeUndefined()
} else {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
history: expect.any(CircularArray)
},
elu: {
- idle: expect.objectContaining({
+ idle: {
history: expect.any(CircularArray)
- }),
- active: expect.objectContaining({
+ },
+ active: {
history: expect.any(CircularArray)
- })
+ }
}
})
expect(workerNode.usage.tasks.executed).toBeGreaterThanOrEqual(0)
expect(workerNode.usage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
+ if (workerNode.usage.elu.active.aggregate == null) {
+ expect(workerNode.usage.elu.active.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.active.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.elu.idle.aggregate == null) {
+ expect(workerNode.usage.elu.idle.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.idle.aggregate).toBeGreaterThanOrEqual(0)
+ }
if (workerNode.usage.elu.utilization == null) {
expect(workerNode.usage.elu.utilization).toBeUndefined()
} else {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
- runTime: expect.objectContaining({
+ runTime: {
history: expect.any(CircularArray)
- }),
+ },
waitTime: {
history: expect.any(CircularArray)
},
elu: {
- idle: expect.objectContaining({
+ idle: {
history: expect.any(CircularArray)
- }),
- active: expect.objectContaining({
+ },
+ active: {
history: expect.any(CircularArray)
- })
+ }
}
})
expect(workerNode.usage.tasks.executed).toBeGreaterThanOrEqual(0)
} else {
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
+ if (workerNode.usage.elu.active.aggregate == null) {
+ expect(workerNode.usage.elu.active.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.active.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.elu.idle.aggregate == null) {
+ expect(workerNode.usage.elu.idle.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.idle.aggregate).toBeGreaterThanOrEqual(0)
+ }
if (workerNode.usage.elu.utilization == null) {
expect(workerNode.usage.elu.utilization).toBeUndefined()
} else {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
- runTime: expect.objectContaining({
+ runTime: {
history: expect.any(CircularArray)
- }),
+ },
waitTime: {
history: expect.any(CircularArray)
},
elu: {
- idle: expect.objectContaining({
+ idle: {
history: expect.any(CircularArray)
- }),
- active: expect.objectContaining({
+ },
+ active: {
history: expect.any(CircularArray)
- })
+ }
}
})
expect(workerNode.usage.tasks.executed).toBeGreaterThanOrEqual(0)
} else {
expect(workerNode.usage.runTime.average).toBeGreaterThan(0)
}
+ if (workerNode.usage.elu.active.aggregate == null) {
+ expect(workerNode.usage.elu.active.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.active.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.elu.idle.aggregate == null) {
+ expect(workerNode.usage.elu.idle.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.idle.aggregate).toBeGreaterThanOrEqual(0)
+ }
if (workerNode.usage.elu.utilization == null) {
expect(workerNode.usage.elu.utilization).toBeUndefined()
} else {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
- runTime: expect.objectContaining({
+ runTime: {
history: expect.any(CircularArray)
- }),
+ },
waitTime: {
history: expect.any(CircularArray)
},
elu: {
- idle: expect.objectContaining({
+ idle: {
history: expect.any(CircularArray)
- }),
- active: expect.objectContaining({
+ },
+ active: {
history: expect.any(CircularArray)
- })
+ }
}
})
expect(workerNode.usage.tasks.executed).toBeGreaterThanOrEqual(0)
} else {
expect(workerNode.usage.runTime.median).toBeGreaterThan(0)
}
+ if (workerNode.usage.elu.active.aggregate == null) {
+ expect(workerNode.usage.elu.active.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.active.aggregate).toBeGreaterThan(0)
+ }
+ if (workerNode.usage.elu.idle.aggregate == null) {
+ expect(workerNode.usage.elu.idle.aggregate).toBeUndefined()
+ } else {
+ expect(workerNode.usage.elu.idle.aggregate).toBeGreaterThanOrEqual(0)
+ }
if (workerNode.usage.elu.utilization == null) {
expect(workerNode.usage.elu.utilization).toBeUndefined()
} else {
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: expect.objectContaining({
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: expect.objectContaining({
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: expect.objectContaining({
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})
executing: 0,
queued: 0,
maxQueued: 0,
+ stolen: 0,
failed: 0
},
runTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
waitTime: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
elu: {
idle: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
},
active: {
- history: expect.any(CircularArray)
+ history: new CircularArray()
}
}
})