Skip to content

Commit

Permalink
Merge pull request #863 from jstourac/readme
Browse files Browse the repository at this point in the history
NO-JIRA: chore(tests) Update readme for tests execution + some test fixes for linux env
  • Loading branch information
openshift-merge-bot[bot] authored Jan 24, 2025
2 parents adbd066 + 55a5ef2 commit 5349835
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,51 @@ Note: To ensure the GitHub Action runs successfully, users must add a `GH_ACCESS

### Deploy & Test

#### Running Python selftests in Pytest
#### Prepare Python + poetry + pytest env

```shell
pip install poetry
poetry env use /usr/bin/python3.12
# Linux
sudo dnf install python3.12
pip install --user poetry
# MacOS
brew install [email protected] poetry

poetry env use $(which python3.12)
poetry config virtualenvs.in-project true
poetry env info
poetry install --sync
```

#### Running Python selftests in Pytest
By completing configuration in previous section, you are able to run any tests that don't need to start a container using following command:

```
poetry run pytest
```

#### Running testcontainers tests in Pytest
```
# Podman/Docker config
# Linux
sudo dnf install podman
systemctl --user start podman.service
systemctl --user status podman.service
systemctl --user status podman.socket
DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock poetry run pytest tests/containers --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
# Mac OS
brew install podman
podman machine init
podman machine set --rootful
sudo podman-mac-helper install
podman machine start
poetry run pytest tests/containers --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
```

#### Running Playwright tests in Pytest

[tests/browser/README.md](tests/browser/README.md)

#### Notebooks

Deploy the notebook images in your Kubernetes environment using:
Expand Down
6 changes: 3 additions & 3 deletions tests/containers/base_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestBaseImage:
"""Tests that are applicable for all images we have in this repository."""

def test_oc_command_runs(self, image: str):
container = testcontainers.core.container.DockerContainer(image=image, user=123456, group_add=[0])
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
container.with_command("/bin/sh -c 'sleep infinity'")
try:
container.start()
Expand Down Expand Up @@ -50,8 +50,8 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
# tmpdir is by-default created with perms restricting access to user only
tmp_crypto.chmod(0o777)

container = testcontainers.core.container.DockerContainer(image=image, user=654321, group_add=[0])
container.with_volume_mapping(str(tmp_crypto), "/proc/sys")
container = testcontainers.core.container.DockerContainer(image=image, user=54321, group_add=[0])
container.with_volume_mapping(str(tmp_crypto), "/proc/sys", mode="ro,z")
container.with_command("/bin/sh -c 'sleep infinity'")

try:
Expand Down

0 comments on commit 5349835

Please sign in to comment.