Exemplo n.º 1
0
    def test_post_scenario_yum_plugins_count(self):
        """Upgrade katello agent on pre-upgrade content host registered
        with Satellite.

        :id: postupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:
            1. Create custom tool repo as per upgraded Satellite version and sync.
            2. Add in content-view and publish it.
            2. Update Katello-agent and Restart goferd.
            2. Check yum plugins count.

        :expectedresults:
            1. Loaded yum plugins should not load more than two times.
         """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        product_id = entity_data.get('product_id')
        conten_view_id = entity_data.get('conten_view_id')
        product = entities.Product(id=product_id).read()
        content_view = entities.ContentView(id=conten_view_id).read()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        for repo in (tools_repo, rhel_repo):
            content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()

        self._install_or_update_package(client_container_id, "katello-agent", update=True)
        self._run_goferd(client_container_id)
        self._check_yum_plugins_count(client_container_id)
Exemplo n.º 2
0
    def test_post_crud_virt_who_configuration(self):
        """Virt-who config is intact post upgrade and verify the config can be updated and deleted.

        :id: postupgrade-d7ae7b2b-3291-48c8-b412-cb54e444c7a4

        :steps:
            1. Post upgrade, Verify virt-who exists and has same status.
            2. Verify the connection of the guest on Content host.
            3. Verify the virt-who config-file exists.
            4. Update virt-who config with new name.
            5. Delete virt-who config.

        :expectedresults:
            1. virt-who config is intact post upgrade.
            2. the config and guest connection have the same status.
            3. virt-who config should update and delete successfully.
        """
        org = entities.Organization().search(query={'search': 'name={0}'.format(self.org_name)})[0]

        # Post upgrade, Verify virt-who exists and has same status.
        vhd = entities.VirtWhoConfig(organization_id=org.id).search(
            query={'search': 'name={}'.format(self.name)}
        )[0]
        if not is_open('BZ:1802395'):
            self.assertEqual(vhd.status, 'ok')
        # Verify virt-who status via CLI as we cannot check it via API now
        vhd_cli = VirtWhoConfig.exists(search=('name', self.name))
        self.assertEqual(
            VirtWhoConfig.info({'id': vhd_cli['id']})['general-information']['status'], 'OK'
        )

        # Vefify the connection of the guest on Content host
        entity_data = get_entity_data(self.__class__.__name__)
        hypervisor_name = entity_data.get('hypervisor_name')
        guest_name = entity_data.get('guest_name')
        hosts = [hypervisor_name, guest_name]
        for hostname in hosts:
            result = (
                entities.Host(organization=org.id)
                .search(query={'search': hostname})[0]
                .read_json()
            )
            self.assertEqual(result['subscription_status_label'], 'Fully entitled')

        # Verify the virt-who config-file exists.
        config_file = get_configure_file(vhd.id)
        get_configure_option('hypervisor_id', config_file),

        # Update virt-who config
        modify_name = gen_string('alpha')
        vhd.name = modify_name
        vhd.update(['name'])

        # Delete virt-who config
        vhd.delete()
        self.assertFalse(
            entities.VirtWhoConfig(organization_id=org.id).search(
                query={'search': 'name={}'.format(modify_name)}
            )
        )
Exemplo n.º 3
0
    def test_post_scenario_preclient_package_installation(self):
        """Post-upgrade scenario that installs the package on pre-upgrade
        client remotely and then verifies if the package installed

        :id: postupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps: Install package on a pre-upgrade client

        :expectedresults: The package is installed in client
         """
        client = get_entity_data(self.__class__.__name__)
        client_name = str(list(client.keys())[0]).lower()
        client_id = entities.Host().search(
            query={'search': 'name={}'.format(client_name)}
        )[0].id
        entities.Host().install_content(data={
            'organization_id': self.org.id,
            'included': {'ids': [client_id]},
            'content_type': 'package',
            'content': [self.package_name],
        })
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            list(client.values())[0],
            'rpm -q {}'.format(self.package_name),
            host=self.docker_vm
        )[self.docker_vm]
        self.assertIn(self.package_name, installed_package)
    def test_post_user_scenario_capsule_sync(self):
        """Post-upgrade scenario that sync capsule from satellite and then
        verifies if the repo/rpm of pre-upgrade scenario is synced to capsule


        :id: postupgrade-eb8970fa-98cc-4a99-99fb-1c12c4e319c9

        :steps:
            1. Run capsule sync post upgrade.
            2. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The capsule sync should be successful
            2. The repos/rpms from satellite should be synced to satellite

         """
        env_name = get_entity_data(self.__class__.__name__)['env_name']
        cap_data = hammer.hammer('capsule list')
        cap_id = hammer.get_attribute_value(cap_data, self.cap_host, 'id')
        org_data = hammer.hammer('organization list')
        org_name = hammer.get_attribute_value(org_data, int(self.org_id),
                                              'label')
        print hammer.hammer(
            'capsule content synchronize --id {0}'.format(cap_id))
        result = execute(
            lambda: run('[ -f /var/lib/pulp/published/yum/http/repos/'
                        '{0}/{1}/{2}/custom/{3}/{4}/Packages/b/{5} ]; echo $?'.
                        format(org_name, env_name, self.cv_name, self.
                               prod_name, self.repo_name, self.rpm_name)),
            host=self.cap_host)[self.cap_host]
        self.assertEqual('0', result)
Exemplo n.º 5
0
    def test_post_scenario_preclient_package_installation(default_org):
        """Post-upgrade install of a package on a client created and registered pre-upgrade.

        :id: postupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps: Install package on the pre-upgrade registered client

        :expectedresults: The package is installed on client
        """
        client = get_entity_data(__name__)
        client_name = str(list(client.keys())[0]).lower()
        client_id = entities.Host().search(
            query={'search': f'name={client_name}'})[0].id
        entities.Host().install_content(
            data={
                'organization_id': default_org.id,
                'included': {
                    'ids': [client_id]
                },
                'content_type': 'package',
                'content': [FAKE_0_CUSTOM_PACKAGE],
            })
        # Verifies that package is really installed
        installed_package = execute(
            docker_execute_command,
            list(client.values())[0],
            f'rpm -q {FAKE_0_CUSTOM_PACKAGE}',
            host=docker_vm,
        )[docker_vm]
        assert FAKE_0_CUSTOM_PACKAGE in installed_package
Exemplo n.º 6
0
    def test_post_sync_plan_migration(self):
        """Post-upgrade scenario that tests existing sync plans are working as
        expected after satellite upgrade with migrating from pulp to katello

        :id: badaeec2-d42f-41d5-bd85-4b23d6d5a724

        :steps:
            1. Verify sync plan exists and works as earlier

        :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

         """
        entity_data = get_entity_data(self.__class__.__name__)
        org = entities.Organization(id=entity_data.get('org_id'))
        product = entities.Product(id=entity_data.get("product_id")).read()
        sync_plan = entities.SyncPlan(id=entity_data.get("sync_plan_id"),
                                      organization=org).read()
        self.assertEqual(product.sync_plan.id, sync_plan.id)
        self.assertEqual(sync_plan.name, entity_data.get("sync_plan_name"))
        self.assertEqual(sync_plan.interval, entity_data.get("interval"))
        self.assertEqual(sync_plan.sync_date, entity_data.get("sync_date"))
        # checking sync plan update on upgraded satellite
        sync_plan.interval = SYNC_INTERVAL['custom']
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        self.assertEqual(
            sync_plan.update(['interval', 'cron_expression']).interval,
            SYNC_INTERVAL['custom']
        )
        # checking sync plan delete on upgraded satellite
        sync_plan.delete()
        product = product.read()
        self.assertIsNone(product.sync_plan)
        with self.assertRaises(HTTPError):
            sync_plan.read()
Exemplo n.º 7
0
    def test_post_user_scenario_capsule_sync(self):
        """Post-upgrade scenario that sync capsule from satellite and then
        verifies if the repo/rpm of pre-upgrade scenario is synced to capsule


        :id: postupgrade-eb8970fa-98cc-4a99-99fb-1c12c4e319c9

        :steps:
            1. Run capsule sync post upgrade.
            2. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The capsule sync should be successful
            2. The repos/rpms from satellite should be synced to satellite

         """
        env_name = get_entity_data(self.__class__.__name__)['env_name']
        org_name = (entities.Organization().search(
            query={'search': 'id={}'.format(self.org_id)})[0].label)
        capsule = entities.SmartProxy().search(
            query={'search': 'name={}'.format(self.cap_host)})[0]
        call_entity_method_with_timeout(
            entities.Capsule(id=capsule.id).content_sync, timeout=3600)
        result = execute(
            lambda: run('[ -f /var/lib/pulp/published/yum/http/repos/'
                        '{0}/{1}/{2}/custom/{3}/{4}/Packages/b/{5} ]; echo $?'.
                        format(org_name, env_name, self.cv_name, self.
                               prod_name, self.repo_name, self.rpm_name)),
            host=self.cap_host,
        )[self.cap_host]
        self.assertEqual('0', result)
Exemplo n.º 8
0
    def test_post_scenario_yum_plugins_count(self):
        """Upgrade katello agent on pre-upgrade content host registered
        with Satellite.

        :id: postupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:
            1. Create custom tool repo as per upgraded Satellite version and sync.
            2. Add in content-view and publish it.
            2. Update Katello-agent and Restart goferd.
            2. Check yum plugins count.

        :expectedresults:
            1. Loaded yum plugins should not load more than two times.
         """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        product_id = entity_data.get('product_id')
        conten_view_id = entity_data.get('conten_view_id')
        product = entities.Product(id=product_id).read()
        content_view = entities.ContentView(id=conten_view_id).read()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        for repo in (tools_repo, rhel_repo):
            content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()

        self._install_or_update_package(client_container_id,
                                        "katello-agent",
                                        update=True)
        self._run_goferd(client_container_id)
        self._check_yum_plugins_count(client_container_id)
Exemplo n.º 9
0
    def test_post_user_scenario_capsule_sync(self):
        """Post-upgrade scenario that sync capsule from satellite and then
        verifies if the repo/rpm of pre-upgrade scenario is synced to capsule


        :id: postupgrade-eb8970fa-98cc-4a99-99fb-1c12c4e319c9

        :steps:
            1. Run capsule sync post upgrade.
            2. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The capsule sync should be successful
            2. The repos/rpms from satellite should be synced to satellite

         """
        env_name = get_entity_data(self.__class__.__name__)['env_name']
        org_name = entities.Organization().search(
            query={'search': 'id={}'.format(self.org_id)})[0].label
        capsule = entities.SmartProxy().search(
            query={'search': 'name={}'.format(self.cap_host)})[0]
        entities.Capsule(id=capsule.id).content_sync()
        result = execute(
            lambda: run(
                '[ -f /var/lib/pulp/published/yum/http/repos/'
                '{0}/{1}/{2}/custom/{3}/{4}/Packages/b/{5} ]; echo $?'.format(
                    org_name, env_name, self.cv_name,
                    self.prod_name, self.repo_name, self.rpm_name)),
            host=self.cap_host
        )[self.cap_host]
        self.assertEqual('0', result)
Exemplo n.º 10
0
    def test_post_scenario_remoteexecution_satellite(self):
        """Run a REX job on pre-upgrade created client registered
        with Satellite.

        :id: postupgrade-ad3b1564-d3e6-4ada-9337-3a6ee6863bae

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(
            data={
                'job_template_id': 89,
                'inputs': {
                    'command': "ls"
                },
                'targeting_type': 'static_query',
                'search_query': f"name = {client_name}",
            })
        self.assertEqual(job['output']['success_count'], 1)
        cleanup_of_provisioned_server(hostname=client_name,
                                      provisioning_server=self.libvirt_vm,
                                      distro=DISTRO_RHEL7)
Exemplo n.º 11
0
    def test_post_scenario_remoteexecution_external_capsule(self):
        """Run a REX job on pre-upgrade created client registered
        with external capsule.

        :id: postupgrade-00ed2a25-b0bd-446f-a3fc-09149c57fe94

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(
            data={
                'job_template_id': 89,
                'inputs': {
                    'command': "ls"
                },
                'targeting_type': 'static_query',
                'search_query': "name = {0}".format(client_name)
            })
        self.assertEqual(job['output']['success_count'], 1)
        cleanup_of_provisioned_server(hostname=client_name,
                                      provisioning_server=self.libvirt_vm,
                                      distro=DISTRO_RHEL7)
    def test_post_scenario_preclient_package_installation(self):
        """Post-upgrade scenario that installs the package on pre-upgrade
        client remotely and then verifies if the package installed

        :id: postupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps: Install package on a pre-upgrade client

        :expectedresults: The package is installed in client
         """
        client = get_entity_data(self.__class__.__name__)
        client_name = str(client.keys()[0]).lower()
        client_id = entities.Host().search(
            query={'search': 'name={}'.format(client_name)}
        )[0].id
        entities.Host().install_content(data={
            'organization_id': self.org.id,
            'included': {'ids': [client_id]},
            'content_type': 'package',
            'content': [self.package_name],
        })
        # Holding on for 20 seconds to let the package install
        time.sleep(20)
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            client.values()[0],
            'rpm -q {}'.format(self.package_name),
            host=self.docker_vm
        )[self.docker_vm]
        self.assertIn(self.package_name, installed_package)
Exemplo n.º 13
0
    def test_post_scenario_generate_errata_with_previous_version_katello_agent_client(
            self):
        """Post-upgrade scenario that installs the package on pre-upgraded client
        remotely and then verifies if the package installed and errata counts.

        :id: postupgrade-b61f8f5a-44a3-4d3e-87bb-fc399e03ba6f

        :steps:

            1. Recovered pre_upgrade data for post_upgrade verification.
            2. Verifying errata count has not changed on satellite.
            3. Restart goferd/Katello-agent running.
            4. Verifying the errata_ids.
            5. Verifying installation errata passes successfully.
            6. Verifying that package installation passed successfully by remote docker
                exec.

        :expectedresults:
            1. errata count, erratum list should same after satellite upgrade.
            2. Installation of errata should be pass successfully and check errata counts
                is 0.
        """

        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        custom_repo_id = entity_data.get('custom_repo_id')
        custom_yum_repo = entities.Repository(id=custom_repo_id).read()
        activation_key = entity_data.get('activation_key')
        host = entities.Host().search(
            query={'search': f'activation_key={activation_key}'})[0]

        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        assert installable_errata_count > 1

        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        assert sorted(errata_ids) == sorted(settings.repos.yum_9.errata)

        for errata in settings.repos.yum_9.errata:
            host.errata_apply(data={'errata_ids': [errata]})

        for package in FAKE_9_YUM_UPDATED_PACKAGES:
            install_or_update_package(client_hostname=client_container_id,
                                      package=package)

        # waiting for errata count to become 0, as profile uploading take some
        # amount of time
        wait_for(
            lambda: self._errata_count(ak=activation_key) == 0,
            timeout=400,
            delay=2,
            logger=logger,
        )
        assert self._errata_count(ak=activation_key) == 0
Exemplo n.º 14
0
    def test_post_sync_plan_migration(self):
        """Post-upgrade scenario that tests existing sync plans are working as
        expected after satellite upgrade with migrating from pulp to katello

        :id: badaeec2-d42f-41d5-bd85-4b23d6d5a724

        :steps:
            1. Verify sync plan exists and works as earlier

        :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

         """
        entity_data = get_entity_data(self.__class__.__name__)
        org = entities.Organization(id=entity_data.get('org_id'))
        product = entities.Product(id=entity_data.get("product_id")).read()
        sync_plan = entities.SyncPlan(id=entity_data.get("sync_plan_id"),
                                      organization=org).read()
        self.assertEqual(product.sync_plan.id, sync_plan.id)
        self.assertEqual(sync_plan.name, entity_data.get("sync_plan_name"))
        self.assertEqual(sync_plan.interval, entity_data.get("interval"))
        self.assertEqual(sync_plan.sync_date, entity_data.get("sync_date"))
        # checking sync plan update on upgraded satellite
        sync_plan.interval = SYNC_INTERVAL['custom']
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        self.assertEqual(
            sync_plan.update(['interval', 'cron_expression']).interval,
            SYNC_INTERVAL['custom'])
        # checking sync plan delete on upgraded satellite
        sync_plan.delete()
        product = product.read()
        self.assertIsNone(product.sync_plan)
        with self.assertRaises(HTTPError):
            sync_plan.read()
Exemplo n.º 15
0
    def test_post_version_cv_export_import(self):
        """Export and Import cv version created before upgrade

        :id: postupgrade-f19e4928-94db-4df6-8ce8-b5e4afe34258

        :steps: Export and Import the Content Views version created before upgrade

        :expectedresults: Content-view created before upgrade should be exported and imported
            after upgrade
         """
        prescene_dict = get_entity_data(self.__class__.__name__)
        exporting_cv = entities.ContentView(
            organization=prescene_dict['exporting_orgid']).search(query={
                'search':
                'name={}'.format(prescene_dict['exporting_cvname'])
            })[0]
        exporting_cvv_id = max([cvv.id for cvv in exporting_cv.version])
        exporting_cvv_version = entities.ContentViewVersion(
            id=exporting_cvv_id).read().version
        ContentView.version_export({
            'export-dir': '{}'.format(self.export_base),
            'id': exporting_cvv_id
        })
        exported_tar = '{0}/export-{1}-{2}.tar'.format(self.export_base,
                                                       exporting_cv.name,
                                                       exporting_cvv_version)
        result = ssh.command("[ -f {0} ]".format(exported_tar))
        self.assertEqual(result.return_code, 0)
        exported_packages = Package.list(
            {'content-view-version-id': exporting_cvv_id})
        self.assertTrue(len(exported_packages) > 0)
        self.set_importing_org(
            prescene_dict['exporting_prodname'],
            prescene_dict['exporting_reponame'],
            exporting_cv.name,
        )
        ContentView.version_import({
            'export-tar': exported_tar,
            'organization-id': self.importing_org.id
        })
        importing_cvv = self.importing_cv.read().version
        self.assertTrue(len(importing_cvv) == 1)
        imported_packages = Package.list(
            {'content-view-version-id': importing_cvv[0].id})
        self.assertTrue(len(imported_packages) > 0)
        self.assertEqual(len(exported_packages), len(imported_packages))
        self.tearDownScenario()
Exemplo n.º 16
0
    def test_post_scenario_custom_repo_check(self, default_sat):
        """This is post-upgrade scenario test to verify if we can alter the
        created custom repository and satellite will be able to sync back
        the repo.

        :id: postupgrade-5c793577-e573-46a7-abbf-b6fd1f20b06e

        :steps:
            1. Remove old and add new package into custom repo.
            2. Sync repo , publish the new version of cv.
            3. Try to install new package on client.


        :expectedresults: Content host should able to pull the new rpm.

        """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        content_view_name = entity_data.get('content_view_name')
        lce_id = entity_data.get('lce_id')
        lce_name = entity_data.get('lce_name')
        org_label = entity_data.get('org_label')
        prod_label = entity_data.get('prod_label')
        repo_name = entity_data.get('repo_name')

        create_repo(rpm2, FILE_PATH, post_upgrade=True, other_rpm=rpm1)
        repo = default_sat.api.Repository(name=repo_name).search()[0]
        repo.sync()

        content_view = default_sat.api.ContentView(
            name=content_view_name).search()[0]
        content_view.publish()

        content_view = default_sat.api.ContentView(
            name=content_view_name).search()[0]
        promote(content_view.version[-1], lce_id)

        result = default_sat.execute(
            'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/'
            'Packages/c/| grep {}'.format(org_label, lce_name,
                                          content_view.label, prod_label,
                                          repo.label, RPM2_NAME))
        assert result.status == 0
        assert len(result.stdout)
        install_or_update_package(client_hostname=client_container_id,
                                  package=RPM2_NAME)
Exemplo n.º 17
0
    def test_post_subscription_scenario_autoattach(self):
        """Run subscription auto-attach on pre-upgrade content host registered
        with Satellite.

        :id: postupgrade-940fc78c-ffa6-4d9a-9c4b-efa1b9480a22

        :steps:
            1. Run subscription auto-attach on content host.

        :expectedresults:
            1. Pre-upgrade content host should get Subscribed.
         """
        client_container_id = get_entity_data(self.__class__.__name__)['client_container_id']
        subscription = execute(docker_execute_command, client_container_id,
                               'subscription-manager attach --auto',
                               host=self.docker_vm)[self.docker_vm]
        self.assertIn('Subscribed', subscription)
Exemplo n.º 18
0
    def test_post_scenario_custom_repo_check(self):
        """This is post-upgrade scenario test to verify if we can alter the
        created custom repository and satellite will be able to sync back
        the repo.

        :id: postupgrade-5c793577-e573-46a7-abbf-b6fd1f20b06e

        :steps:
            1. Remove old and add new package into custom repo.
            2. Sync repo , publish the new version of cv.
            3. Try to install new package on client.


        :expectedresults: Content host should able to pull the new rpm.

        """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        content_view_name = entity_data.get('content_view_name')
        lce_id = entity_data.get('lce_id')
        lce_name = entity_data.get('lce_name')
        org_label = entity_data.get('org_label')
        prod_label = entity_data.get('prod_label')
        repo_name = entity_data.get('repo_name')

        self._create_repo(post_upgrade=True)
        repo = entities.Repository(name=repo_name).search()[0]
        repo.sync()

        content_view = entities.ContentView(name=content_view_name).search()[0]
        content_view.publish()

        content_view = entities.ContentView(name=content_view_name).search()[0]
        promote(content_view.version[-1], lce_id)

        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/'
            'Packages/c/| grep {}'.format(org_label, lce_name,
                                          content_view.label, prod_label,
                                          repo.label, self.rpm2_name))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)

        self._install_package(client_container_id, self.rpm2_name)
Exemplo n.º 19
0
    def test_post_puppet_class_parameter_data_and_type(self):
        """Puppet Class Parameters value and type is intact post upgrade

        :steps: Postupgrade, Verify the value and type of updated parameters

        :expectedresults: The puppet class parameters data and type should be
            intact post upgrade
        """
        for count in range(1, 10):
            with self.subTest(count):
                data = _valid_sc_parameters_data()[count-1]
                sc_param = entities.SmartClassParameters().search(query={
                   'search': 'parameter="api_classparameters_scp_00{}"'.format(
                        count)})[0]
                self.assertEqual(sc_param.parameter_type, data['sc_type'])
                self._validate_value(data, sc_param)
        puppet_class = get_entity_data(self.__class__.__name__)['puppet_class']
        delete_puppet_class(puppet_class)
Exemplo n.º 20
0
    def test_post_scenario_remoteexecution_satellite(self):
        """Run a REX job on pre-upgrade created client registered
        with Satellite.

        :id: postupgrade-ad3b1564-d3e6-4ada-9337-3a6ee6863bae

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(data={
            'job_template_id': 89, 'inputs': {'command': "ls"},
            'targeting_type': 'static_query', 'search_query': "name = {0}".format(client_name)})
        self.assertEqual(job['output']['success_count'], 1)
        self._vm_cleanup(hostname=client_name)
Exemplo n.º 21
0
    def test_post_scenario_remoteexecution_external_capsule(self):
        """Run a REX job on pre-upgrade created client registered
        with external capsule.

        :id: postupgrade-00ed2a25-b0bd-446f-a3fc-09149c57fe94

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(data={
            'job_template_id': 89, 'inputs': {'command': "ls"},
            'targeting_type': 'static_query', 'search_query': "name = {0}".format(client_name)})
        self.assertEqual(job['output']['success_count'], 1)
        self._vm_cleanup(hostname=client_name)
Exemplo n.º 22
0
    def test_post_scenario_yum_plugins_count(self, default_org):
        """Upgrade katello agent on pre-upgrade content host registered
        with Satellite.

        :id: postupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:
            1. Create Product, custom tools repo and sync them.
            2. Add in content-view and publish it.
            3. Attach custom subscription to content host.
            4. Install katello-host-tools, so enabled_repos_upload yum plugin is enabled.
            4. Update katello-agent and Restart goferd.
            5. Check yum plugins count.

        :expectedresults:
            1. Loaded yum plugins should not load more than two times.
        """

        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        client_container_name = list(client.keys())[0]
        cv = entities.ContentView(id=entity_data.get('cv_id')).read()
        product = entities.Product(organization=default_org).create()

        tools_repo = self._create_custom_tools_repos(product)
        product.sync()

        cv.repository.pop()
        cv.repository.append(tools_repo)
        cv = cv.update(['repository'])
        call_entity_method_with_timeout(cv.publish, timeout=3400)

        attach_custom_product_subscription(prod_name=product.name,
                                           host_name=client_container_name)
        install_or_update_package(client_hostname=client_container_id,
                                  update=True,
                                  package='katello-host-tools')
        install_or_update_package(client_hostname=client_container_id,
                                  update=True,
                                  package='katello-agent')
        run_goferd(client_hostname=client_container_id)
        self._check_yum_plugins_count(client_container_id)
Exemplo n.º 23
0
    def test_post_repository_scenario_upstream_authorization(self):
        """Verify upstream username for pre-upgrade created repository.

        :id: postupgrade-11c5ceee-bfe0-4ce9-8f7b-67a835baf522

        :steps:
            1. Verify upstream username for pre-upgrade created repository using
            foreman-rake.

        :expectedresults:
            1. upstream username should not exists on same repository.

        :BZ: 1641785
        """

        repo_id = get_entity_data(self.__class__.__name__)['repo_id']
        rake_repo = f'repo = Katello::RootRepository.find_by_id({repo_id})'
        rake_username = '******'
        result = run(f"echo '{rake_repo}{rake_username}'|foreman-rake console")
        assert UPSTREAM_USERNAME not in result
Exemplo n.º 24
0
    def test_post_repository_scenario_upstream_authorization(self):
        """ Verify upstream username for pre-upgrade created repository.

        :id: postupgrade-11c5ceee-bfe0-4ce9-8f7b-67a835baf522

        :steps:
            1. Verify upstream username for pre-upgrade created repository using
            foreman-rake.

        :expectedresults:
            1. upstream username should not exists on same repository.

        :BZ: 1641785
        """

        repo_id = get_entity_data(self.__class__.__name__)['repo_id']
        rake_repo = 'repo = Katello::RootRepository.find_by_id({0})'.format(repo_id)
        rake_username = '******'
        result = run("echo '{0}{1}'|foreman-rake console".format(rake_repo, rake_username))
        self.assertNotIn(self.upstream_username, result)
Exemplo n.º 25
0
    def test_post_scenario_remoteexecution_satellite(self):
        """Run a REX job on pre-upgrade created client registered
        with Satellite.

        :id: postupgrade-ad3b1564-d3e6-4ada-9337-3a6ee6863bae

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(
            data={
                'job_template_id': 89,
                'inputs': {'command': 'ls'},
                'targeting_type': 'static_query',
                'search_query': f'name = {client_name}',
            }
        )
        assert job['output']['success_count'] == 1
Exemplo n.º 26
0
    def test_post_repository_scenario_upstream_authorization(self):
        """ Verify upstream username for pre-upgrade created repository.

        :id: postupgrade-11c5ceee-bfe0-4ce9-8f7b-67a835baf522

        :steps:
            1. Verify upstream username for pre-upgrade created repository using
            foreman-rake.

        :expectedresults:
            1. upstream username should not exists on same repository.

        :BZ: 1641785
        """

        repo_id = get_entity_data(self.__class__.__name__)['repo_id']
        rake_repo = 'repo = Katello::RootRepository.find_by_id({0})'.format(
            repo_id)
        rake_username = '******'
        result = run("echo '{0}{1}'|foreman-rake console".format(
            rake_repo, rake_username))
        self.assertNotIn(self.upstream_username, result)
Exemplo n.º 27
0
    def test_post_scenario_remoteexecution_external_capsule(self):
        """Run a REX job on pre-upgrade created client registered
        with external capsule.

        :id: postupgrade-00ed2a25-b0bd-446f-a3fc-09149c57fe94

        :steps:
            1. Run a REX job on content host.

        :expectedresults:
            1. The job should successfully executed on pre-upgrade created client.
        """
        client_name = get_entity_data(self.__class__.__name__)['client_name']
        job = entities.JobInvocation().run(
            data={
                'job_template_id': 89,
                'inputs': {'command': 'ls'},
                'targeting_type': 'static_query',
                'search_query': f'name = {client_name}',
            }
        )
        assert job['output']['success_count'] == 1
Exemplo n.º 28
0
 def test_post_create_gce_cr_and_host(self, arch_os_domain, delete_host):
     """"""
     arch, os, domain_name = arch_os_domain
     hostname = gen_string('alpha')
     self.__class__.fullhost = f'{hostname}.{domain_name}'.lower()
     preentities = get_entity_data(self.__class__.__name__)
     gce_cr = entities.GCEComputeResource().search(
         query={'search': f'name={preentities["cr_name"]}'})[0]
     org = entities.Organization().search(
         query={'search': f'name={preentities["org"]}'})[0]
     loc = entities.Location().search(
         query={'search': f'name={preentities["loc"]}'})[0]
     compute_attrs = {
         'machine_type': 'g1-small',
         'network': 'default',
         'associate_external_ip': True,
         'volumes_attributes': {
             '0': {
                 'size_gb': '10'
             }
         },
         'image_id': LATEST_RHEL7_GCE_IMG_UUID,
     }
     # Host Provisioning Tests
     try:
         skip_yum_update_during_provisioning(
             template='Kickstart default finish')
         gce_hst = entities.Host(
             name=hostname,
             organization=org,
             location=loc,
             root_pass=gen_string('alphanumeric'),
             architecture=arch,
             compute_resource=gce_cr,
             domain=entities.Domain().search(
                 query={'search': f'name={domain_name}'})[0],
             compute_attributes=compute_attrs,
             operatingsystem=os,
             provision_method='image',
         ).create()
     finally:
         skip_yum_update_during_provisioning(
             template='Kickstart default finish', reverse=True)
     wait_for(
         lambda: entities.Host().search(query={
             'search': f'name={self.fullhost}'
         })[0].build_status_label == 'Installed',
         timeout=400,
         delay=15,
         silent_failure=True,
         handle_exception=True,
     )
     assert gce_hst.name == self.fullhost
     gce_hst = entities.Host(id=gce_hst.id).read()
     assert gce_hst.build_status_label == 'Installed'
     # CR Manipulation Tests
     newgce_name = gen_string('alpha')
     newgce_zone = random.choice(VALID_GCE_ZONES)
     gce_cr.name = newgce_name
     gce_cr.zone = newgce_zone
     gce_cr.update(['name', 'zone'])
     gce_cr = entities.GCEComputeResource(id=gce_cr.id).read()
     assert gce_cr.name == newgce_name
     assert gce_cr.zone == newgce_zone
Exemplo n.º 29
0
    def test_post_user_scenario_bug_1429201(self):
        """This is post-upgrade scenario test to verify if we can alter the
        created custom repository and satellite will be able to sync back
        the repo

        :id: 9415c3e5-4699-462f-81bc-4143d8b820f1

        :steps:
            1. Remove PackageFoo-1.0.rpm from RepoFoo
            2. Add PackageFoo-2.0.rpm to RepoFoo
            3. Sync RepoFoo
            4. Publish version 2 of CVFoo
            5. Delete version 1 of CVFoo
            6. run /etc/cron.weekly/katello-remove-orphans
            7. Subscribe ClientA to CVFoo
            8. Try to install PackageFoo-1.0.rpm on ClientA
            9. Notice that yum thinks it's there based on the repo metadata
               but then fails to download it with 404
            10. Try to install PackageFoo-2.0.rpm

        :expectedresults: The clients is present after upgrade and deleted
            rpm is unable to be fetched, while new rpm is pulled and installed
            on client

        :BZ: 1429201
        """
        entity_data = get_entity_data(self.__class__.__name__)
        run('wget {0} -P {1}'.format(rpm2, self.file_path))
        run('rm -rf {0}'.format(self.file_path + self.rpm1_name))
        run('createrepo --update {0}'.format(self.file_path))
        # get entities from pickle
        pkcl_ak_name = entity_data['ak_name']
        container_ids = entity_data['container_ids']
        repo_name = entity_data['repo_name']
        prd_name = entity_data['prd_name']
        cv_name, lc_name = hammer.hammer_determine_cv_and_env_from_ak(
            pkcl_ak_name, self.org_id)
        # Info on created entities to assert the test case using hammer info
        ak_info = hammer.hammer('"{0}" info --name "{1}" --organization-id '
                                '{2}'.format('activation-key', pkcl_ak_name,
                                             self.org_id))
        print(
            hammer.hammer_repository_synchronize(repo_name, self.org_id,
                                                 prd_name))
        print(hammer.hammer_content_view_publish(cv_name, self.org_id))
        latest_repo_version = hammer.get_latest_cv_version(cv_name)

        result = hammer.hammer('"{0}" info --name "{1}" --organization-id '
                               '{2}'.format('lifecycle-environment', lc_name,
                                            self.org_id))
        lifecycle_id = hammer.get_attribute_value(result, lc_name, 'id')
        print(
            hammer.hammer_content_view_promote_version(cv_name,
                                                       latest_repo_version,
                                                       lifecycle_id,
                                                       self.org_id))
        hammer.hammer('content-view remove --content-view-version-ids {0}'
                      ' --name "{1}" --organization-id {2}'.format(
                          latest_repo_version, cv_name, self.org_id))
        run('foreman-rake katello:delete_orphaned_content')
        execute(refresh_subscriptions_on_docker_clients,
                list(container_ids.values()),
                host=self.docker_vm)
        # Subscription manager needs time to register
        execute(docker_wait_until_repo_list,
                list(container_ids.values())[0],
                host=self.docker_vm)
        result_fail = execute(docker_execute_command,
                              list(container_ids.values())[0],
                              'yum list {0} | grep {0}'.format(
                                  self.rpm1_name.split('-')[0]),
                              quiet=True,
                              host=self.docker_vm)  # should be error
        result_pass = execute(docker_execute_command,
                              list(container_ids.values())[0],
                              'yum install -y {0}'.format(
                                  self.rpm2_name.split('-')[0]),
                              host=self.docker_vm)  # should be successful
        self.assertEqual(
            pkcl_ak_name,
            hammer.get_attribute_value(ak_info, pkcl_ak_name, 'name'))
        self.assertIsNotNone(container_ids)
        self.assertIn('Error', list(result_fail.values())[0])
        self.assertIn('Complete', list(result_pass.values())[0])
Exemplo n.º 30
0
    def test_post_scenario_errata_count_installation(self):
        """Post-upgrade scenario that installs the package on pre-upgrade
        client remotely and then verifies if the package installed.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Recovered pre_upgrade data for post_upgrade verification
            2. Verifying errata count has not changed on satellite
            3. Update Katello-agent and Restart goferd
            4. Verifying the errata_ids
            5. Verifying installation errata passes successfully
            6. Verifying that package installation passed successfully by remote docker
                exec

        :expectedresults:
            1. errata count, erratum list should same after satellite upgrade
            2. Installation of errata should be pass successfully
        """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        custom_repo_id = entity_data.get('custom_repo_id')
        product_id = entity_data.get('product_id')
        conten_view_id = entity_data.get('conten_view_id')
        product = entities.Product(id=product_id).read()
        content_view = entities.ContentView(id=conten_view_id).read()
        custom_yum_repo = entities.Repository(id=custom_repo_id).read()
        activation_key = entity_data.get('activation_key')
        host = entities.Host().search(
            query={'search': f'activation_key={activation_key}'})[0]

        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        call_entity_method_with_timeout(product.sync, timeout=1400)
        for repo in (tools_repo, rhel_repo):
            content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        install_or_update_package(client_hostname=client_container_id,
                                  update=True,
                                  package="katello-agent")

        run_goferd(client_hostname=client_container_id)
        assert installable_errata_count > 1

        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        assert sorted(errata_ids) == sorted(settings.repos.yum_9.errata)

        for errata in settings.repos.yum_9.errata:
            host.errata_apply(data={'errata_ids': [errata]})
            installable_errata_count -= 1

        # waiting for errata count to become 0, as profile uploading take some
        # amount of time
        wait_for(
            lambda: self._errata_count(ak=activation_key) == 0,
            timeout=400,
            delay=2,
            logger=logger,
        )
        host = entities.Host().search(
            query={'search': f'activation_key={activation_key}'})[0]
        assert host.content_facet_attributes['errata_counts']['total'] == 0
        for package in FAKE_9_YUM_UPDATED_PACKAGES:
            install_or_update_package(client_hostname=client_container_id,
                                      package=package)
Exemplo n.º 31
0
    def test_post_user_scenario_bug_1429201(self):
        """This is post-upgrade scenario test to verify if we can alter the
        created custom repository and satellite will be able to sync back
        the repo

        :id: 9415c3e5-4699-462f-81bc-4143d8b820f1

        :steps:
            1. Remove PackageFoo-1.0.rpm from RepoFoo
            2. Add PackageFoo-2.0.rpm to RepoFoo
            3. Sync RepoFoo
            4. Publish version 2 of CVFoo
            5. Delete version 1 of CVFoo
            6. run /etc/cron.weekly/katello-remove-orphans
            7. Subscribe ClientA to CVFoo
            8. Try to install PackageFoo-1.0.rpm on ClientA
            9. Notice that yum thinks it's there based on the repo metadata
               but then fails to download it with 404
            10. Try to install PackageFoo-2.0.rpm

        :expectedresults: The clients is present after upgrade and deleted
            rpm is unable to be fetched, while new rpm is pulled and installed
            on client

        :BZ: 1429201
        """
        entity_data = get_entity_data(self.__class__.__name__)
        run('wget {0} -P {1}'.format(rpm2, self.file_path))
        run('rm -rf {0}'.format(self.file_path + self.rpm1_name))
        run('createrepo --update {0}'.format(self.file_path))
        # get entities from pickle
        pkcl_ak_name = entity_data['ak_name']
        container_ids = entity_data['container_ids']
        repo_name = entity_data['repo_name']
        prd_name = entity_data['prd_name']
        cv_name, lc_name = hammer.hammer_determine_cv_and_env_from_ak(
            pkcl_ak_name,
            self.org_id
        )
        # Info on created entities to assert the test case using hammer info
        ak_info = hammer.hammer(
            '"{0}" info --name "{1}" --organization-id '
            '{2}'.format('activation-key', pkcl_ak_name, self.org_id)
        )
        print(hammer.hammer_repository_synchronize(
            repo_name,
            self.org_id,
            prd_name
        ))
        print(hammer.hammer_content_view_publish(cv_name, self.org_id))
        latest_repo_version = hammer.get_latest_cv_version(cv_name)

        result = hammer.hammer(
            '"{0}" info --name "{1}" --organization-id '
            '{2}'.format('lifecycle-environment', lc_name, self.org_id)
        )
        lifecycle_id = hammer.get_attribute_value(result, lc_name, 'id')
        print(hammer.hammer_content_view_promote_version(
            cv_name,
            latest_repo_version,
            lifecycle_id,
            self.org_id
        ))
        hammer.hammer(
            'content-view remove --content-view-version-ids {0}'
            ' --name "{1}" --organization-id {2}'.format(
                latest_repo_version,
                cv_name,
                self.org_id
            )
        )
        run('foreman-rake katello:delete_orphaned_content')
        execute(refresh_subscriptions_on_docker_clients,
                list(container_ids.values()),
                host=self.docker_vm
                )
        # Subscription manager needs time to register
        execute(docker_wait_until_repo_list,
                list(container_ids.values())[0],
                host=self.docker_vm)
        result_fail = execute(
            docker_execute_command,
            list(container_ids.values())[0],
            'yum list {0} | grep {0}'.format(self.rpm1_name.split('-')[0]),
            quiet=True,
            host=self.docker_vm
        )  # should be error
        result_pass = execute(
            docker_execute_command,
            list(container_ids.values())[0],
            'yum install -y {0}'.format(self.rpm2_name.split('-')[0]),
            host=self.docker_vm
        )  # should be successful
        self.assertEqual(
            pkcl_ak_name,
            hammer.get_attribute_value(ak_info, pkcl_ak_name, 'name')
        )
        self.assertIsNotNone(container_ids)
        self.assertIn('Error', list(result_fail.values())[0])
        self.assertIn('Complete', list(result_pass.values())[0])
Exemplo n.º 32
0
 def _cleanup():
     puppet_class = get_entity_data(
         self.__class__.__name__)['puppet_class']
     delete_puppet_class(puppet_class)
Exemplo n.º 33
0
    def test_post_scenario_containers_support_removal(self):
        """Post-upgrade scenario test to verify containers created and run
        before upgrade are still running after upgrade.

        :id: postupgrade-f6de07ae-14c7-4452-9cb1-cafe2aa648ae

        :steps:

            1. Verify that upgrade procedure removed foreman_docker support
            2. Verify container from dockerhub is still running
            3. Verify container from external registry is still running

        :expectedresults:

            1. Upgrade procedure removed support for foreman_docker
            2. Container from dockerhub is still running
            3. Container from external registry is still running

        """
        entity_data = get_entity_data(self.__class__.__name__)
        rh_registry_available = entity_data.get('rh_registry_available')
        docker_host_hostname = entity_data.get('docker_host')
        dockerhub_container = entity_data.get('dockerhub_container')
        external_container = entity_data.get('external_container')

        try:
            extract_log_command = "sed -n '/{delimiter}/,/{delimiter}/p' {path}".format(
                delimiter="RemoveForemanDockerSupport",
                path="/var/log/foreman-installer/satellite.log")
            docker_log = ssh.command(extract_log_command,
                                     output_format='plain')
            self.assertEqual(docker_log.return_code, 0)

            docker_log = docker_log.stdout.split("\n")

            self.assertTrue(
                any("RemoveForemanDockerSupport: migrated" in line
                    for line in docker_log))
            self.assertTrue(
                any("remove_column(:containers, :capsule_id)" in line
                    for line in docker_log))

            removed_tables = ('docker_images', 'docker_tags',
                              'docker_container_wizard_states_images',
                              'containers')

            for table in removed_tables:
                self.assertTrue(
                    any("table_exists?(:{})".format(table) in line
                        for line in docker_log))

            running_containers = ssh.command('docker ps',
                                             hostname=docker_host_hostname)
            self.assertEqual(running_containers.return_code, 0)

            self.assertTrue(
                any(dockerhub_container in line
                    for line in running_containers.stdout))
            if rh_registry_available:
                self.assertTrue(
                    any(external_container in line
                        for line in running_containers.stdout))
        except Exception as exp:
            self._vm_cleanup(hostname=docker_host_hostname)
            raise Exception(exp)

        self._vm_cleanup(hostname=docker_host_hostname)
Exemplo n.º 34
0
    def test_post_scenario_errata_count_installtion(self):
        """Post-upgrade scenario that installs the package on pre-upgrade
        client remotely and then verifies if the package installed.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Recovered pre_upgrade data for post_upgrade verification
            2. Verifying errata count has not changed on satellite
            3. Update Katello-agent and Restart goferd
            4. Verifying the errata_ids
            5. Verifying installation errata passes successfully
            6. Verifying that package installation passed successfully by remote docker exec

        :expectedresults:
            1. errata count, erratum list should same after satellite upgrade
            2. Installation of errata should be pass successfully
         """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        custom_repo_id = entity_data.get('custom_repo_id')
        product_id = entity_data.get('product_id')
        conten_view_id = entity_data.get('conten_view_id')
        product = entities.Product(id=product_id).read()
        content_view = entities.ContentView(id=conten_view_id).read()
        custom_yum_repo = entities.Repository(id=custom_repo_id).read()
        activation_key = entity_data.get('activation_key')
        host = entities.Host().search(
            query={'search': 'activation_key={0}'.format(activation_key)})[0]

        applicable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        for repo in (tools_repo, rhel_repo):
            content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()
        content_view = content_view.read()

        self._install_or_update_package(client_container_id,
                                        "katello-agent",
                                        update=True)
        self._run_goferd(client_container_id)
        self.assertGreater(applicable_errata_count, 1)

        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000,
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        self.assertEqual(sorted(errata_ids), sorted(FAKE_9_YUM_ERRATUM))

        for errata in FAKE_9_YUM_ERRATUM:
            host.errata_apply(data={'errata_ids': [errata]})
            applicable_errata_count -= 1
        self.assertEqual(
            host.content_facet_attributes['errata_counts']['total'], 0)
        for package in FAKE_9_YUM_UPDATED_PACKAGES:
            self._check_package_installed(client_container_id, package)
Exemplo n.º 35
0
    def test_post_scenario_errata_count_installtion(self):
        """Post-upgrade scenario that installs the package on pre-upgrade
        client remotely and then verifies if the package installed.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Recovered pre_upgrade data for post_upgrade verification
            2. Verifying errata count has not changed on satellite
            3. Update Katello-agent and Restart goferd
            4. Verifying the errata_ids
            5. Verifying installation errata passes successfully
            6. Verifying that package installation passed successfully by remote docker exec

        :expectedresults:
            1. errata count, erratum list should same after satellite upgrade
            2. Installation of errata should be pass successfully
         """
        entity_data = get_entity_data(self.__class__.__name__)
        client = entity_data.get('rhel_client')
        client_container_id = list(client.values())[0]
        custom_repo_id = entity_data.get('custom_repo_id')
        product_id = entity_data.get('product_id')
        conten_view_id = entity_data.get('conten_view_id')
        product = entities.Product(id=product_id).read()
        content_view = entities.ContentView(id=conten_view_id).read()
        custom_yum_repo = entities.Repository(id=custom_repo_id).read()
        activation_key = entity_data.get('activation_key')
        host = entities.Host().search(query={
            'search': 'activation_key={0}'.format(activation_key)})[0]

        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        for repo in (tools_repo, rhel_repo):
            content_view.repository.append(repo)
        content_view = content_view.update(['repository'])
        content_view.publish()

        self._install_or_update_package(client_container_id,
                                        "katello-agent",
                                        update=True)
        self._run_goferd(client_container_id)
        self.assertGreater(installable_errata_count, 1)

        erratum_list = entities.Errata(repository=custom_yum_repo).search(query={
            'order': 'updated ASC',
            'per_page': 1000,
        })
        errata_ids = [errata.errata_id for errata in erratum_list]
        self.assertEqual(sorted(errata_ids), sorted(FAKE_9_YUM_ERRATUM))

        for errata in FAKE_9_YUM_ERRATUM:
            host.errata_apply(data={'errata_ids': [errata]})
            installable_errata_count -= 1

        # waiting for errata count to become 0, as profile uploading take some amount of time
        wait_for(
            lambda: self._errata_count(ak=activation_key) == 0,
            timeout=200,
            delay=10,
            logger=self.logger
        )
        self.assertEqual(
            host.content_facet_attributes['errata_counts']['total'],
            0
        )
        for package in FAKE_9_YUM_UPDATED_PACKAGES:
            self._check_package_installed(client_container_id, package)