Skip to content

Commit 922ca79

Browse files
committed
rex tests
1 parent 64f8540 commit 922ca79

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

tests/client_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
def test_foreman_content_view(client_environment, activation_key, organization, foremanapi, client):
22
client.run('dnf install -y subscription-manager')
3-
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']]})
3+
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']], 'force': True})
44
client.run_test(rcmd['registration_command'])
55
client.run('subscription-manager repos --enable=*')
66
client.run_test('dnf install -y bear')
77
assert client.package('bear').is_installed
88
client.run('dnf remove -y bear')
99
client.run('subscription-manager unregister')
1010
client.run('subscription-manager clean')
11+
12+
def test_foreman_rex(client_environment, activation_key, organization, foremanapi, client, client_fqdn):
13+
client.run('dnf install -y subscription-manager')
14+
rcmd = foremanapi.create('registration_commands', {'organization_id': organization['id'], 'insecure': True, 'activation_keys': [activation_key['name']], 'force': True})
15+
client.run_test(rcmd['registration_command'])
16+
job = foremanapi.create('job_invocations', {'feature': 'run_script', 'inputs': {'command': 'uptime'}, 'search_query': f'name = {client_fqdn}', 'targeting_type': 'static_query'})
17+
task = foremanapi.wait_for_task(job['task'])
18+
assert task['result'] == 'success'
19+
foremanapi.delete('hosts', {'id': client_fqdn})

tests/conftest.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def server_fqdn(server_hostname):
3232
return f'{server_hostname}.example.com'
3333

3434

35+
@pytest.fixture(scope="module")
36+
def client_hostname():
37+
return 'client'
38+
39+
40+
@pytest.fixture(scope="module")
41+
def client_fqdn(client_hostname):
42+
return f'{client_hostname}.example.com'
43+
44+
3545
@pytest.fixture(scope="module")
3646
def certificates(pytestconfig, server_fqdn):
3747
source = pytestconfig.getoption("certificate_source")
@@ -48,8 +58,8 @@ def server(server_hostname):
4858

4959

5060
@pytest.fixture(scope="module")
51-
def client():
52-
yield testinfra.get_host('paramiko://client', sudo=True, ssh_config=VAGRANT_SSH_CONFIG)
61+
def client(client_hostname):
62+
yield testinfra.get_host(f'paramiko://{client_hostname}', sudo=True, ssh_config=VAGRANT_SSH_CONFIG)
5363

5464

5565
@pytest.fixture(scope="module")

0 commit comments

Comments
 (0)