Skip to content

Commit 765c16c

Browse files
alisonlhartssbarneacidrblock
authored
Add test for container-in-container functionality (#367)
Co-authored-by: Sorin Sbarnea <[email protected]> Co-authored-by: Bradley A. Thornton <[email protected]>
1 parent a696a72 commit 765c16c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def pytest_sessionfinish(session: pytest.Session) -> None:
263263
--userns=host
264264
"""
265265

266-
DOCKER_CMD = """ --user=podman
266+
DOCKER_CMD = """ --user=root
267267
"""
268268

269269
END = """ {image_name}

tests/integration/test_container.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,30 @@ def test_podman(exec_container: Callable[[str], subprocess.CompletedProcess[str]
4747
assert result.returncode == 0, "podman command failed"
4848

4949

50+
@pytest.mark.container()
51+
def test_container_in_container(
52+
exec_container: Callable[[str], subprocess.CompletedProcess[str]],
53+
) -> None:
54+
"""Test podman container-in-container functionality for plugin copy.
55+
56+
Args:
57+
exec_container: The container executor.
58+
"""
59+
podman_run_container = exec_container(
60+
"podman run -i --rm -d -e ANSIBLE_DEV_TOOLS_CONTAINER=1"
61+
" -e ANSIBLE_FORCE_COLOR=0 --name ghcr_io_ansible_community_ansible_dev_tools_latest"
62+
" ghcr.io/ansible/community-ansible-dev-tools:latest bash",
63+
)
64+
assert podman_run_container.returncode == 0
65+
66+
test_path_access = exec_container(
67+
"podman exec ghcr_io_ansible_community_ansible_dev_tools_latest"
68+
" ls /usr/local/lib/python3.12/site-packages/ansible/plugins/",
69+
)
70+
assert "OCI permission denied" not in test_path_access.stdout
71+
assert test_path_access.returncode == 0
72+
73+
5074
@pytest.mark.container()
5175
@pytest.mark.parametrize("app", ("nano", "tar", "vi"))
5276
def test_app(exec_container: Callable[[str], subprocess.CompletedProcess[str]], app: str) -> None:

0 commit comments

Comments
 (0)