Fix flaky E2E tests with API-based setup and data isolation#64024
Draft
choo121600 wants to merge 2 commits intoapache:mainfrom
Draft
Fix flaky E2E tests with API-based setup and data isolation#64024choo121600 wants to merge 2 commits intoapache:mainfrom
choo121600 wants to merge 2 commits intoapache:mainfrom
Conversation
2601f28 to
8b472a1
Compare
eb7f956 to
d909103
Compare
b9a46f5 to
91fec17
Compare
f7e1225 to
ca0e788
Compare
ca0e788 to
e39499e
Compare
Contributor
|
Nice! Could we possibly break this up into smaller PRs? It is a lot of changes to review at once. |
Member
Author
|
@bbovenzi Thanks! I agree it's quite large — it currently mixes structural changes with fixes for flaky tests. I’ll split it into smaller PRs soon 😉 |
1 task
8fb0d2a to
42f0a5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
E2E tests have been intermittently failing in CI, causing unreliable builds and frequent reruns, due to two root causes:
beforeAllDate.now(), which can collide when multiple Playwright workers start at the same time. Leftover data from previous runs could also interfere with assertions that assumed exact row counts.This PR makes E2E tests deterministic and reliable by removing UI-driven setup and enforcing strict data isolation.
Change
New shared utilities (
tests/e2e/utils/test-helpers.ts)Replaces fragile UI-based setup with reliable API-driven helpers:
uniqueRunId(prefix)— UUID-based ID generation to prevent cross-worker collisions.waitForDagReady()— PollsGET /api/v2/dags/{id}until the Dag is parsed and available.apiTriggerDagRun()/apiCreateDagRun()/apiSetDagRunState()* — Create and manipulate Dag runs via the API with 409-conflict handling for parallel safety.waitForDagRunStatus()/waitForTaskInstanceState()— Poll until a Dag run or task instance reaches the expected state.apiRespondToHITL()/setupHITLFlowViaAPI()— Drive the full HITL operator flow via API, removing the need for browser-based setup.apiCreateVariable()/apiDeleteVariable()— Variable CRUD.apiCreateBackfill()/apiCancelBackfill()— Backfill lifecycle management with automatic retry on 409.waitForTableLoad()/waitForStableRowCount()— DOM stability helpers for reliable table assertions.Custom Playwright fixtures (
tests/e2e/fixtures.ts)Standardizes test setup and removes boilerplate across all specs:
new PageObject(page)usage in every spec.authenticatedRequest(worker-scoped) provides anAPIRequestContextwith stored auth state, enabling API calls inbeforeAll/afterAllwithout creating a browser context.Spec and Page Object updates (22 specs, 18 page objects)
Every spec file follows the same migration pattern, ensuring consistency:
import { test, expect } from "@playwright/test"-->import { test, expect } from "tests/e2e/fixtures"beforeAllsetup:browser.newContext()+ UI interactions -->authenticatedRequest+ API helper callsDate.now()identifiers -->uniqueRunId()for collision-free IDsafterAllcleanup: tracks created resources and deletes via API(404 treated as success for idempotency)After
beforeAllno longer opens a separatebrowser.newContext()just for seeding data, reducing memory pressure and startup overhead per worker.related: #63036
Was generative AI tooling used to co-author this PR?
claude
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.