Skip to content
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

Add Linux Client tests #10

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ To see all markers:
```
pytest --markers
```

## Launching Linux clients

The client tests will automatically run on any local running podman containers. They can be launched using

```
podman run --rm --detach --label smoker-linux-client --name centos-7 centos:7 /sbin/init
podman run --rm --detach --label smoker-linux-client --name centos-8 centos:8 /sbin/init
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that not all container images have systemd installed by default.

```
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest-base-url
pytest-selenium
pytest-testinfra
pytest-variables
pytest-xdist
29 changes: 29 additions & 0 deletions tests/test_clients.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import testinfra


def pytest_generate_tests(metafunc):
if 'linux_client' in metafunc.fixturenames:
host = testinfra.get_host('local://')
containers = host.podman.get_containers(label='smoker-linux-client', status='running')
linux_clients = [f"podman://{container.id}" for container in containers]
ids = [container.name for container in containers]

metafunc.parametrize('linux_client', linux_clients, ids=ids, indirect=True)


@pytest.fixture(scope="module")
def linux_client(request):
host = testinfra.get_host(request.param)

subman = host.package("subscription-manager")
if not subman.is_installed:
print('Installing subscription-manager')
host.run('yum -y install subscription-manager')

return host
Comment on lines +17 to +24
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an example. I also considered making it an explicit parameter on the CLI pytest invocation and spawn them on demand here so they wouldn't be reused between tests. That's probably a much cleaner implementation.



def test_subman_installed(linux_client):
subman = linux_client.package("subscription-manager")
assert subman.is_installed