Skip to content

Commit

Permalink
use fixtures for host definition
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Nov 18, 2024
1 parent 60b8b29 commit d926760
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
10 changes: 10 additions & 0 deletions tests/client_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def test_foreman_content_view(client_environment, activation_key, organization, foremanapi, client, ssh_config):
client.run('dnf install -y subscription-manager')
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']]})
client.run_test(rcmd['registration_command'])
client.run('subscription-manager repos --enable=*')
client.run_test('dnf install -y bear')
assert client.package('bear').is_installed
client.run('dnf remove -y bear')
client.run('subscription-manager unregister')
client.run('subscription-manager clean')
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def server():
yield testinfra.get_host('paramiko://quadlet', sudo=True, ssh_config='./.vagrant/ssh-config')


@pytest.fixture(scope="module")
def client():
yield testinfra.get_host('paramiko://client', sudo=True, ssh_config='./.vagrant/ssh-config')


@pytest.fixture(scope="module")
def ssh_config():
config = paramiko.SSHConfig.from_path('./.vagrant/ssh-config')
Expand Down
10 changes: 0 additions & 10 deletions tests/foreman_client.py

This file was deleted.

10 changes: 5 additions & 5 deletions tests/zzz_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def test_collect_report(host):
host.run('mkdir -p logs')
def test_collect_report(server):
server.run('mkdir -p logs')
for container, filename in [('foreman', '/var/log/foreman/production.log')]:
localfile = filename.replace('/', '_')
host.run(f'podman cp {container}:{filename} logs/{container}-{localfile}')
host.run('tar caf logs.tar.gz logs/')
server.run(f'podman cp {container}:{filename} logs/{container}-{localfile}')
server.run('tar caf logs.tar.gz logs/')
with open('logs.tar.gz', 'wb') as logstar:
logstar.write(host.file('logs.tar.gz').content)
logstar.write(server.file('logs.tar.gz').content)

0 comments on commit d926760

Please sign in to comment.