From 418b330fac8d3722c8fbd34cafb4f9a17b93b039 Mon Sep 17 00:00:00 2001 From: Griffin Sullivan Date: Tue, 26 Sep 2023 12:23:49 -0400 Subject: [PATCH 1/3] Add customer coverage to health check --- tests/foreman/maintain/test_health.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/foreman/maintain/test_health.py b/tests/foreman/maintain/test_health.py index c1d590546ec..0dd4320d633 100644 --- a/tests/foreman/maintain/test_health.py +++ b/tests/foreman/maintain/test_health.py @@ -96,11 +96,17 @@ def test_positive_health_check(sat_maintain): 1. Run satellite-maintain health check :expectedresults: Health check should pass. + + :BZ: 1956210 + + :customerscenario: true """ result = sat_maintain.cli.Health.check(options={'assumeyes': True}) assert result.status == 0 if 'paused tasks in the system' not in result.stdout: assert 'FAIL' not in result.stdout + result = sat_maintain.execute('tail /var/log/foreman-proxy/proxy.log') + assert 'sslv3 alert bad certificate' not in result.stdout @pytest.mark.include_capsule From 8d98645c4b53b53d0f983a0752506c8fa3fa5db7 Mon Sep 17 00:00:00 2001 From: Griffin Sullivan Date: Thu, 28 Sep 2023 15:46:52 -0400 Subject: [PATCH 2/3] Add coverage for 1964037 installer cert regen --- robottelo/cli/base.py | 12 +++++++- tests/foreman/destructive/test_installer.py | 34 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/robottelo/cli/base.py b/robottelo/cli/base.py index 4f66a05a089..d5ce2ae224f 100644 --- a/robottelo/cli/base.py +++ b/robottelo/cli/base.py @@ -119,6 +119,16 @@ def add_operating_system(cls, options=None): return cls.execute(cls._construct_command(options)) + @classmethod + def ping(cls, options=None): + """ + Display status of Satellite. + """ + + cls.command_sub = 'ping' + + return cls.execute(cls._construct_command(options)) + @classmethod def create(cls, options=None, timeout=None): """ @@ -419,6 +429,6 @@ def _construct_command(cls, options=None): if isinstance(val, list): val = ','.join(str(el) for el in val) tail += f' --{key}="{val}"' - cmd = f"{cls.command_base} {cls.command_sub or ''} {tail.strip()} {cls.command_end or ''}" + cmd = f"{cls.command_base or ''} {cls.command_sub or ''} {tail.strip()} {cls.command_end or ''}" return cmd diff --git a/tests/foreman/destructive/test_installer.py b/tests/foreman/destructive/test_installer.py index 19459340458..aa683870591 100644 --- a/tests/foreman/destructive/test_installer.py +++ b/tests/foreman/destructive/test_installer.py @@ -20,6 +20,7 @@ import pytest from robottelo.config import settings +from robottelo.constants import SATELLITE_ANSWER_FILE from robottelo.utils.installer import InstallerCommand pytestmark = pytest.mark.destructive @@ -154,3 +155,36 @@ def test_positive_mismatched_satellite_fqdn(target_sat, set_random_fqdn): ) installer_command_output = target_sat.execute('satellite-installer').stderr assert warning_message in str(installer_command_output) + + +def test_positive_installer_certs_regenerate(target_sat): + """Ensure "satellite-installer --certs-regenerate true" command correctly generates + /etc/tomcat/cert-users.properties after editing answers file + + :id: db6152c3-4459-425b-998d-4a7992ca1f72 + + :steps: + 1. Update /etc/foreman-installer/scenarios.d/satellite-answers.yaml + 2. Fill some empty strings in certs category for 'state' + 3. Run satellite-installer --certs-regenerate true + 4. hammer ping + + :expectedresults: Correct generation of /etc/tomcat/cert-users.properties + + :BZ: 1964037 + + :customerscenario: true + """ + target_sat.execute(f'sed -i "s/state: North Carolina/state: \'\'/g" {SATELLITE_ANSWER_FILE}') + result = target_sat.execute(f'grep state: {SATELLITE_ANSWER_FILE}') + assert "state: ''" in result.stdout + result = target_sat.install( + InstallerCommand( + 'certs-update-all', + 'certs-update-server', + 'certs-update-server-ca', + certs_regenerate=['true'], + ) + ) + assert result.status == 0 + assert 'FAIL' not in target_sat.cli.Base.ping() From 89b779b664e521b87b5ee999424c205369df965b Mon Sep 17 00:00:00 2001 From: Griffin Sullivan <48397354+Griffin-Sullivan@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:33:42 -0400 Subject: [PATCH 3/3] Add coverage for 2055790 to service enable disable (#12756) * Adding wait for to service enable test * Add coverage for 2055790 to enable disable --- tests/foreman/maintain/test_service.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/foreman/maintain/test_service.py b/tests/foreman/maintain/test_service.py index 99bb6074ae5..5e9f24c6510 100644 --- a/tests/foreman/maintain/test_service.py +++ b/tests/foreman/maintain/test_service.py @@ -18,6 +18,7 @@ """ from fauxfactory import gen_string import pytest +from wait_for import wait_for from robottelo.config import settings from robottelo.constants import ( @@ -173,6 +174,10 @@ def test_positive_service_enable_disable(sat_maintain): 2. Run satellite-maintain service enable :expectedresults: Services should enable/disable + + :BZ: 1995783, 2055790 + + :customerscenario: true """ result = sat_maintain.cli.Service.stop() assert 'FAIL' not in result.stdout @@ -183,6 +188,28 @@ def test_positive_service_enable_disable(sat_maintain): result = sat_maintain.cli.Service.enable() assert 'FAIL' not in result.stdout assert result.status == 0 + sat_maintain.power_control(state='reboot') + if isinstance(sat_maintain, Satellite): + result, _ = wait_for( + sat_maintain.cli.Service.status, + func_kwargs={'options': {'brief': True, 'only': 'foreman.service'}}, + fail_condition=lambda res: "FAIL" in res.stdout, + handle_exception=True, + delay=30, + timeout=300, + ) + assert 'FAIL' not in sat_maintain.cli.Base.ping() + else: + result, _ = wait_for( + sat_maintain.cli.Service.status, + func_kwargs={'options': {'brief': True}}, + fail_condition=lambda res: "FAIL" in res.stdout, + handle_exception=True, + delay=30, + timeout=300, + ) + assert 'FAIL' not in result.stdout + assert result.status == 0 @pytest.mark.usefixtures('start_satellite_services')