From 09c74d45db085e86fdff4254b5305cf039e0546b Mon Sep 17 00:00:00 2001 From: Archana Pandey Date: Thu, 27 Jun 2024 14:42:35 +0530 Subject: [PATCH] fix(test): Refactoring to replace service name from rhcd to yggdrasil - Upstream name of the service is changed from rhcd to yggdrasil, so replacing the service name from rhcd to yggdrasil in tests also --- integration-tests/test_connect.py | 20 ++++++++++---------- integration-tests/utils/__init__.py | 22 ++++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/integration-tests/test_connect.py b/integration-tests/test_connect.py index 0435c11..ea89b57 100644 --- a/integration-tests/test_connect.py +++ b/integration-tests/test_connect.py @@ -12,9 +12,9 @@ import sh from utils import ( - rhcd_service_is_active, + yggdrasil_service_is_active, prepare_args_for_connect, - check_rhcd_journalctl, + check_yggdrasil_journalctl, ) logger = logging.getLogger(__name__) @@ -23,7 +23,7 @@ @pytest.mark.parametrize("auth", ["basic", "activation-key"]) def test_connect(external_candlepin, rhc, test_config, auth): """Test if RHC can connect to CRC using basic auth and activation key, - Also verify that rhcd service is in active state afterward. + Also verify that yggdrasil service is in active state afterward. """ with contextlib.suppress(Exception): rhc.disconnect() @@ -31,10 +31,10 @@ def test_connect(external_candlepin, rhc, test_config, auth): command = ["connect"] + command_args result = rhc.run(*command) assert rhc.is_registered - assert rhcd_service_is_active() + assert yggdrasil_service_is_active() assert "Connected to Red Hat Subscription Management" in result.stdout assert "Connected to Red Hat Insights" in result.stdout - assert "Activated the Remote Host Configuration daemon" in result.stdout + assert "Activated the yggdrasil service" in result.stdout assert "Successfully connected to Red Hat!" in result.stdout @@ -101,7 +101,7 @@ def test_connect_wrong_parameters( command = ["connect"] + command_args result = rhc.run(*command, check=False) assert result.returncode == 1 - assert not rhcd_service_is_active() + assert not yggdrasil_service_is_active() @pytest.mark.parametrize("auth", ["basic", "activation-key"]) @@ -113,7 +113,7 @@ def test_rhc_worker_playbook_install_after_rhc_connect( Also log the total time taken to install the package test_steps: 1- run 'rhc connect' - 2- monitor rhcd logs to see when package-manager-worker installs 'rhc-worker-playbook' + 2- monitor yggdrasil logs to see when package-manager-worker installs 'rhc-worker-playbook' 3- validate rhc-worker-playbook is installed """ with contextlib.suppress(Exception): @@ -125,7 +125,7 @@ def test_rhc_worker_playbook_install_after_rhc_connect( start_date_time = datetime.now().strftime( "%Y-%m-%d %H:%M:%S" - ) # current date and time for observing rhcd logs + ) # current date and time for observing yggdrasil logs command_args = prepare_args_for_connect(test_config, auth=auth) command = ["connect"] + command_args rhc.run(*command, check=False) @@ -134,7 +134,7 @@ def test_rhc_worker_playbook_install_after_rhc_connect( # Verifying if rhc-worker-playbook was installed successfully t_end = time.time() + 60 * 5 # maximum time to wait for installation while time.time() < t_end: - installed_status = check_rhcd_journalctl( + installed_status = check_yggdrasil_journalctl( str_to_check=success_message, since_datetime=start_date_time, must_exist_in_log=True, @@ -151,6 +151,6 @@ def test_rhc_worker_playbook_install_after_rhc_connect( pkg_version = sh.rpm("-qa", "rhc-worker-playbook") logger.info(f"successfully installed rhc_worker_playbook package {pkg_version}") logger.info( - f"time taken to start rhcd service and install " + f"time taken to start yggdrasil service and install " f"rhc_worker_playbook : {total_runtime} s" ) diff --git a/integration-tests/utils/__init__.py b/integration-tests/utils/__init__.py index c9aef4a..f242ade 100644 --- a/integration-tests/utils/__init__.py +++ b/integration-tests/utils/__init__.py @@ -1,33 +1,35 @@ import sh -def rhcd_service_is_active(): - """Method to verify if rhcd is in active/inactive state - :return: True if rhcd in active state else False +def yggdrasil_service_is_active(): + """Method to verify if yggdrasil is in active/inactive state + :return: True if yggdrasil in active state else False """ try: - stdout = sh.systemctl("is-active rhcd".split()).strip() + stdout = sh.systemctl("is-active yggdrasil".split()).strip() return stdout == "active" except sh.ErrorReturnCode_3: return False -def check_rhcd_journalctl(str_to_check, since_datetime=None, must_exist_in_log=True): - """This method helps in verifying strings in rhcd logs +def check_yggdrasil_journalctl( + str_to_check, since_datetime=None, must_exist_in_log=True +): + """This method helps in verifying strings in yggdrasil logs :param str_to_check: string to be searched in logs :param since_datetime: start time for logs :param must_exist_in_log: True if str_to_check should exist in log else false :return: True/False """ if since_datetime: - rhcd_logs = sh.journalctl("-u", "rhcd", "--since", since_datetime) + yggdrasil_logs = sh.journalctl("-u", "yggdrasil", "--since", since_datetime) else: - rhcd_logs = sh.journalctl("-u", "rhcd") + yggdrasil_logs = sh.journalctl("-u", "yggdrasil") if must_exist_in_log: - return str_to_check in rhcd_logs + return str_to_check in yggdrasil_logs else: - return str_to_check not in rhcd_logs + return str_to_check not in yggdrasil_logs def prepare_args_for_connect(