diff --git a/conftest.py b/conftest.py index c58f71c991b..8beb3e3b550 100644 --- a/conftest.py +++ b/conftest.py @@ -41,7 +41,6 @@ 'pytest_fixtures.component.host', 'pytest_fixtures.component.hostgroup', 'pytest_fixtures.component.http_proxy', - 'pytest_fixtures.component.katello_agent', 'pytest_fixtures.component.katello_certs_check', 'pytest_fixtures.component.lce', 'pytest_fixtures.component.maintain', diff --git a/pytest_fixtures/component/katello_agent.py b/pytest_fixtures/component/katello_agent.py deleted file mode 100644 index 0428f91a740..00000000000 --- a/pytest_fixtures/component/katello_agent.py +++ /dev/null @@ -1,57 +0,0 @@ -from box import Box -import pytest - -from robottelo.config import settings -from robottelo.utils.installer import InstallerCommand - - -@pytest.fixture(scope='module') -def sat_with_katello_agent(module_target_sat): - """Enable katello-agent feature on module_target_sat if not enabled yet.""" - katello_agent_enabled = ( - 'true' - in module_target_sat.install( - InstallerCommand(help='| grep foreman-proxy-content-enable-katello-agent') - ).stdout - ) - if not katello_agent_enabled: - module_target_sat.register_to_cdn() - # Enable katello-agent from satellite-installer - result = module_target_sat.install( - InstallerCommand('foreman-proxy-content-enable-katello-agent true') - ) - assert result.status == 0 - yield module_target_sat - - -@pytest.fixture -def katello_agent_client_for_upgrade(sat_with_katello_agent, sat_upgrade_chost, module_org): - """Register content host to Satellite and install katello-agent on the host.""" - client_repo = settings.repos['SATCLIENT_REPO'][f'RHEL{sat_upgrade_chost.os_version.major}'] - sat_with_katello_agent.register_host_custom_repo( - module_org, sat_upgrade_chost, [client_repo, settings.repos.yum_1.url] - ) - sat_upgrade_chost.install_katello_agent() - host_info = sat_with_katello_agent.cli.Host.info({'name': sat_upgrade_chost.hostname}) - yield Box( - { - 'client': sat_upgrade_chost, - 'host_info': host_info, - 'sat': sat_with_katello_agent, - } - ) - - -@pytest.fixture -def katello_agent_client(sat_with_katello_agent, rhel_contenthost): - """Register content host to Satellite and install katello-agent on the host.""" - org = sat_with_katello_agent.api.Organization().create() - client_repo = settings.repos['SATCLIENT_REPO'][f'RHEL{rhel_contenthost.os_version.major}'] - sat_with_katello_agent.register_host_custom_repo( - org, - rhel_contenthost, - [client_repo, settings.repos.yum_1.url], - ) - rhel_contenthost.install_katello_agent() - host_info = sat_with_katello_agent.cli.Host.info({'name': rhel_contenthost.hostname}) - yield Box({'client': rhel_contenthost, 'host_info': host_info, 'sat': sat_with_katello_agent}) diff --git a/tests/upgrades/test_client.py b/tests/upgrades/test_client.py index 8877550a29f..7cb4ce6fe7c 100644 --- a/tests/upgrades/test_client.py +++ b/tests/upgrades/test_client.py @@ -21,10 +21,17 @@ """ import pytest +from robottelo.config import settings from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME, FAKE_4_CUSTOM_PACKAGE_NAME from robottelo.hosts import ContentHost +@pytest.fixture +def client_for_upgrade(module_target_sat, rex_contenthost, module_org): + rex_contenthost.create_custom_repos(fake_yum=settings.repos.yum_1.url) + yield rex_contenthost + + class TestScenarioUpgradeOldClientAndPackageInstallation: """This section contains pre and post upgrade scenarios to test if the package can be installed on the preupgrade client remotely. @@ -39,8 +46,13 @@ class TestScenarioUpgradeOldClientAndPackageInstallation: """ @pytest.mark.pre_upgrade + @pytest.mark.rhel_ver_list([8]) def test_pre_scenario_pre_client_package_installation( - self, katello_agent_client_for_upgrade, module_org, module_target_sat, save_test_data + self, + client_for_upgrade, + module_org, + module_target_sat, + save_test_data, ): """Create product and repo, from which a package will be installed post upgrade. Create a content host and register it. @@ -53,7 +65,6 @@ def test_pre_scenario_pre_client_package_installation( installed on content host 2. Add repo to CV and then to Activation key - :steps: 1. Create a container as content host and register with Activation key @@ -64,17 +75,21 @@ def test_pre_scenario_pre_client_package_installation( 2. The new repo is enabled on the content host. """ - rhel_client = katello_agent_client_for_upgrade.client - module_target_sat.cli.Host.package_install( - {'host-id': rhel_client.nailgun_host.id, 'packages': FAKE_4_CUSTOM_PACKAGE_NAME} + client_for_upgrade._skip_context_checkin = True + module_target_sat.cli_factory.make_job_invocation( + { + 'job-template': 'Install Package - Katello Script Default', + 'inputs': f'package={FAKE_4_CUSTOM_PACKAGE_NAME}', + 'search-query': f'name ~ {client_for_upgrade.hostname}', + } ) - result = rhel_client.execute(f"rpm -q {FAKE_4_CUSTOM_PACKAGE_NAME}") + result = client_for_upgrade.execute(f"rpm -q {FAKE_4_CUSTOM_PACKAGE_NAME}") assert FAKE_4_CUSTOM_PACKAGE_NAME in result.stdout # Save client info to disk for post-upgrade test save_test_data( { - 'rhel_client': rhel_client.hostname, + 'rhel_client': client_for_upgrade.hostname, 'org_id': module_org.id, } ) @@ -93,8 +108,12 @@ def test_post_scenario_pre_client_package_installation( """ client_hostname = pre_upgrade_data.get('rhel_client') rhel_client = ContentHost.get_host_by_hostname(client_hostname) - module_target_sat.cli.Host.package_install( - {'host-id': rhel_client.nailgun_host.id, 'packages': FAKE_0_CUSTOM_PACKAGE_NAME} + module_target_sat.cli_factory.make_job_invocation( + { + 'job-template': 'Install Package - Katello Script Default', + 'inputs': f'package={FAKE_0_CUSTOM_PACKAGE_NAME}', + 'search-query': f'name ~ {rhel_client.hostname}', + } ) # Verify that package is really installed result = rhel_client.execute(f"rpm -q {FAKE_0_CUSTOM_PACKAGE_NAME}") @@ -115,10 +134,11 @@ class TestScenarioUpgradeNewClientAndPackageInstallation: """ @pytest.mark.post_upgrade + @pytest.mark.rhel_ver_list([8]) def test_post_scenario_post_client_package_installation( self, module_target_sat, - katello_agent_client_for_upgrade, + client_for_upgrade, ): """Post-upgrade test that creates a client, installs a package on the post-upgrade created client and then verifies the package is installed. @@ -140,10 +160,13 @@ def test_post_scenario_post_client_package_installation( the content host is created 3. The package is installed on post-upgrade client """ - rhel_client = katello_agent_client_for_upgrade.client - module_target_sat.cli.Host.package_install( - {'host-id': rhel_client.nailgun_host.id, 'packages': FAKE_0_CUSTOM_PACKAGE_NAME} + module_target_sat.cli_factory.make_job_invocation( + { + 'job-template': 'Install Package - Katello Script Default', + 'inputs': f'package={FAKE_0_CUSTOM_PACKAGE_NAME}', + 'search-query': f'name ~ {client_for_upgrade.hostname}', + } ) # Verifies that package is really installed - result = rhel_client.execute(f"rpm -q {FAKE_0_CUSTOM_PACKAGE_NAME}") + result = client_for_upgrade.execute(f"rpm -q {FAKE_0_CUSTOM_PACKAGE_NAME}") assert FAKE_0_CUSTOM_PACKAGE_NAME in result.stdout