Fix flaky SimpleAuthManager login tests under parallel runs#68498
Merged
potiuk merged 1 commit intoJun 13, 2026
Conversation
The SimpleAuthManager tests shared a single generated-password file path under AIRFLOW_HOME across all test processes. Fixtures and tests create, overwrite, and delete that file, so under parallel (xdist) runs one process could delete the file another was mid-read on, raising FileNotFoundError (e.g. test_create_token_invalid_user_password hitting get_passwords). Isolate the password file per test via the existing [core] simple_auth_manager_passwords_file config option, pointing it at a per-test tmp_path so each test (and worker) gets its own file.
potiuk
approved these changes
Jun 13, 2026
imrichardwu
pushed a commit
to imrichardwu/airflow
that referenced
this pull request
Jun 16, 2026
…8498) The SimpleAuthManager tests shared a single generated-password file path under AIRFLOW_HOME across all test processes. Fixtures and tests create, overwrite, and delete that file, so under parallel (xdist) runs one process could delete the file another was mid-read on, raising FileNotFoundError (e.g. test_create_token_invalid_user_password hitting get_passwords). Isolate the password file per test via the existing [core] simple_auth_manager_passwords_file config option, pointing it at a per-test tmp_path so each test (and worker) gets its own file.
dingo4dev
pushed a commit
to dingo4dev/airflow
that referenced
this pull request
Jun 16, 2026
…8498) The SimpleAuthManager tests shared a single generated-password file path under AIRFLOW_HOME across all test processes. Fixtures and tests create, overwrite, and delete that file, so under parallel (xdist) runs one process could delete the file another was mid-read on, raising FileNotFoundError (e.g. test_create_token_invalid_user_password hitting get_passwords). Isolate the password file per test via the existing [core] simple_auth_manager_passwords_file config option, pointing it at a per-test tmp_path so each test (and worker) gets its own file.
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.
Human Summary
This PR fixes a race between tests of
SimpleAuthManagerthat utilize the same generated JSON file.AI Summary
Click Here
The SimpleAuthManager tests under `airflow-core/tests/unit/api_fastapi/auth/managers/simple/` all share a single generated-password file path under `AIRFLOW_HOME` (`simple_auth_manager_passwords.json.generated`). Several fixtures and tests create, overwrite, and delete that file — notably the `auth_manager` conftest fixture (`os.remove`), `test_init_with_all_admins`, and `test_get_passwords`.Because the path is global, under parallel (xdist) runs one worker process can delete the file while another is mid-read on it.
SimpleAuthManager.get_passwords()opens the file with"r+"and fails hard if it is missing, so e.g.test_create_token_invalid_user_passwordintermittently raises:This is a long-standing latent test-isolation bug (the shared-path fixture dates back to the sources-move in #47798), surfaced when these test types run together in the same parallel pool.
Fix: isolate the password file per test via an autouse fixture that points the existing
[core] simple_auth_manager_passwords_fileconfig option at a per-testtmp_path. Each test (and each xdist worker) gets its own file, removing the cross-process race. No source change needed — the source already honors that config option.Verified by reproducing the failure (~1-in-5 parallel runs before) and confirming 10/10 clean parallel runs of the whole directory after the fix.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines