Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unquarantine docker example test around mpi4py builds #39495

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]