From d8fe51bcd266ae1ee8d5b77f19306d9453c41e2c Mon Sep 17 00:00:00 2001 From: Andrey Anshin Date: Wed, 8 May 2024 21:04:47 +0400 Subject: [PATCH] Unquarantine docker example test around `mpi4py` builds (#39495) --- .../test_examples_of_prod_image_building.py | 21 +++++++++---------- .../customizing/add-build-essential-custom.sh | 2 +- .../add-build-essential-extend/Dockerfile | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docker_tests/test_examples_of_prod_image_building.py b/docker_tests/test_examples_of_prod_image_building.py index 2e99b69280bf9..a10fcb1c654c2 100644 --- a/docker_tests/test_examples_of_prod_image_building.py +++ b/docker_tests/test_examples_of_prod_image_building.py @@ -33,6 +33,11 @@ # isort:on (needed to workaround isort bug) DOCKER_EXAMPLES_DIR = SOURCE_ROOT / "docs" / "docker-stack" / "docker-examples" +QUARANTINED_DOCKER_EXAMPLES: dict[str, str] = { + # You could temporarily disable check for specific Dockerfile + # In this case you need to provide a relative path with the reason, e.g: + # "extending/add-build-essential-extend/Dockerfile": "https://github.com/apache/airflow/issues/XX", +} @lru_cache(maxsize=None) @@ -52,27 +57,21 @@ def test_shell_script_example(script_file): run_command(["bash", script_file]) -def docker_examples(directory: Path, xfails: list[str] | None = None): - xfails = xfails or [] +def docker_examples(directory: Path, xfails: dict[str, str] | None = None): + xfails = xfails or {} result = [] for filepath in sorted(directory.rglob("**/Dockerfile")): markers = [] rel_path = filepath.relative_to(directory).as_posix() - if rel_path in xfails: - markers.append(pytest.mark.xfail) + if xfail_reason := xfails.get(rel_path): + markers.append(pytest.mark.xfail(reason=xfail_reason)) result.append(pytest.param(filepath, rel_path, marks=markers, id=rel_path)) return result @pytest.mark.parametrize( "dockerfile, relative_path", - docker_examples( - DOCKER_EXAMPLES_DIR, - xfails=[ - # FIXME https://github.com/apache/airflow/issues/38988 - "extending/add-build-essential-extend/Dockerfile", - ], - ), + docker_examples(DOCKER_EXAMPLES_DIR, xfails=QUARANTINED_DOCKER_EXAMPLES), ) def test_dockerfile_example(dockerfile, relative_path, tmp_path): image_name = relative_path.lower().replace("/", "-") diff --git a/docs/docker-stack/docker-examples/customizing/add-build-essential-custom.sh b/docs/docker-stack/docker-examples/customizing/add-build-essential-custom.sh index 70c1bf9e331b4..f0d30cb20fb37 100755 --- a/docs/docker-stack/docker-examples/customizing/add-build-essential-custom.sh +++ b/docs/docker-stack/docker-examples/customizing/add-build-essential-custom.sh @@ -33,7 +33,7 @@ docker build . \ --pull \ --build-arg PYTHON_BASE_IMAGE="python:3.8-slim-bookworm" \ --build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \ - --build-arg ADDITIONAL_PYTHON_DEPS="mpi4py==3.1.5" \ + --build-arg ADDITIONAL_PYTHON_DEPS="mpi4py==3.1.6" \ --build-arg ADDITIONAL_DEV_APT_DEPS="libopenmpi-dev" \ --build-arg ADDITIONAL_RUNTIME_APT_DEPS="openmpi-common" \ --tag "my-build-essential-image:0.0.1" diff --git a/docs/docker-stack/docker-examples/extending/add-build-essential-extend/Dockerfile b/docs/docker-stack/docker-examples/extending/add-build-essential-extend/Dockerfile index 0d52b860dcb84..4ad77eec9287e 100644 --- a/docs/docker-stack/docker-examples/extending/add-build-essential-extend/Dockerfile +++ b/docs/docker-stack/docker-examples/extending/add-build-essential-extend/Dockerfile @@ -24,5 +24,5 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* USER airflow -RUN pip install --no-cache-dir "apache-airflow==${AIRFLOW_VERSION}" mpi4py +RUN pip install --no-cache-dir "apache-airflow==${AIRFLOW_VERSION}" "mpi4py==3.1.6" # [END Dockerfile]