Skip to content

Commit

Permalink
RHOAIENG-9707: chore(tests/containers): try to install the cowsay pac…
Browse files Browse the repository at this point in the history
…kage to check the python venv is writable
  • Loading branch information
jiridanek committed Jan 31, 2025
1 parent 20e7b89 commit d332fab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/containers/base_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
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.
All dependencies (imports, ...) must be part of function body."""
Expand Down

0 comments on commit d332fab

Please sign in to comment.