From 4ba8492f17b13668853cfc15a1ec9ff8c8d7b179 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 18 Aug 2023 16:32:29 +0200 Subject: [PATCH] fix: fix error message after worker choice strategies failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../worker-choice-strategy-context.ts | 4 +++- .../worker-choice-strategy-context.test.js | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 8c5a9587..fefc1275 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -183,7 +183,9 @@ export class WorkerChoiceStrategyContext< this.choiceRetriesCount++ return this.execute() } else if (workerNodeKey == null) { - throw new TypeError('Worker node key chosen is null or undefined') + throw new TypeError( + `Worker node key chosen is null or undefined after ${this.choiceRetriesCount} retries` + ) } return workerNodeKey } diff --git a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js index 808a44cb..63e58d57 100644 --- a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js +++ b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js @@ -91,7 +91,7 @@ describe('Worker choice strategy context test suite', () => { expect(chosenWorkerKey).toBe(0) }) - it('Verify that execute() throws error if null or undefined is returned', () => { + it('Verify that execute() throws error if null or undefined is returned after retries', () => { const workerChoiceStrategyContext = new WorkerChoiceStrategyContext( fixedPool ) @@ -115,14 +115,18 @@ describe('Worker choice strategy context test suite', () => { WorkerChoiceStrategyUndefinedStub ) expect(() => workerChoiceStrategyContext.execute()).toThrowError( - new TypeError('Worker node key chosen is null or undefined') + new TypeError( + 'Worker node key chosen is null or undefined after 6 retries' + ) ) workerChoiceStrategyContext.workerChoiceStrategies.set( workerChoiceStrategyContext.workerChoiceStrategy, WorkerChoiceStrategyNullStub ) expect(() => workerChoiceStrategyContext.execute()).toThrowError( - new TypeError('Worker node key chosen is null or undefined') + new TypeError( + 'Worker node key chosen is null or undefined after 6 retries' + ) ) }) -- 2.34.1