コード例 #1
0
    def test_positive_include_exclude_module_stream_filter(
            self, content_view_module_stream):
        """Verify Include and Exclude Errata filter(modular errata) automatically force the copy
           of the module streams associated to it.

        :id: 20540722-b163-4ebb-b18d-351444ef0c86

        :steps:
            1. Create Include Errata filter
            2. Publish content view, Verify errata and stream count.
            3. Delete Filter (As we can not update the filter inclusion type)
            4. Create Exclude Errata filter
            5. Publish content view, Verify errata and stream count

        :expectedresults: Module Stream count changes automatically after including or
            excluding modular errata

        :CaseLevel: Integration
        """
        content_view = content_view_module_stream
        cv_filter = entities.ErratumContentViewFilter(
            content_view=content_view,
            inclusion=True,
        ).create()
        errata = entities.Errata().search(query={
            'search':
            f'errata_id="{settings.repos.module_stream_0.errata[2]}"'
        })[0]
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       errata=errata).create()

        content_view.publish()
        content_view = content_view.read()
        content_view_version_info = content_view.version[0].read()

        # verify the module_stream_count and errata_count for Exclude Filter
        assert content_view_version_info.module_stream_count == 2
        assert content_view_version_info.errata_counts['total'] == 1

        # delete the previous content_view_filter
        cv_filter.delete()
        cv_filter = entities.ErratumContentViewFilter(
            content_view=content_view,
            inclusion=False,
        ).create()
        errata = entities.Errata().search(query={
            'search':
            f'errata_id="{settings.repos.module_stream_0.errata[2]}"'
        })[0]
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       errata=errata).create()

        content_view.publish()
        content_view_version_info = content_view.read().version[1].read()

        # verify the module_stream_count and errata_count for Include Filter
        assert content_view_version_info.module_stream_count == 5
        assert content_view_version_info.errata_counts['total'] == 5
コード例 #2
0
    def test_positive_filter_by_envs(self):
        """Filter applicable errata for a content host by current and
        Library environments

        :id: f41bfcc2-39ee-4ae1-a71f-d2c9288875be

        :Setup:

            1. Make sure multiple environments are present.
            2. One of Content host's previous environment has additional
               errata.

        :Steps: GET /katello/api/errata

        :expectedresults: The errata for the content host is filtered by
            current and Library environments.

        :CaseLevel: System

        :BZ: 1682940
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst7'],
            'repository': REPOS['rhst7']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_cv = entities.ContentView(organization=org).create()
        new_repo = entities.Repository(
            product=entities.Product(organization=org).create(),
            url=CUSTOM_REPO_URL,
        ).create()
        self.assertEqual(new_repo.sync()['result'], 'success')
        new_cv = new_cv.read()
        new_cv.repository.append(new_repo)
        new_cv = new_cv.update(['repository'])
        new_cv.publish()
        library_env = entities.LifecycleEnvironment(
            name='Library',
            organization=org,
        ).search()[0]
        errata_library = entities.Errata(environment=library_env).search(
            query={'per_page': 1000})
        errata_env = entities.Errata(environment=env).search(
            query={'per_page': 1000})
        self.assertGreater(len(errata_library), len(errata_env))
コード例 #3
0
    def test_positive_multi_level_filters(self):
        """Verify promotion of Content View and Verify count after applying
        multi_filters (errata and module stream)

        :id: aeaf2ac7-eda2-4f07-a1dd-fe6057934697

        :expectedresults: Verify module stream and errata count should correct

        :CaseLevel: Integration
        """
        # apply include errata filter
        cv_filter = entities.ErratumContentViewFilter(
            content_view=self.content_view, inclusion=True).create()
        errata = entities.Errata().search(
            query={'search': f'errata_id="{FAKE_0_MODULAR_ERRATA_ID}"'})[0]
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       errata=errata).create()

        # apply exclude module filter
        cv_filter = entities.ModuleStreamContentViewFilter(
            content_view=self.content_view, inclusion=False).create()
        module_streams = entities.ModuleStream().search(
            query={'search': 'name="{}"'.format('walrus')})
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       module_stream=module_streams).create()
        self.content_view.publish()
        content_view = self.content_view.read()
        content_view_version_info = content_view.read().version[0].read()
        # verify the module_stream_count and errata_count for Include Filter
        assert content_view_version_info.module_stream_count == 2
        assert content_view_version_info.errata_counts['total'] == 1
コード例 #4
0
    def test_positive_sort_by_issued_date(self):
        """Filter errata by issued date

        :id: 6b4a783a-a7b4-4af4-b9e6-eb2928b7f7c1

        :Setup: Errata synced on satellite server.

        :Steps: GET /katello/api/errata

        :expectedresults: Errata is sorted by issued date.

        :CaseLevel: System
        """
        repo = entities.Repository(name=REPOS['rhva6']['name']).search(
            query={'organization_id': self.org.id})
        if repo:
            repo = repo[0]
        else:
            repo_with_cves_id = enable_rhrepo_and_fetchid(
                basearch=DEFAULT_ARCHITECTURE,
                org_id=self.org.id,
                product=PRDS['rhel'],
                repo=REPOS['rhva6']['name'],
                reposet=REPOSET['rhva6'],
                releasever=DEFAULT_RELEASE_VERSION,
            )
            repo = entities.Repository(id=repo_with_cves_id)
        self.assertEqual(repo.sync()['result'], 'success')
        erratum_list = entities.Errata(repository=repo).search(query={
            'order': 'issued ASC',
            'per_page': 1000
        })
        issued = [errata.issued for errata in erratum_list]
        self.assertEqual(issued, sorted(issued))
コード例 #5
0
ファイル: test_errata.py プロジェクト: latran/robottelo
def test_positive_sorted_issue_date_and_filter_by_cve(module_org, custom_repo, default_sat):
    """Sort by issued date and filter errata by CVE

    :id: a921d4c2-8d3d-4462-ba6c-fbd4b898a3f2

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is sorted by issued date and filtered by CVE.

    :CaseLevel: System
    """
    # Errata is sorted by issued date.
    erratum_list = entities.Errata(repository=custom_repo['repository-id']).search(
        query={'order': 'issued ASC', 'per_page': '1000'}
    )
    issued = [errata.issued for errata in erratum_list]
    assert issued == sorted(issued)

    # Errata is filtered by CVE
    erratum_list = default_sat.api.Errata(repository=custom_repo['repository-id']).search(
        query={'order': 'cve DESC', 'per_page': '1000'}
    )
    # Most of Errata don't have any CVEs. Removing empty CVEs from results
    erratum_cves = [errata.cves for errata in erratum_list if errata.cves]
    # Verifying each errata have its CVEs sorted in DESC order
    for errata_cves in erratum_cves:
        cve_ids = [cve['cve_id'] for cve in errata_cves]
        assert cve_ids == sorted(cve_ids, reverse=True)
コード例 #6
0
    def test_positive_list_updated(self):
        """View all errata in an Org sorted by Updated

        :id: 560d6584-70bd-4d1b-993a-cc7665a9e600

        :Setup: Errata synced on satellite server.

        :Steps: GET /katello/api/errata

        :expectedresults: Errata is filtered by Org and sorted by Updated date.

        :CaseLevel: System
        """
        repo = entities.Repository(name=REPOS['rhva6']['name']).search(
            query={'organization_id': self.org.id})
        if repo:
            repo = repo[0]
        else:
            repo_with_cves_id = enable_rhrepo_and_fetchid(
                basearch=DEFAULT_ARCHITECTURE,
                org_id=self.org.id,
                product=PRDS['rhel'],
                repo=REPOS['rhva6']['name'],
                reposet=REPOSET['rhva6'],
                releasever=DEFAULT_RELEASE_VERSION,
            )
            repo = entities.Repository(id=repo_with_cves_id)
        self.assertEqual(repo.sync()['result'], 'success')
        erratum_list = entities.Errata(repository=repo).search(query={
            'order': 'updated ASC',
            'per_page': 1000
        })
        updated = [errata.updated for errata in erratum_list]
        self.assertEqual(updated, sorted(updated))
コード例 #7
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    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
コード例 #8
0
    def test_positive_get_diff_for_cv_envs(self):
        """Generate a difference in errata between a set of environments
        for a content view

        :id: 96732506-4a89-408c-8d7e-f30c8d469769

        :Setup:

            1. Errata synced on satellite server.
            2. Multiple environments present.

        :Steps: GET /katello/api/compare

        :expectedresults: Difference in errata between a set of environments
            for a content view is retrieved.

        :CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(environment=env,
                                                organization=org).create()
        setup_org_for_a_rh_repo(
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhst7'],
                'repository': REPOS['rhst7']['name'],
                'organization-id': org.id,
                'content-view-id': content_view.id,
                'lifecycle-environment-id': env.id,
                'activationkey-id': activation_key.id,
            },
            force_use_cdn=True,
        )
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        new_env = entities.LifecycleEnvironment(organization=org,
                                                prior=env).create()
        cvvs = content_view.read().version[-2:]
        promote(cvvs[-1], new_env.id)
        result = entities.Errata().compare(
            data={
                'content_view_version_ids': [cvv.id for cvv in cvvs],
                'per_page': 9999
            })
        cvv2_only_errata = next(
            errata for errata in result['results']
            if errata['errata_id'] == CUSTOM_REPO_ERRATA_ID)
        self.assertEqual([cvvs[-1].id], cvv2_only_errata['comparison'])
        both_cvvs_errata = next(errata for errata in result['results']
                                if errata['errata_id'] == REAL_0_ERRATA_ID)
        self.assertEqual({cvv.id
                          for cvv in cvvs},
                         set(both_cvvs_errata['comparison']))
コード例 #9
0
ファイル: test_errata.py プロジェクト: latran/robottelo
def test_positive_get_diff_for_cv_envs():
    """Generate a difference in errata between a set of environments
    for a content view

    :id: 96732506-4a89-408c-8d7e-f30c8d469769

    :Setup:

        1. Errata synced on satellite server.
        2. Multiple environments present.

    :Steps: GET /katello/api/compare

    :expectedresults: Difference in errata between a set of environments
        for a content view is retrieved.

    :CaseLevel: System
    """
    org = entities.Organization().create()
    env = entities.LifecycleEnvironment(organization=org).create()
    content_view = entities.ContentView(organization=org).create()
    activation_key = entities.ActivationKey(environment=env, organization=org).create()
    for repo_url in [settings.repos.yum_9.url, CUSTOM_REPO_URL]:
        setup_org_for_a_custom_repo(
            {
                'url': repo_url,
                'organization-id': org.id,
                'content-view-id': content_view.id,
                'lifecycle-environment-id': env.id,
                'activationkey-id': activation_key.id,
            }
        )
    new_env = entities.LifecycleEnvironment(organization=org, prior=env).create()
    cvvs = content_view.read().version[-2:]
    promote(cvvs[-1], new_env.id)
    result = entities.Errata().compare(
        data={'content_view_version_ids': [cvv.id for cvv in cvvs], 'per_page': '9999'}
    )
    cvv2_only_errata = next(
        errata for errata in result['results'] if errata['errata_id'] == CUSTOM_REPO_ERRATA_ID
    )
    assert cvvs[-1].id in cvv2_only_errata['comparison']
    both_cvvs_errata = next(
        errata
        for errata in result['results']
        if errata['errata_id'] in constants.FAKE_9_YUM_SECURITY_ERRATUM
    )
    assert {cvv.id for cvv in cvvs} == set(both_cvvs_errata['comparison'])
コード例 #10
0
def test_positive_filter_by_cve(module_org):
    """Filter errata by CVE

    :id: a921d4c2-8d3d-4462-ba6c-fbd4b898a3f2

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is filtered by CVE.

    :CaseLevel: System
    """
    repo = entities.Repository(name=constants.REPOS['rhva6']['name']).search(
        query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
        })
        repo = entities.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = entities.Errata(repository=repo).search(query={
        'order': 'cve DESC',
        'per_page': '1000'
    })
    # Most of Errata don't have any CVEs. Removing empty CVEs from results
    erratum_cves = [errata.cves for errata in erratum_list if errata.cves]
    # Verifying each errata have its CVEs sorted in DESC order
    for errata_cves in erratum_cves:
        cve_ids = [cve['cve_id'] for cve in errata_cves]
        assert cve_ids == sorted(cve_ids, reverse=True)
コード例 #11
0
def test_positive_sort_by_issued_date(module_org):
    """Filter errata by issued date

    :id: 6b4a783a-a7b4-4af4-b9e6-eb2928b7f7c1

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is sorted by issued date.

    :CaseLevel: System
    """
    repo = entities.Repository(name=constants.REPOS['rhva6']['name']).search(
        query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
            # 'content-view-id': content_view.id,
            # 'lifecycle-environment-id': env.id,
            # 'activationkey-id': activation_key.id,
        })
        repo = entities.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = entities.Errata(repository=repo).search(query={
        'order': 'issued ASC',
        'per_page': '1000'
    })
    issued = [errata.issued for errata in erratum_list]
    assert issued == sorted(issued)
コード例 #12
0
ファイル: test_errata.py プロジェクト: rohitkadam19/robottelo
    def test_positive_filter_by_cve(self):
        """Filter errata by CVE

        @id: a921d4c2-8d3d-4462-ba6c-fbd4b898a3f2

        @Setup: Errata synced on satellite server.

        @Steps:

        1. GET /katello/api/errata

        @Assert: Errata is filtered by CVE.

        @CaseLevel: System
        """
        repo = entities.Repository(name=REPOS['rhva6']['name']).search(
            query={'organization_id': self.org.id})
        if repo:
            repo = repo[0]
        else:
            repo_with_cves_id = enable_rhrepo_and_fetchid(
                basearch=DEFAULT_ARCHITECTURE,
                org_id=self.org.id,
                product=PRDS['rhel'],
                repo=REPOS['rhva6']['name'],
                reposet=REPOSET['rhva6'],
                releasever=DEFAULT_RELEASE_VERSION,
            )
            repo = entities.Repository(id=repo_with_cves_id)
        self.assertEqual(repo.sync()['result'], 'success')
        erratum_list = entities.Errata(repository=repo).search(
            query={
                'order': 'cve DESC',
                'per_page': 1000,
            })
        # Most of Errata don't have any CVEs. Removing empty CVEs from results
        erratum_cves = [errata.cves for errata in erratum_list if errata.cves]
        # Verifying each errata have its CVEs sorted in DESC order
        for errata_cves in erratum_cves:
            cve_ids = [cve['cve_id'] for cve in errata_cves]
            self.assertEqual(cve_ids, sorted(cve_ids, reverse=True))
コード例 #13
0
def test_positive_list_updated(module_org):
    """View all errata in an Org sorted by Updated

    :id: 560d6584-70bd-4d1b-993a-cc7665a9e600

    :Setup: Errata synced on satellite server.

    :Steps: GET /katello/api/errata

    :expectedresults: Errata is filtered by Org and sorted by Updated date.

    :CaseLevel: System
    """
    repo = entities.Repository(name=constants.REPOS['rhva6']['name']).search(
        query={'organization_id': module_org.id})
    if repo:
        repo = repo[0]
    else:
        result = setup_org_for_a_rh_repo({
            'product':
            constants.PRDS['rhel'],
            'repository-set':
            constants.REPOSET['rhva6'],
            'repository':
            constants.REPOS['rhva6']['name'],
            'organization-id':
            module_org.id,
            'releasever':
            constants.DEFAULT_RELEASE_VERSION,
            'basearch':
            constants.DEFAULT_ARCHITECTURE,
        })
        repo = entities.Repository(id=result['repository-id'])
    assert repo.sync()['result'] == 'success'
    erratum_list = entities.Errata(repository=repo).search(query={
        'order': 'updated ASC',
        'per_page': '1000'
    })
    updated = [errata.updated for errata in erratum_list]
    assert updated == sorted(updated)
コード例 #14
0
def test_positive_filtered_errata_status_installable_param(
        session, errata_status_installable):
    """Filter errata for specific content view and verify that host that
    was registered using that content view has different states in
    correspondence to filtered errata and `errata status installable`
    settings flag value

    :id: ed94cf34-b8b9-4411-8edc-5e210ea6af4f

    :Steps:

        1. Prepare setup: Create Lifecycle Environment, Content View,
            Activation Key and all necessary repos
        2. Register Content Host using created data
        3. Create necessary Content View Filter and Rule for repository errata
        4. Publish and Promote Content View to a new version.
        5. Go to created Host page and check its properties
        6. Change 'errata status installable' flag in the settings and
            check host properties once more

    :expectedresults: Check that 'errata status installable' flag works as intended

    :BZ: 1368254

    :CaseLevel: System
    """
    org = entities.Organization().create()
    lce = entities.LifecycleEnvironment(organization=org).create()
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7,
        repositories=[
            SatelliteToolsRepository(),
            # As Satellite Tools may be added as custom repo and to have a "Fully entitled" host,
            # force the host to consume an RH product with adding a cdn repo.
            RHELAnsibleEngineRepository(cdn=True),
            YumRepository(url=CUSTOM_REPO_URL),
        ],
    )
    repos_collection.setup_content(org.id, lce.id, upload_manifest=True)
    with VirtualMachine(distro=repos_collection.distro) as client:
        repos_collection.setup_virtual_machine(client)
        assert _install_client_package(client,
                                       FAKE_1_CUSTOM_PACKAGE,
                                       errata_applicability=True)
        # Adding content view filter and content view filter rule to exclude errata for the
        # installed package.
        content_view = entities.ContentView(
            id=repos_collection.setup_content_data['content_view']
            ['id']).read()
        cv_filter = entities.ErratumContentViewFilter(
            content_view=content_view, inclusion=False).create()
        errata = entities.Errata(
            content_view_version=content_view.version[-1]).search(query=dict(
                search=f'errata_id="{CUSTOM_REPO_ERRATA_ID}"'))[0]
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       errata=errata).create()
        content_view.publish()
        content_view = content_view.read()
        content_view_version = content_view.version[-1]
        promote(content_view_version, lce.id)
        with session:
            session.organization.select(org_name=org.name)
            _set_setting_value(errata_status_installable, True)
            expected_values = {
                'Status': 'OK',
                'Errata': 'All errata applied',
                'Subscription': 'Fully entitled',
            }
            host_details_values = session.host.get_details(client.hostname)
            actual_values = {
                key: value
                for key, value in host_details_values['properties']
                ['properties_table'].items() if key in expected_values
            }
            for key in actual_values:
                assert expected_values[key] in actual_values[
                    key], 'Expected text not found'
            _set_setting_value(errata_status_installable, False)
            expected_values = {
                'Status': 'Error',
                'Errata': 'Security errata applicable',
                'Subscription': 'Fully entitled',
            }
            # navigate to host main page by making a search, to refresh the host details page
            session.host.search(client.hostname)
            host_details_values = session.host.get_details(client.hostname)
            actual_values = {
                key: value
                for key, value in host_details_values['properties']
                ['properties_table'].items() if key in expected_values
            }
            for key in actual_values:
                assert expected_values[key] in actual_values[
                    key], 'Expected text not found'
コード例 #15
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    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)
コード例 #16
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    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)
コード例 #17
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    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)
コード例 #18
0
 def get_applicable_errata(repo):
     """Retrieves applicable errata for the given repo"""
     return entities.Errata(repository=repo).search(
         query={'errata_restrict_applicable': True})
コード例 #19
0
ファイル: test_errata.py プロジェクト: jhutar/robottelo
    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)
コード例 #20
0
ファイル: test_errata.py プロジェクト: jhutar/robottelo
    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=FAKE_9_YUM_REPO).create()
        product.sync()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        repolist = [custom_yum_repo, tools_repo, rhel_repo]
        content_view = self._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': 'name={}'.format(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]
        self._host_location_update(client_container_name=client_container_name,
                                   loc=loc)
        self._install_or_update_package(client_container_id, 'katello-agent')
        self._run_goferd(client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            self._install_or_update_package(client_container_id, package)
        host = entities.Host().search(
            query={'search': 'activation_key={0}'.format(ak.name)})[0]
        applicable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        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))
        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)