Skip to content

Commit 589843a

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 589843a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/containers/base_image_test.py

+17
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
163163
finally:
164164
docker_utils.NotebookContainer(container).stop(timeout=0)
165165

166+
def test_pip_install_cowsay_runs(self, image: str):
167+
"""Checks that the Python virtualenv in the image is writable."""
168+
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
169+
container.with_command("/bin/sh -c 'sleep infinity'")
170+
try:
171+
container.start()
172+
173+
ecode, output = container.exec(["python3", "-m", "pip", "install", "cowsay"])
174+
logging.debug(output.decode())
175+
assert ecode == 0
176+
177+
ecode, output = container.exec(["python3", "-m", "cowsay", "--text", "Hello world"])
178+
logging.debug(output.decode())
179+
assert ecode == 0
180+
finally:
181+
docker_utils.NotebookContainer(container).stop(timeout=0)
182+
166183

167184
def encode_python_function_execution_command_interpreter(python: str, function: Callable[..., Any], *args: list[Any]) -> list[str]:
168185
"""Returns a cli command that will run the given Python function encoded inline.

0 commit comments

Comments
 (0)