示例#1
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')

        create_repo(rpm2, FILE_PATH, post_upgrade=True, other_rpm=rpm1)
        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, RPM2_NAME))
        assert result.return_code == 0
        assert len(result.stdout) >= 1
        install_or_update_package(client_hostname=client_container_id,
                                  package=RPM2_NAME)
示例#2
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)
示例#3
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)
示例#4
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)
示例#5
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)
示例#6
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)
示例#7
0
    def test_pre_scenario_yum_plugins_count(self, default_org):
        """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-host-tools and katello-agent.

        :expectedresults:

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

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=default_org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        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

        install_or_update_package(client_hostname=client_container_id,
                                  package='katello-host-tools')
        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)