Skip to content

Commit

Permalink
e2e: exclude warmup results from final measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Jun 4, 2024
1 parent 1d5f83d commit d20326b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/e2e/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ServerInstance = {
addTestResultListener: AddListener<TestResultListener>;
addTestDoneListener: AddListener<TestDoneListener>;
forceTestCompletion: () => void;
setReadyToAcceptTestResults: (isReady: boolean) => void;
start: () => Promise<void>;
stop: () => Promise<Error | undefined>;
};
Expand Down Expand Up @@ -96,6 +97,11 @@ const createServerInstance = (): ServerInstance => {
const [testStartedListeners, addTestStartedListener] = createListenerState<TestStartedListener>();
const [testResultListeners, addTestResultListener] = createListenerState<TestResultListener>();
const [testDoneListeners, addTestDoneListener] = createListenerState<TestDoneListener>();
let isReadyToAcceptTestResults = true;

const setReadyToAcceptTestResults = (isReady: boolean) => {
isReadyToAcceptTestResults = isReady;
};

const forceTestCompletion = () => {
testDoneListeners.forEach((listener) => {
Expand All @@ -122,6 +128,10 @@ const createServerInstance = (): ServerInstance => {
}

case Routes.testResults: {
if (!isReadyToAcceptTestResults) {
return res.end('ok');
}

getPostJSONRequestData<TestResult>(req, res)?.then((data) => {
if (!data) {
// The getPostJSONRequestData function already handled the response
Expand Down Expand Up @@ -201,6 +211,7 @@ const createServerInstance = (): ServerInstance => {
});

return {
setReadyToAcceptTestResults,
setTestConfig,
addTestStartedListener,
addTestResultListener,
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const runTests = async (): Promise<void> => {
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}]`;

Expand All @@ -193,6 +194,8 @@ const runTests = async (): Promise<void> => {
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,
Expand Down

0 comments on commit d20326b

Please sign in to comment.