This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 53ed24ffc76 Use filelock to fix race condition in version suffix test
for xdist runs (#58608)
53ed24ffc76 is described below
commit 53ed24ffc76930f7d6760f9109e4c9b595a17f35
Author: Amogh Desai <[email protected]>
AuthorDate: Mon Nov 24 15:47:08 2025 +0530
Use filelock to fix race condition in version suffix test for xdist runs
(#58608)
* Use filelock to fix race condition in version suffix test for xdist runs
* Use filelock to fix race condition in version suffix test for xdist runs
---
dev/breeze/tests/test_packages.py | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/dev/breeze/tests/test_packages.py
b/dev/breeze/tests/test_packages.py
index ea9fbfebc49..b6ca0ac4a0b 100644
--- a/dev/breeze/tests/test_packages.py
+++ b/dev/breeze/tests/test_packages.py
@@ -402,22 +402,17 @@ AIRFLOWCTL_INIT_PY = AIRFLOW_ROOT_PATH / "airflow-ctl" /
"src" / "airflowctl" /
@pytest.fixture
-def restore_version_files():
- # save contents of all version files before test starts
- version_files = [
- AIRFLOW_CORE_INIT_PY,
- TASK_SDK_INIT_PY,
- AIRFLOWCTL_INIT_PY,
- ]
- original_contents = {f: f.read_text() for f in version_files if f.exists()}
-
- yield
+def lock_version_files():
+ from filelock import FileLock
- # restore original contents after test
- for fp, content in original_contents.items():
- fp.write_text(content)
+ lock_file = AIRFLOW_ROOT_PATH / ".version_files.lock"
+ with FileLock(lock_file):
+ yield
+ if lock_file.exists():
+ lock_file.unlink()
[email protected]("lock_version_files")
@pytest.mark.parametrize(
("distributions", "init_file_path", "version_suffix",
"floored_version_suffix"),
[
@@ -445,7 +440,6 @@ def restore_version_files():
],
)
def test_apply_version_suffix_to_non_provider_pyproject_tomls(
- restore_version_files,
distributions: tuple[str, ...],
init_file_path: Path,
version_suffix: str,