diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 71f7735d963..6107505e9f6 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -196,8 +196,11 @@ def large_capsule_configured(large_capsule_host, target_sat): @pytest.fixture(scope='module') def module_capsule_configured(request, module_capsule_host, module_target_sat): """Configure the capsule instance with the satellite from settings.server.hostname""" - if not request.config.option.n_minus: + if not any([request.config.option.n_minus, 'build_sanity' in request.config.option.markexpr]): module_capsule_host.capsule_setup(sat_host=module_target_sat) + # The capsule is being set here by capsule installation test of `test_installer.py` for sanity + if 'build_sanity' in request.config.option.markexpr: + return Capsule.get_host_by_hostname(settings.capsule.hostname) return module_capsule_host diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index be497dd988d..53d657a9308 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -6,7 +6,7 @@ import pytest from robottelo.config import configure_airgun, configure_nailgun, settings -from robottelo.hosts import Satellite +from robottelo.hosts import Capsule, Satellite from robottelo.logging import logger @@ -16,6 +16,12 @@ def align_to_satellite(request, worker_id, satellite_factory): if 'build_sanity' in request.config.option.markexpr: settings.set("server.hostname", None) yield + # Checkout Sanity Capsule finally + if settings.capsule.hostname: + sanity_cap = Capsule.get_host_by_hostname(settings.capsule.hostname) + sanity_cap.unregister() + Broker(hosts=[sanity_cap]).checkin() + # Checkout Sanity Satellite finally if settings.server.hostname: sanity_sat = Satellite(settings.server.hostname) sanity_sat.unregister() diff --git a/robottelo/hosts.py b/robottelo/hosts.py index ad73a66200f..66e03b53835 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -20,6 +20,7 @@ from fauxfactory import gen_alpha, gen_string from nailgun import entities from packaging.version import Version +import pytest import requests from ssh2.exceptions import AuthenticationError from wait_for import TimedOutError, wait_for @@ -362,6 +363,13 @@ def setup(self): def teardown(self): logger.debug('START: tearing down host %s', self) if not self.blank and not getattr(self, '_skip_context_checkin', False): + if ( + hasattr(pytest, 'capsule_sanity') + and pytest.capsule_sanity is True + and type(self) is Capsule + ): + logger.debug('END: Skipping tearing down caspule host %s for sanity', self) + return self.unregister() if type(self) is not Satellite: # do not delete Satellite's host record self._delete_host_record() diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index 4fb0f73bb00..4772a24f75e 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -510,6 +510,10 @@ def test_positive_iso_library_sync( assert set(sat_isos) == set(caps_isos) @pytest.mark.tier4 + @pytest.mark.build_sanity + @pytest.mark.order( + after="tests/foreman/installer/test_installer.py::test_satellite_and_capsule_installation" + ) @pytest.mark.skip_if_not_set('capsule', 'fake_manifest') def test_positive_on_demand_sync( self, diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index 8e68375bead..d7e4cddbd92 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -1459,7 +1459,7 @@ def test_satellite_installation(installer_satellite): @pytest.mark.parametrize( "installer_satellite", [settings.server.version.rhel_version], indirect=True ) -def test_satellite_and_capsule_installation(installer_satellite, cap_ready_rhel): +def test_satellite_and_capsule_installation(pytestconfig, installer_satellite, cap_ready_rhel): """Run a basic Satellite and Capsule installation :id: bbab30a6-6861-494f-96dd-23b883c2c906 @@ -1482,6 +1482,11 @@ def test_satellite_and_capsule_installation(installer_satellite, cap_ready_rhel) :CaseImportance: Critical """ + # Setup Capsule Hostname for further sanity caspule testing + if 'build_sanity' in pytestconfig.option.markexpr: + settings.capsule.hostname = cap_ready_rhel.hostname + cap_ready_rhel._skip_context_checkin = True + pytest.capsule_sanity = True # Get Capsule repofile, and enable and download satellite-capsule cap_ready_rhel.register_to_cdn() cap_ready_rhel.download_repofile(product='capsule', release=settings.server.version.release) @@ -1502,6 +1507,11 @@ def test_satellite_and_capsule_installation(installer_satellite, cap_ready_rhel) r'grep "\[ERROR" --after-context=100 /var/log/foreman-installer/satellite.log' ) assert len(result.stdout) == 0 + + # Enabling firewall + cap_ready_rhel.execute('firewall-cmd --add-service RH-Satellite-6-capsule') + cap_ready_rhel.execute('firewall-cmd --runtime-to-permanent') + result = cap_ready_rhel.cli.Health.check() assert 'FAIL' not in result.stdout