kaxil opened a new pull request, #68261: URL: https://github.com/apache/airflow/pull/68261
The `api_fastapi` test fixtures (`test_client`, `unauthenticated_test_client`, `unauthorized_test_client`) rebuilt the entire FastAPI app via `create_app()` on every test. Each rebuild constructs two mounted apps (core + execution), registers every route, and builds the OpenAPI schema, costing roughly 0.55s of setup per test. With thousands of api_fastapi tests that setup dominates the suite, and the MySQL `DB-core ... API...CLI` shard had crept to ~62 min against the 65-min job timeout, so PR runs were getting cancelled mid-suite. The app structure is identical for the default client (the fixture pins `[core] auth_manager` to `SimpleAuthManager`), so this builds it once per session and reuses it. Only per-test DB state and request data differ. ## Impact (measured on MySQL via breeze) Representative subset (`test_variables` + `test_pools` + `test_connections`, 289 tests): | | Before | After | |---|---|---| | Wall time | 183.1s | 69.7s (-62%) | | Per-test setup | ~0.55s | ~0.17s (-70%) | Extrapolated across the api_fastapi suite (~3,000 collected tests) this is roughly 15-19 min off the `API...CLI` shard, restoring headroom under the job timeout. Postgres benefits equally. ## Test isolation A shared app means per-test mutations are no longer discarded with the app, so `_reset_shared_app()` runs on every client fixture entry: - **auth manager**: the auth endpoint tests replace `app.state.auth_manager` with a mock and never restore it. Without the reset the next client reads the mock during token generation and every following test fails with 401 (verified by reverting the reset: a passing subset turns into 64 failures). - **dependency overrides**: a few route tests (extra links, tasks, logs) install a `dag_bag_from_app` override in their per-test setup. These are self-healing today because they wrap a DB-backed `DBDagBag`, but the overrides are cleared on reset to guard against a future non-DB override leaking across tests. `execution_api` tests are unaffected: they build their own app via `cached_app(apps="execution")` and pop their own overrides. Validated by running the override and auth mutators ordered ahead of their victims (`test_auth`, `test_extra_links`, `test_tasks`, `test_log`, then `test_dags`, `test_xcom`, `test_variables`) plus the config and asset/task store route tests, all passing. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
