fix: fix error message after worker choice strategies failure
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 18 Aug 2023 14:32:29 +0000 (16:32 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 18 Aug 2023 14:32:29 +0000 (16:32 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/worker-choice-strategy-context.ts
tests/pools/selection-strategies/worker-choice-strategy-context.test.js

index 8c5a9587debbd4b66fba9a7630838fcc44cabc3c..fefc1275f5cb7fbacf72d689dfaf8140a733ffac 100644 (file)
@@ -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
   }
index 808a44cb096b77894b0ad34fd3a1c865091c0722..63e58d57ed3a9bec4ce6d92c61283379385f2a04 100644 (file)
@@ -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'
+      )
     )
   })