Skip to content

RHOAIENG-9707: chore(tests/containers): try to install the cowsay package to check the python venv is writable #873

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

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
17 changes: 17 additions & 0 deletions tests/containers/base_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
finally:
docker_utils.NotebookContainer(container).stop(timeout=0)

def test_pip_install_cowsay_runs(self, image: str):
"""Checks that the Python virtualenv in the image is writable."""
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
container.with_command("/bin/sh -c 'sleep infinity'")
try:
container.start()

ecode, output = container.exec(["python3", "-m", "pip", "install", "cowsay"])
logging.debug(output.decode())
assert ecode == 0

ecode, output = container.exec(["python3", "-m", "cowsay", "--text", "Hello world"])
logging.debug(output.decode())
assert ecode == 0
finally:
docker_utils.NotebookContainer(container).stop(timeout=0)


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