let leastEluWorkerNodeKey!: number
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
const workerUsage = workerNode.workerUsage
- const workerElu = workerUsage.elu?.utilization ?? 0
+ const workerElu = workerUsage.elu?.active ?? 0
if (workerElu === 0) {
return workerNodeKey
} else if (workerElu < minWorkerElu) {
FixedClusterPool
} = require('../../../lib')
const { CircularArray } = require('../../../lib/circular-array')
-const TestUtils = require('../../test-utils')
describe('Selection strategies test suite', () => {
const min = 0
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_ELU }
)
// TODO: Create a better test to cover `LeastEluWorkerChoiceStrategy#choose`
+ const promises = new Set()
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
- if (i !== max * maxMultiplier - 1) await TestUtils.sleep(500)
+ promises.add(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
const expectedWorkerUsage = {
tasks: {
{ workerChoiceStrategy: WorkerChoiceStrategies.LEAST_ELU }
)
// TODO: Create a better test to cover `LeastEluWorkerChoiceStrategy#choose`
+ const promises = new Set()
const maxMultiplier = 2
for (let i = 0; i < max * maxMultiplier; i++) {
- await pool.execute()
- if (i !== max * maxMultiplier - 1) await TestUtils.sleep(500)
+ promises.add(pool.execute())
}
+ await Promise.all(promises)
for (const workerNode of pool.workerNodes) {
const expectedWorkerUsage = {
tasks: {