expect(pool.starting).toBe(false)
expect(pool.started).toBe(true)
await pool.destroy()
- expect(pool.started).toBe(false)
})
it('Verify that filePath is checked', () => {
)
expect(
() =>
- new DynamicClusterPool(
- 1,
- 1,
- './tests/worker-files/cluster/testWorker.js'
- )
+ new DynamicThreadPool(0, 0, './tests/worker-files/thread/testWorker.js')
).toThrowError(
new RangeError(
- 'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
+ 'Cannot instantiate a dynamic pool with a maximum pool size equal to zero'
)
)
expect(
() =>
- new DynamicThreadPool(0, 0, './tests/worker-files/thread/testWorker.js')
+ new DynamicClusterPool(
+ 1,
+ 1,
+ './tests/worker-files/cluster/testWorker.js'
+ )
).toThrowError(
new RangeError(
- 'Cannot instantiate a dynamic pool with a maximum pool size equal to zero'
+ 'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
)
)
})
WorkerChoiceStrategies.ROUND_ROBIN
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
WorkerChoiceStrategies.LEAST_USED
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: true },
waitTime: { median: false },
elu: { median: false },
weights: { 0: 300, 1: 200 }
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: true },
waitTime: { median: false },
elu: { median: false },
'./tests/worker-files/thread/testWorker.js',
{
workerChoiceStrategyOptions: {
- choiceRetries: 'invalidChoiceRetries'
+ retries: 'invalidChoiceRetries'
}
}
)
).toThrowError(
new TypeError(
- 'Invalid worker choice strategy options: choice retries must be an integer'
+ 'Invalid worker choice strategy options: retries must be an integer'
)
)
expect(
'./tests/worker-files/thread/testWorker.js',
{
workerChoiceStrategyOptions: {
- choiceRetries: -1
+ retries: -1
}
}
)
).toThrowError(
new RangeError(
- "Invalid worker choice strategy options: choice retries '-1' must be greater or equal than zero"
+ "Invalid worker choice strategy options: retries '-1' must be greater or equal than zero"
)
)
expect(
{ workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
elu: { median: true }
})
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: true },
waitTime: { median: false },
elu: { median: true }
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: true },
waitTime: { median: false },
elu: { median: true }
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: true },
waitTime: { median: false },
elu: { median: true }
elu: { median: false }
})
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
})
expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({
- choiceRetries: 6,
+ retries: 6,
runTime: { median: false },
waitTime: { median: false },
elu: { median: false }
)
expect(() =>
pool.setWorkerChoiceStrategyOptions({
- choiceRetries: 'invalidChoiceRetries'
+ retries: 'invalidChoiceRetries'
})
).toThrowError(
new TypeError(
- 'Invalid worker choice strategy options: choice retries must be an integer'
+ 'Invalid worker choice strategy options: retries must be an integer'
)
)
expect(() =>
- pool.setWorkerChoiceStrategyOptions({ choiceRetries: -1 })
+ pool.setWorkerChoiceStrategyOptions({ retries: -1 })
).toThrowError(
new RangeError(
- "Invalid worker choice strategy options: choice retries '-1' must be greater or equal than zero"
+ "Invalid worker choice strategy options: retries '-1' must be greater or equal than zero"
)
)
expect(() =>
expect(workerNode.tasksQueue.size).toBe(0)
expect(workerNode.tasksQueue.maxSize).toBe(0)
}
+ await pool.destroy()
})
it('Verify that pool worker info are initialized', async () => {
ready: true
})
}
+ await pool.destroy()
})
it('Verify that pool execute() arguments are checked', async () => {