-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
888aac9
commit 3b6efb6
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
""" | ||
This Python module contains integration tests for rhc. It uses pytest-client-tools Python module. | ||
More information about this module could be found: https://github.com/ptoscano/pytest-client-tools/ | ||
""" | ||
|
||
import contextlib | ||
|
||
import sh | ||
from utils import yggdrasil_service_is_active, show_yggdrasil_service_status | ||
|
||
|
||
def test_status_connected(external_candlepin, rhc, test_config): | ||
""" | ||
Test RHC Status command when the host is connected and disconnected | ||
test_steps: | ||
1- rhc connect | ||
2- rhc status | ||
expected_output: | ||
1- Validate following strings in status command output | ||
"Connected to Red Hat Subscription Management" | ||
"Connected to Red Hat Insights" | ||
"The yggdrasil service is active" | ||
""" | ||
rhc.connect( | ||
username=test_config.get("candlepin.username"), | ||
password=test_config.get("candlepin.password"), | ||
) | ||
assert yggdrasil_service_is_active() | ||
status_result = rhc.run("status", check=False) | ||
assert status_result.returncode == 0 | ||
assert "Connected to Red Hat Subscription Management" in status_result.stdout | ||
assert "Connected to Red Hat Insights" in status_result.stdout | ||
assert "The yggdrasil service is active" in status_result.stdout | ||
|
||
|
||
def test_status_disconnected(rhc): | ||
""" | ||
Test RHC Status command when the host is connected and disconnected | ||
test_steps: | ||
1- rhc disconnect | ||
2- rhc status | ||
expected_output: | ||
1- Validate following strings in status command output | ||
"Not connected to Red Hat Subscription Management" | ||
"Not connected to Red Hat Insights" | ||
"The yggdrasil service is inactive" | ||
""" | ||
rhc.run("disconnect", check=False) | ||
status_result = rhc.run("status", check=False) | ||
assert status_result.returncode == 0 | ||
assert "Not connected to Red Hat Subscription Management" in status_result.stdout | ||
assert "Not connected to Red Hat Insights" in status_result.stdout | ||
assert "The yggdrasil service is inactive" in status_result.stdout | ||
|
||
|
||
def test_rhcd_started_after_reboot(external_candlepin, rhc, test_config): | ||
""" | ||
Test RHCD service is started automatically after reboot. | ||
Note: | ||
currently it is not possible to actually reboot a | ||
system due to infra limitations so we will try to | ||
restart service vis systemd instead | ||
test_steps: | ||
1- disconnect the system | ||
2- restart yggdrasil service via systemctl | ||
expected_results: | ||
1- Yggdrasil service should be restarted successfully and set in active state | ||
""" | ||
with contextlib.suppress(Exception): | ||
rhc.disconnect() | ||
|
||
# reboot the test system, but currently it is not possible to actually reboot a | ||
# system, so we will try to restart service vis systemd instead | ||
# reboot_commands = ["tmt-reboot", "rhts-reboot", "reboot"] ### Change-Me | ||
try: | ||
cmd = sh.systemctl("restart yggdrasil".split(), _return_cmd=True) | ||
cmd.wait(timeout=60) | ||
assert yggdrasil_service_is_active() | ||
except AssertionError as exc: | ||
show_yggdrasil_service_status() | ||
raise exc | ||
|
||
# test yggdrasil service restart on a connected system | ||
rhc.connect( | ||
username=test_config.get("candlepin.username"), | ||
password=test_config.get("candlepin.password"), | ||
) | ||
assert rhc.is_registered | ||
try: | ||
cmd = sh.systemctl("restart yggdrasil".split(), _return_cmd=True) | ||
cmd.wait(timeout=60) | ||
assert yggdrasil_service_is_active() | ||
except AssertionError as exc: | ||
show_yggdrasil_service_status() | ||
raise exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters