From 3d6f0f7377c842be430708f7fe2b2d8a33d57e3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 20 Dec 2023 15:30:39 +0100 Subject: [PATCH] fix: put back properties init in constructor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../abstract-worker-choice-strategy.ts | 7 +++++- ...hted-round-robin-worker-choice-strategy.ts | 4 +++- tests/pools/abstract-pool.test.mjs | 22 +++++-------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 91733b52..fe8c7543 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -57,7 +57,12 @@ export abstract class AbstractWorkerChoiceStrategy< protected readonly pool: IPool, protected opts: InternalWorkerChoiceStrategyOptions ) { - this.setOptions(this.opts) + // this.setOptions(this.opts) + this.opts = buildInternalWorkerChoiceStrategyOptions( + this.pool.info.maxSize, + this.opts + ) + this.setTaskStatisticsRequirements(this.opts) this.choose = this.choose.bind(this) } diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 0f718e98..fe6bbb73 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -56,7 +56,9 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< opts: InternalWorkerChoiceStrategyOptions ) { super(pool, opts) - this.setOptions(this.opts) + // this.setOptions(this.opts) + this.setTaskStatisticsRequirements(this.opts) + this.roundWeights = this.getRoundWeights() } /** @inheritDoc */ diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 6bb6e1a6..12e1a530 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -249,11 +249,11 @@ describe('Abstract pool test suite', () => { Object.keys(workerChoiceStrategy.opts.weights).length, runTime: { median: false }, waitTime: { median: false }, - elu: { median: false } - // weights: expect.objectContaining({ - // 0: expect.any(Number), - // [pool.info.maxSize - 1]: expect.any(Number) - // }) + elu: { median: false }, + weights: expect.objectContaining({ + 0: expect.any(Number), + [pool.info.maxSize - 1]: expect.any(Number) + }) }) ) } @@ -494,10 +494,6 @@ describe('Abstract pool test suite', () => { runTime: { median: false }, waitTime: { median: false }, elu: { median: false } - // weights: expect.objectContaining({ - // 0: expect.any(Number), - // [pool.info.maxSize - 1]: expect.any(Number) - // }) }) ) } @@ -550,10 +546,6 @@ describe('Abstract pool test suite', () => { runTime: { median: true }, waitTime: { median: false }, elu: { median: true } - // weights: expect.objectContaining({ - // 0: expect.any(Number), - // [pool.info.maxSize - 1]: expect.any(Number) - // }) }) ) } @@ -606,10 +598,6 @@ describe('Abstract pool test suite', () => { runTime: { median: false }, waitTime: { median: false }, elu: { median: false } - // weights: expect.objectContaining({ - // 0: expect.any(Number), - // [pool.info.maxSize - 1]: expect.any(Number) - // }) }) ) } -- 2.34.1