Пример #1
0
    def test_pre_scenario_yum_plugins_count(self):
        """Create content host and register with Satellite.

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

        :steps:

            1. Before Satellite upgrade.
            2. Create LifecycleEnvironment.
            3. Enable/sync 'base os RHEL7' and tools repos.
            4. Create 'Content View' and activation key.
            5. Create a content host, register and install katello-agent on it.

        :expectedresults:

            1. The content host is created.
            2. katello-agent install and goferd run.
        """
        environment = entities.LifecycleEnvironment(
            organization=self.org).search(query={'search': 'name=Library'})[0]
        repos = self._get_rh_rhel_tools_repos()
        content_view = publish_content_view(org=self.org, repolist=repos)
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=self.org.id,
                                    environment=environment).create()

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=self.org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        wait_for(
            lambda: self.org.label in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=self.docker_vm,
            )[self.docker_vm],
            timeout=800,
            delay=2,
            logger=self.logger,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=self.docker_vm,
        )[self.docker_vm]
        self.assertIn(self.org.label, status)

        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'cv_id': content_view.id
            }
        }
        create_dict(scenario_dict)
Пример #2
0
    def test_pre_scenario_generate_errata_with_previous_version_katello_agent_client(
            self, default_org):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

        :id: preupgrade-4e515f84-2582-4b8b-a625-9f6c6966aa59

        :steps:

            1. Create Life Cycle Environment, Product and Custom Yum Repo.
            2. Enable/sync 'base os RHEL7' and tools repos.
            3. Create a content view and publish it.
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7.
            6. Install and check katello agent and goferd service running on host.
            7. Generate Errata by Installing Outdated/Older Packages.
            8. Collect the Erratum list.

        :expectedresults:

            1. The content host is created.
            2. errata count, erratum list will be generated to satellite client/content host.

        """
        environment = entities.LifecycleEnvironment(
            organization=default_org).search(
                query={'search': 'name=Library'})[0]

        product = entities.Product(organization=default_org).create()
        custom_yum_repo = entities.Repository(
            product=product, content_type='yum',
            url=settings.repos.yum_9.url).create()
        call_entity_method_with_timeout(product.sync, timeout=1400)

        repos = self._get_rh_rhel_tools_repos(default_org)
        repos.append(custom_yum_repo)
        content_view = publish_content_view(org=default_org, repolist=repos)
        custom_sub = entities.Subscription(organization=default_org).search(
            query={'search': f'name={product.name}'})[0]
        rh_sub = entities.Subscription(organization=1).search(
            query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'})[0]

        ak = entities.ActivationKey(
            content_view=content_view,
            organization=default_org.id,
            environment=environment,
            auto_attach=False,
        ).create()
        ak.add_subscriptions(data={'subscription_id': custom_sub.id})
        ak.add_subscriptions(data={'subscription_id': rh_sub.id})

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=default_org.label)
        client_container_id = list(rhel7_client.values())[0]

        docker_vm = settings.upgrade.docker_vm
        wait_for(
            lambda: default_org.label in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=docker_vm,
            )[docker_vm],
            timeout=800,
            delay=2,
            logger=logger,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=docker_vm,
        )[docker_vm]

        assert default_org.label in status

        # Update OS to make errata count 0
        execute(docker_execute_command,
                client_container_id,
                'yum update -y',
                host=docker_vm)[docker_vm]
        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            install_or_update_package(client_hostname=client_container_id,
                                      package=package)
        host = entities.Host().search(
            query={'search': f'activation_key={ak.name}'})[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)
        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'activation_key': ak.name,
                'custom_repo_id': custom_yum_repo.id,
                'product_id': product.id,
            }
        }
        create_dict(scenario_dict)
Пример #3
0
    def test_pre_scenario_generate_errata_for_client(self):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

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

        :steps:

            1. Create  Life Cycle Environment, Product and Custom Yum Repo
            2. Create custom tools, rhel repos and sync them
            3. Create content view and publish it
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7
            6. Check katello agent and goferd service running on host
            7. Generate Errata by Installing Outdated/Older Packages
            8. Collect the Erratum list

        :expectedresults:

            1. The content host is created
            2. errata count, erratum list will be generated to satellite client/content
                host

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        environment = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'})[0]

        product = entities.Product(organization=org).create()
        custom_yum_repo = entities.Repository(
            product=product, content_type='yum',
            url=settings.repos.yum_9.url).create()
        product.sync()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        repolist = [custom_yum_repo, tools_repo, rhel_repo]
        content_view = publish_content_view(org=org, repolist=repolist)
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=environment).create()
        subscription = entities.Subscription(organization=org).search(
            query={'search': f'name={product.name}'})[0]

        ak.add_subscriptions(data={'subscription_id': subscription.id})
        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        host_location_update(client_container_name=client_container_name,
                             logger_obj=logger,
                             loc=loc)

        docker_vm = settings.upgrade.docker_vm
        wait_for(
            lambda: org.name in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=docker_vm,
            )[docker_vm],
            timeout=800,
            delay=2,
            logger=logger,
        )
        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

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

        host = entities.Host().search(
            query={'search': f'activation_key={ak.name}'})[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)
        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'activation_key': ak.name,
                'custom_repo_id': custom_yum_repo.id,
                'product_id': product.id,
                'conten_view_id': content_view.id,
            }
        }
        create_dict(scenario_dict)
Пример #4
0
    def test_pre_scenario_custom_repo_check(self):
        """This is pre-upgrade scenario test to verify if we can create a
         custom repository and consume it via content host.

        :id: preupgrade-eb6831b1-c5b6-4941-a325-994a09467478

        :steps:
            1. Before Satellite upgrade.
            2. Create new Organization, Location.
            3. Create Product, custom repo, cv.
            4. Create activation key and add subscription.
            5. Create a content host, register and install package on it.

        :expectedresults:

            1. Custom repo is created.
            2. Package is installed on Content host.

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        lce = entities.LifecycleEnvironment(organization=org).create()

        product = entities.Product(organization=org).create()
        create_repo(rpm1, FILE_PATH)
        repo = entities.Repository(product=product.id,
                                   url=CUSTOM_REPO).create()
        repo.sync()

        content_view = publish_content_view(org=org, repolist=repo)
        promote(content_view.version[0], lce.id)

        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/'
            'Packages/b/|grep {}'.format(org.label, lce.name,
                                         content_view.label, product.label,
                                         repo.label, RPM1_NAME))

        assert result.return_code == 0
        assert len(result.stdout) >= 1

        subscription = entities.Subscription(organization=org).search(
            query={'search': f'name={product.name}'})[0]
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=lce).create()
        ak.add_subscriptions(data={'subscription_id': subscription.id})

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]

        host_location_update(client_container_name=client_container_name,
                             logger_obj=logger,
                             loc=loc)
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=DOCKER_VM,
        )[DOCKER_VM]
        assert org.name in status
        install_or_update_package(client_hostname=client_container_id,
                                  package=RPM1_NAME)

        scenario_dict = {
            self.__class__.__name__: {
                'content_view_name': content_view.name,
                'lce_id': lce.id,
                'lce_name': lce.name,
                'org_label': org.label,
                'prod_label': product.label,
                'rhel_client': rhel7_client,
                'repo_name': repo.name,
            }
        }
        create_dict(scenario_dict)