From d20326b9ea54ad11c1cba0fc3154db2d93e7ca87 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Tue, 4 Jun 2024 10:35:05 +0200 Subject: [PATCH] e2e: exclude warmup results from final measurements --- tests/e2e/server/index.ts | 11 +++++++++++ tests/e2e/testRunner.ts | 3 +++ 2 files changed, 14 insertions(+) diff --git a/tests/e2e/server/index.ts b/tests/e2e/server/index.ts index 52e50fefc0ae..68367aa29c2a 100644 --- a/tests/e2e/server/index.ts +++ b/tests/e2e/server/index.ts @@ -28,6 +28,7 @@ type ServerInstance = { addTestResultListener: AddListener; addTestDoneListener: AddListener; forceTestCompletion: () => void; + setReadyToAcceptTestResults: (isReady: boolean) => void; start: () => Promise; stop: () => Promise; }; @@ -96,6 +97,11 @@ const createServerInstance = (): ServerInstance => { const [testStartedListeners, addTestStartedListener] = createListenerState(); const [testResultListeners, addTestResultListener] = createListenerState(); const [testDoneListeners, addTestDoneListener] = createListenerState(); + let isReadyToAcceptTestResults = true; + + const setReadyToAcceptTestResults = (isReady: boolean) => { + isReadyToAcceptTestResults = isReady; + }; const forceTestCompletion = () => { testDoneListeners.forEach((listener) => { @@ -122,6 +128,10 @@ const createServerInstance = (): ServerInstance => { } case Routes.testResults: { + if (!isReadyToAcceptTestResults) { + return res.end('ok'); + } + getPostJSONRequestData(req, res)?.then((data) => { if (!data) { // The getPostJSONRequestData function already handled the response @@ -201,6 +211,7 @@ const createServerInstance = (): ServerInstance => { }); return { + setReadyToAcceptTestResults, setTestConfig, addTestStartedListener, addTestResultListener, diff --git a/tests/e2e/testRunner.ts b/tests/e2e/testRunner.ts index fcf93d525f8e..f2f4d6290e31 100644 --- a/tests/e2e/testRunner.ts +++ b/tests/e2e/testRunner.ts @@ -178,6 +178,7 @@ const runTests = async (): Promise => { await sleep(config.BOOT_COOL_DOWN); server.setTestConfig(test as TestConfig); + server.setReadyToAcceptTestResults(false); const warmupText = `Warmup for test '${test.name}' [${testIndex + 1}/${tests.length}]`; @@ -193,6 +194,8 @@ const runTests = async (): Promise => { await runTestIteration(config.DELTA_APP_PACKAGE, `[DELTA] ${warmupText}. Iteration ${i + 1}/${iterations}`); } + server.setReadyToAcceptTestResults(true); + // For each test case we allow the test to fail three times before we stop the test run: const errorCountRef = { errorCount: 0,