Skip to content

[WIP] add: container test plugin for pytest#17372

Draft
realsdx wants to merge 2 commits into
4.0from
sudipta/4.0/add-container-runtime-test-system
Draft

[WIP] add: container test plugin for pytest#17372
realsdx wants to merge 2 commits into
4.0from
sudipta/4.0/add-container-runtime-test-system

Conversation

@realsdx
Copy link
Copy Markdown
Contributor

@realsdx realsdx commented May 20, 2026

Add a pytest based validation framework AzureLinux's OCI container images, integrated with azldev image test

Test it locally by (make sure to install and start podman first):

azldev image build container-base && azldev image test container-base

images with a given capability.
- **Image-specific:** add `cases/<image-family>/test_<topic>.py`. Tests
in such subdirectories are **automatically** restricted to that
- **Image-specific static:** add `cases/static/<image-family>/test_<topic>.py`.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have odd feeling about these directory-based tests discovery, markers might be more useful. As you add more and more tests, directories and subdirectories just for categorization might become too complex.

@pytest.mark.dockerfile()
def test_nginx_config_valid(container_exec) -> None:
"""nginx configuration must pass validation."""
result = container_exec("nginx -t 2>&1")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2>&1?

- **`uv`** — Python project/package manager

For runtime tests, the **podman socket** must be active:
(ASK: Do we need this? podman-py is quite basic, maybe it's better without REST API and directly invoking podman CLI? The socket requirement is a bit of a pain, especially for WSL users. Then would need to have our own wrapper around podman CLI to handle the container orchestration logic currently in `container_runtime.py`. Or even docker SDK with moby might be more stable than podman-py?)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely open to other options here -- but we should leverage existing OSS if we can.

What about https://github.com/gabrieldemarmiesse/python-on-whales ? That seems to work with podman in rootless, daemonless mode too.

COPY nginx.conf /etc/nginx/nginx.conf
```

Mark tests with `@pytest.mark.dockerfile()` to trigger the build. The
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants