Skip to content

Commit

Permalink
Unquarantine docker example test around mpi4py builds (#39495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed May 8, 2024
1 parent 02ce7f1 commit d8fe51b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions docker_tests/test_examples_of_prod_image_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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("/", "-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit d8fe51b

Please sign in to comment.