From b2940269c5ec28e8757fc775a3a8b9940fdbbc13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 7 May 2024 14:29:47 +0200 Subject: [PATCH] test: improve task statistic requirements coverage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- docs/api.md | 2 +- .../worker-choice-strategies-context.test.mjs | 44 +++++++++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) 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) }) }) -- 2.34.1