repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updartes
[poolifier.git]
/
tests
/
pools
/
abstract-pool.test.mjs
diff --git
a/tests/pools/abstract-pool.test.mjs
b/tests/pools/abstract-pool.test.mjs
index ccd2423102427a40878faf2ee347aa20f3f58964..89cc8995033c12c55f64e4cf8f1c7b1d59d66f42 100644
(file)
--- a/
tests/pools/abstract-pool.test.mjs
+++ b/
tests/pools/abstract-pool.test.mjs
@@
-1,10
+1,14
@@
+import { createHook, executionAsyncId } from 'node:async_hooks'
import { EventEmitterAsyncResource } from 'node:events'
import { EventEmitterAsyncResource } from 'node:events'
-import { dirname, join } from 'node:path'
import { readFileSync } from 'node:fs'
import { readFileSync } from 'node:fs'
+import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { fileURLToPath } from 'node:url'
-import { createHook, executionAsyncId } from 'node:async_hooks'
+
import { expect } from 'expect'
import { restore, stub } from 'sinon'
import { expect } from 'expect'
import { restore, stub } from 'sinon'
+
+import { CircularArray } from '../../lib/circular-array.cjs'
+import { Deque } from '../../lib/deque.cjs'
import {
DynamicClusterPool,
DynamicThreadPool,
import {
DynamicClusterPool,
DynamicThreadPool,
@@
-15,11
+19,9
@@
import {
WorkerChoiceStrategies,
WorkerTypes
} from '../../lib/index.cjs'
WorkerChoiceStrategies,
WorkerTypes
} from '../../lib/index.cjs'
-import { CircularArray } from '../../lib/circular-array.cjs'
-import { Deque } from '../../lib/deque.cjs'
+import { WorkerNode } from '../../lib/pools/worker-node.cjs'
import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs'
import { waitPoolEvents } from '../test-utils.cjs'
import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs'
import { waitPoolEvents } from '../test-utils.cjs'
-import { WorkerNode } from '../../lib/pools/worker-node.cjs'
describe('Abstract pool test suite', () => {
const version = JSON.parse(
describe('Abstract pool test suite', () => {
const version = JSON.parse(
@@
-221,6
+223,7
@@
describe('Abstract pool test suite', () => {
'./tests/worker-files/thread/testWorker.mjs'
)
expect(pool.emitter).toBeInstanceOf(EventEmitterAsyncResource)
'./tests/worker-files/thread/testWorker.mjs'
)
expect(pool.emitter).toBeInstanceOf(EventEmitterAsyncResource)
+ expect(pool.emitter.eventNames()).toStrictEqual([])
expect(pool.opts).toStrictEqual({
startWorkers: true,
enableEvents: true,
expect(pool.opts).toStrictEqual({
startWorkers: true,
enableEvents: true,
@@
-703,6
+706,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: 0,
minSize: numberOfWorkers,
maxSize: numberOfWorkers,
workerNodes: numberOfWorkers,
minSize: numberOfWorkers,
maxSize: numberOfWorkers,
workerNodes: numberOfWorkers,
@@
-725,6
+729,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: 0,
minSize: Math.floor(numberOfWorkers / 2),
maxSize: numberOfWorkers,
workerNodes: Math.floor(numberOfWorkers / 2),
minSize: Math.floor(numberOfWorkers / 2),
maxSize: numberOfWorkers,
workerNodes: Math.floor(numberOfWorkers / 2),
@@
-861,8
+866,8
@@
describe('Abstract pool test suite', () => {
)
expect(pool.info.started).toBe(false)
expect(pool.info.ready).toBe(false)
)
expect(pool.info.started).toBe(false)
expect(pool.info.ready).toBe(false)
- expect(pool.readyEventEmitted).toBe(false)
expect(pool.workerNodes).toStrictEqual([])
expect(pool.workerNodes).toStrictEqual([])
+ expect(pool.readyEventEmitted).toBe(false)
await expect(pool.execute()).rejects.toThrow(
new Error('Cannot execute a task on not started pool')
)
await expect(pool.execute()).rejects.toThrow(
new Error('Cannot execute a task on not started pool')
)
@@
-1074,6
+1079,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
@@
-1114,6
+1120,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
@@
-1153,6
+1160,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
@@
-1195,6
+1203,7
@@
describe('Abstract pool test suite', () => {
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
started: true,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,
+ strategyRetries: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
minSize: expect.any(Number),
maxSize: expect.any(Number),
workerNodes: expect.any(Number),
@@
-1239,7
+1248,7
@@
describe('Abstract pool test suite', () => {
const elapsedTime = performance.now() - startTime
expect(tasksFinished).toBeLessThanOrEqual(numberOfWorkers * maxMultiplier)
expect(elapsedTime).toBeGreaterThanOrEqual(2000)
const elapsedTime = performance.now() - startTime
expect(tasksFinished).toBeLessThanOrEqual(numberOfWorkers * maxMultiplier)
expect(elapsedTime).toBeGreaterThanOrEqual(2000)
- expect(elapsedTime).toBeLessThanOrEqual(tasksFinishedTimeout +
4
00)
+ expect(elapsedTime).toBeLessThanOrEqual(tasksFinishedTimeout +
8
00)
})
it('Verify that destroy() waits until the tasks finished timeout is reached', async () => {
})
it('Verify that destroy() waits until the tasks finished timeout is reached', async () => {