From: Jérôme Benoit Date: Tue, 7 May 2024 12:29:47 +0000 (+0200) Subject: test: improve task statistic requirements coverage X-Git-Tag: v4.0.3~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b2940269c5ec28e8757fc775a3a8b9940fdbbc13;p=poolifier.git test: improve task statistic requirements coverage Signed-off-by: Jérôme Benoit --- diff --git a/docs/api.md b/docs/api.md index 1b888173..634ab08b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -99,7 +99,7 @@ An object with these properties: - `WorkerChoiceStrategies.ROUND_ROBIN`: Submit tasks to worker in a round robin fashion - `WorkerChoiceStrategies.LEAST_USED`: Submit tasks to the worker with the minimum number of executing and queued tasks - - `WorkerChoiceStrategies.LEAST_BUSY`: Submit tasks to the worker with the minimum tasks total execution and wait time + - `WorkerChoiceStrategies.LEAST_BUSY`: Submit tasks to the worker with the minimum tasks execution time - `WorkerChoiceStrategies.LEAST_ELU`: Submit tasks to the worker with the minimum event loop utilization (ELU) - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN`: Submit tasks to worker by using a [weighted round robin scheduling algorithm](./worker-choice-strategies.md#weighted-round-robin) based on tasks execution time - `WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN`: Submit tasks to worker by using an [interleaved weighted round robin scheduling algorithm](./worker-choice-strategies.md#interleaved-weighted-round-robin-experimental) based on tasks execution time (experimental) diff --git a/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs b/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs index 8fcd90b2..aeb7db17 100644 --- a/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs +++ b/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs @@ -417,7 +417,8 @@ describe('Worker choice strategies context test suite', () => { fixedPool, [wwrWorkerChoiceStrategy], { - runTime: { median: true } + runTime: { median: true }, + waitTime: { median: true } } ) expect( @@ -428,11 +429,20 @@ describe('Worker choice strategies context test suite', () => { workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime .median ).toBe(true) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .average + ).toBe(false) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .median + ).toBe(true) workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext( dynamicPool, [wwrWorkerChoiceStrategy], { - runTime: { median: true } + runTime: { median: true }, + waitTime: { median: true } } ) expect( @@ -443,12 +453,21 @@ describe('Worker choice strategies context test suite', () => { workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime .median ).toBe(true) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .average + ).toBe(false) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .median + ).toBe(true) const fsWorkerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext( fixedPool, [fsWorkerChoiceStrategy], { - runTime: { median: true } + runTime: { median: true }, + waitTime: { median: true } } ) expect( @@ -459,11 +478,20 @@ describe('Worker choice strategies context test suite', () => { workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime .median ).toBe(true) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .average + ).toBe(false) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .median + ).toBe(true) workerChoiceStrategiesContext = new WorkerChoiceStrategiesContext( dynamicPool, [fsWorkerChoiceStrategy], { - runTime: { median: true } + runTime: { median: true }, + waitTime: { median: true } } ) expect( @@ -474,5 +502,13 @@ describe('Worker choice strategies context test suite', () => { workerChoiceStrategiesContext.getTaskStatisticsRequirements().runTime .median ).toBe(true) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .average + ).toBe(false) + expect( + workerChoiceStrategiesContext.getTaskStatisticsRequirements().waitTime + .median + ).toBe(true) }) })