Skip to content

Fix flaky SimpleAuthManager login tests under parallel runs#68498

Merged
potiuk merged 1 commit into
apache:mainfrom
shahar1:fix-simple-auth-password-file-test-race
Jun 13, 2026
Merged

Fix flaky SimpleAuthManager login tests under parallel runs#68498
potiuk merged 1 commit into
apache:mainfrom
shahar1:fix-simple-auth-password-file-test-race

Conversation

@shahar1

@shahar1 shahar1 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Human Summary

This PR fixes a race between tests of SimpleAuthManager that 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_password intermittently raises:

FileNotFoundError: [Errno 2] No such file or directory: '.../simple_auth_manager_passwords.json.generated'

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_file config option at a per-test tmp_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?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

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.
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Jun 13, 2026
@shahar1
shahar1 requested review from bugraoz93 and potiuk June 13, 2026 05:53
@potiuk
potiuk merged commit 0823e7a into apache:main Jun 13, 2026
76 checks passed
@shahar1
shahar1 deleted the fix-simple-auth-password-file-test-race branch June 13, 2026 08:25
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants