コード例 #1
0
def test_negative_install_without_hc_info(module_org, host_collection):
    """Attempt to install an erratum on a host collection without specifying host collection info.
    This test only works with two or more host collections (BZ#1928281).
    We have the one from the fixture, just need to create one more at the start of the test.

    :id: 753d36f0-d19b-494d-a247-ce2d61c4cf74

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --errata <errata>
        --organization-id <org_id>

    :expectedresults: Error message thrown.

    :BZ: 1928281

    :CaseImportance: Low

    :CaseLevel: System
    """
    make_host_collection({'organization-id': module_org.id})
    with pytest.raises(CLIReturnCodeError):
        HostCollection.erratum_install({
            'organization-id':
            module_org.id,
            'errata': [REPO_WITH_ERRATA['errata'][0]['id']]
        })
コード例 #2
0
def test_negative_install_by_hc_id_without_errata_info(module_org,
                                                       host_collection,
                                                       errata_hosts):
    """Attempt to install an erratum on a host collection by host collection id but no errata info
    specified.

    :id: 3635698d-4f09-4a60-91ea-1957e5949750

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --id <id> --organization-id
        <org_id>

    :expectedresults: Error message thrown.

    :CaseImportance: Low

    :CaseLevel: System
    """
    with pytest.raises(CLIReturnCodeError,
                       match="Error: Option '--errata' is required"):
        HostCollection.erratum_install({
            'id': host_collection['id'],
            'organization-id': module_org.id
        })
コード例 #3
0
def test_negative_install_by_hc_name_without_org_info(module_org,
                                                      host_collection):
    """Attempt to install an erratum on a host collection by host collection name but without
    specifying any org info.

    :id: 991f5b61-a4d1-444c-8a21-8ffe48e83f76

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --errata <errata> --name <name>

    :expectedresults: Error message thrown.

    :CaseImportance: Low

    :CaseLevel: System
    """
    with pytest.raises(CLIReturnCodeError,
                       match='Error: Could not find organization'):
        HostCollection.erratum_install({
            'name':
            host_collection['name'],
            'errata': [REPO_WITH_ERRATA['errata'][0]['id']]
        })
コード例 #4
0
def test_negative_install_by_hc_id_without_org_info(module_org,
                                                    host_collection):
    """Attempt to install an erratum on a host collection by host collection id but without
    specifying any org info.

    :id: b7d32bb3-9c5f-452b-b421-f8e9976ca52c

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --errata <errata> --id <id>

    :expectedresults: Error message thrown.

    :CaseImportance: Low

    :CaseLevel: System
    """
    with pytest.raises(CLIReturnCodeError,
                       match='Error: Could not find organization'):
        HostCollection.erratum_install({
            'id':
            host_collection['id'],
            'errata': [REPO_WITH_ERRATA['errata'][0]['id']]
        })
コード例 #5
0
def test_negative_install_by_hc_name_without_errata_info(
        module_org, host_collection, errata_hosts):
    """Attempt to install an erratum on a host collection by host collection name but no errata
    info specified.

    :id: 12d78bca-efd1-407a-9bd3-f989c2bda6a8

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --name <name> --organization-id
        <org_id>

    :expectedresults: Error message thrown.

    :CaseImportance: Low

    :CaseLevel: System
    """
    with pytest.raises(CLIReturnCodeError,
                       match="Error: Option '--errata' is required"):
        HostCollection.erratum_install({
            'name': host_collection['name'],
            'organization-id': module_org.id
        })
コード例 #6
0
def test_install_errata_to_one_host(module_org, errata_hosts, host_collection):
    """Install an erratum to one of the hosts in a host collection.

    :id: bfcee2de-3448-497e-a696-fcd30cea9d33

    :expectedresults: Errata was successfully installed in only one of the hosts in
        the host collection

    :Setup: Errata synced on satellite server, custom package installed on errata hosts.

    :Steps:
        1. Remove packages from one host.
        2. host-collection erratum install --errata <errata> --id <id>
            --organization <org_name>
        3. Assert first host does not have the package.
        4. Assert second host does have the new package.


    :expectedresults: Erratum is only installed on one host.

    :BZ: 1810774
    """
    errata = REPO_WITH_ERRATA['errata'][0]

    # Remove the package on first host to remove need for errata.
    result = errata_hosts[0].execute(f'yum erase -y {errata["package_name"]}')
    assert result.status == 0, f'Failed to erase the rpm: {result.stdout}'

    # Apply errata to the host collection.
    install_task = HostCollection.erratum_install({
        'id': host_collection['id'],
        'organization': module_org.name,
        'errata': [errata['id']],
    })
    Task.progress({'id': install_task[0]['id']})

    assert not is_rpm_installed(
        errata_hosts[0],
        rpm=errata['package_name']), 'Package should not be installed on host.'
    assert is_rpm_installed(
        errata_hosts[1],
        rpm=errata['new_package']), 'Package should be installed on host.'
コード例 #7
0
def test_positive_install_by_host_collection_and_org(module_org,
                                                     host_collection,
                                                     errata_hosts,
                                                     filter_by_hc,
                                                     filter_by_org):
    """Use host collection id or name and org id, name, or label to install an update on the host
    collection.

    :id: 1b063f76-c85f-42fb-a919-5de319b09b99

    :parametrized: yes

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --errata <errata>
        (--id <hc_id>|--name <hc_name>)
        (--organization-id <org_id>|--organization <org_name>|--organization-label <org_label>)

    :expectedresults: Erratum is installed.

    :CaseLevel: System

    :BZ: 1457977
    """
    param = {'errata': [REPO_WITH_ERRATA['errata'][0]['id']]}

    if filter_by_hc == 'id':
        param['id'] = host_collection['id']
    elif filter_by_hc == 'name':
        param['name'] = host_collection['name']

    if filter_by_org == 'id':
        param['organization-id'] = module_org.id
    elif filter_by_org == 'name':
        param['organization'] = module_org.name
    elif filter_by_org == 'label':
        param['organization-label'] = module_org.label

    install_task = HostCollection.erratum_install(param)
    Task.progress({'id': install_task[0]['id']})
    for host in errata_hosts:
        assert is_rpm_installed(host)