Skip to content

Commit d332fab

Browse files
committed
RHOAIENG-9707: chore(tests/containers): try to install the cowsay package to check the python venv is writable
1 parent 20e7b89 commit d332fab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/containers/base_image_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
164164
docker_utils.NotebookContainer(container).stop(timeout=0)
165165

166166

167+
def test_pip_install_cowsay_runs(self, image: str):
168+
"""Checks that the Python virtualenv in the image is writable."""
169+
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
170+
container.with_command("/bin/sh -c 'sleep infinity'")
171+
try:
172+
container.start()
173+
174+
ecode, output = container.exec(["python3", "-m", "pip", "install", "cowsay"])
175+
logging.debug(output.decode())
176+
assert ecode == 0
177+
178+
ecode, output = container.exec(["python3", "-m", "cowsay", "--text", "Hello world"])
179+
logging.debug(output.decode())
180+
assert ecode == 0
181+
finally:
182+
docker_utils.NotebookContainer(container).stop(timeout=0)
183+
184+
167185
def encode_python_function_execution_command_interpreter(python: str, function: Callable[..., Any], *args: list[Any]) -> list[str]:
168186
"""Returns a cli command that will run the given Python function encoded inline.
169187
All dependencies (imports, ...) must be part of function body."""

0 commit comments

Comments
 (0)