repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: make IWRR strategy worker readiness aware
[poolifier.git]
/
tests
/
pools
/
selection-strategies
/
selection-strategies.test.js
diff --git
a/tests/pools/selection-strategies/selection-strategies.test.js
b/tests/pools/selection-strategies/selection-strategies.test.js
index 6671b57781b1f51c15bdf0717f3c96cafcf0ca76..535f5f974559ab7748ac885c476f064084e148e6 100644
(file)
--- a/
tests/pools/selection-strategies/selection-strategies.test.js
+++ b/
tests/pools/selection-strategies/selection-strategies.test.js
@@
-3,9
+3,11
@@
const {
DynamicThreadPool,
FixedClusterPool,
FixedThreadPool,
DynamicThreadPool,
FixedClusterPool,
FixedThreadPool,
+ PoolEvents,
WorkerChoiceStrategies
} = require('../../../lib')
const { CircularArray } = require('../../../lib/circular-array')
WorkerChoiceStrategies
} = require('../../../lib')
const { CircularArray } = require('../../../lib/circular-array')
+const { waitPoolEvents } = require('../../test-utils')
describe('Selection strategies test suite', () => {
const min = 0
describe('Selection strategies test suite', () => {
const min = 0
@@
-1715,6
+1717,9
@@
describe('Selection strategies test suite', () => {
WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
}
)
WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
}
)
+ if (!pool.info.ready) {
+ await waitPoolEvents(pool, PoolEvents.ready, 1)
+ }
// TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
const maxMultiplier = 2
// TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
const maxMultiplier = 2
@@
-1785,6
+1790,9
@@
describe('Selection strategies test suite', () => {
WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
}
)
WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
}
)
+ if (!pool.info.ready) {
+ await waitPoolEvents(pool, PoolEvents.ready, 1)
+ }
// TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
const maxMultiplier = 2
// TODO: Create a better test to cover `InterleavedWeightedRoundRobinWorkerChoiceStrategy#choose`
const promises = new Set()
const maxMultiplier = 2
@@
-1795,7
+1803,7
@@
describe('Selection strategies test suite', () => {
for (const workerNode of pool.workerNodes) {
expect(workerNode.usage).toStrictEqual({
tasks: {
for (const workerNode of pool.workerNodes) {
expect(workerNode.usage).toStrictEqual({
tasks: {
- executed:
maxMultiplier
,
+ executed:
expect.any(Number)
,
executing: 0,
queued: 0,
maxQueued: 0,
executing: 0,
queued: 0,
maxQueued: 0,
@@
-1831,7
+1839,7
@@
describe('Selection strategies test suite', () => {
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
).nextWorkerNodeKey
- ).toBe(
0
)
+ ).toBe(
1
)
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy
expect(
pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
pool.workerChoiceStrategyContext.workerChoiceStrategy