コード例 #1
0
def test_resolve_conflicting_requests(monkeypatch):
    """
    Verifies that the algorithm correctly resolves conflicting pes events.
    """
    monkeypatch.setattr(peseventsscanner, 'map_repositories', lambda x: x)
    monkeypatch.setattr(peseventsscanner,
                        'filter_out_pkgs_in_blacklisted_repos', lambda x: x)

    events = [
        Event(1, Action.SPLIT, {Package('sip-devel', 'repo', None)}, {
            Package('python3-sip-devel', 'repo', None),
            Package('sip', 'repo', None)
        }, (7, 6), (8, 0), []),
        Event(2, Action.SPLIT, {Package('sip', 'repo', None)}, {
            Package('python3-pyqt5-sip', 'repo', None),
            Package('python3-sip', 'repo', None)
        }, (7, 6), (8, 0), [])
    ]
    installed_pkgs = {('sip', None), ('sip-devel', None)}

    tasks = process_events([(8, 0)], events, installed_pkgs)

    assert tasks[Task.INSTALL] == {
        ('python3-sip-devel', None): 'repo',
        ('python3-pyqt5-sip', None): 'repo',
        ('python3-sip', None): 'repo'
    }
    assert tasks[Task.REMOVE] == {('sip-devel', None): 'repo'}
    assert tasks[Task.KEEP] == {('sip', None): 'repo'}
コード例 #2
0
def test_add_output_pkgs_to_transaction_conf():
    """
    Verifies that the add_output_pkgs_to_transaction_conf correctly modifies to_remove field based
    on the supplied events.
    """
    events = [
        Event(1, Action.SPLIT, {'split_in': 'repo'}, {'split_out1': 'repo', 'split_out2': 'repo'}, (7, 6), (8, 0), []),
        Event(2, Action.MERGED, {'merge_in1': 'repo', 'merge_in2': 'repo'}, {'merge_out': 'repo'}, (7, 6), (8, 0), []),
        Event(3, Action.RENAMED, {'renamed_in': 'repo'}, {'renamed_out': 'repo'}, (7, 6), (8, 0), []),
        Event(4, Action.REPLACED, {'replaced_in': 'repo'}, {'replaced_out': 'repo'}, (7, 6), (8, 0), []),
    ]

    conf_empty = RpmTransactionTasks()
    add_output_pkgs_to_transaction_conf(conf_empty, events)
    assert conf_empty.to_remove == []

    conf_split = RpmTransactionTasks(to_remove=['split_in'])
    add_output_pkgs_to_transaction_conf(conf_split, events)
    assert sorted(conf_split.to_remove) == ['split_in', 'split_out1', 'split_out2']

    conf_merged_incomplete = RpmTransactionTasks(to_remove=['merge_in1'])
    add_output_pkgs_to_transaction_conf(conf_merged_incomplete, events)
    assert conf_merged_incomplete.to_remove == ['merge_in1']

    conf_merged = RpmTransactionTasks(to_remove=['merge_in1', 'merge_in2'])
    add_output_pkgs_to_transaction_conf(conf_merged, events)
    assert sorted(conf_merged.to_remove) == ['merge_in1', 'merge_in2', 'merge_out']

    conf_renamed = RpmTransactionTasks(to_remove=['renamed_in'])
    add_output_pkgs_to_transaction_conf(conf_renamed, events)
    assert sorted(conf_renamed.to_remove) == ['renamed_in', 'renamed_out']

    conf_replaced = RpmTransactionTasks(to_remove=['replaced_in'])
    add_output_pkgs_to_transaction_conf(conf_replaced, events)
    assert sorted(conf_replaced.to_remove) == ['replaced_in', 'replaced_out']
コード例 #3
0
def test_filter_events_by_releases():
    """
    Tests whether the events are correctly filtered based on the relevant supplied releases.
    """
    events = [
        Event(1, Action.PRESENT, {Package('pkg1', 'repo', None)}, set(),
              (7, 6), (7, 7), []),
        Event(2, Action.PRESENT, {Package('pkg2', 'repo', None)}, set(),
              (7, 7), (7, 8), []),
        Event(3, Action.PRESENT, {Package('pkg3', 'repo', None)}, set(),
              (7, 8), (8, 0), []),
        Event(4, Action.PRESENT, {Package('pkg4', 'repo', None)}, set(),
              (8, 0), (8, 1), []),
        Event(5, Action.PRESENT, {Package('pkg5', 'repo', None)}, set(),
              (8, 1), (8, 2), [])
    ]

    filtered = filter_events_by_releases(events, [(7, 6), (7, 7), (8, 0),
                                                  (8, 3)])
    assert {Package('pkg1', 'repo',
                    None)} in [event.in_pkgs for event in filtered]
    assert {Package('pkg2', 'repo',
                    None)} not in [event.in_pkgs for event in filtered]
    assert {Package('pkg3', 'repo',
                    None)} in [event.in_pkgs for event in filtered]
    assert {Package('pkg4', 'repo',
                    None)} not in [event.in_pkgs for event in filtered]
    assert {Package('pkg5', 'repo',
                    None)} not in [event.in_pkgs for event in filtered]
コード例 #4
0
def test_resolve_conflicting_requests(monkeypatch):
    monkeypatch.setattr(peseventsscanner, 'map_repositories', lambda x: x)
    monkeypatch.setattr(peseventsscanner,
                        'filter_out_pkgs_in_blacklisted_repos', lambda x: x)

    events = [
        Event(1, Action.split, {'sip-devel': 'repo'}, {
            'python3-sip-devel': 'repo',
            'sip': 'repo'
        }, (7, 6), (8, 0), []),
        Event(2, Action.split, {'sip': 'repo'}, {
            'python3-pyqt5-sip': 'repo',
            'python3-sip': 'repo'
        }, (7, 6), (8, 0), [])
    ]
    installed_pkgs = {'sip', 'sip-devel'}

    tasks = process_events([(8, 0)], events, installed_pkgs)

    assert tasks[Task.install] == {
        'python3-sip-devel': 'repo',
        'python3-pyqt5-sip': 'repo',
        'python3-sip': 'repo'
    }
    assert tasks[Task.remove] == {'sip-devel': 'repo'}
    assert tasks[Task.keep] == {'sip': 'repo'}
コード例 #5
0
def test_merge_events_relevance_assessment(monkeypatch, installed_pkgs,
                                           expected_relevance):
    """
    Verifies that the relevance of the MERGED events is correctly assessed when processing events.
    """
    monkeypatch.setattr(peseventsscanner, 'map_repositories', lambda x: x)
    monkeypatch.setattr(peseventsscanner,
                        'filter_out_pkgs_in_blacklisted_repos', lambda x: x)

    events = [
        Event(1, Action.REPLACED, {Package('pkg0', 'repo-in', None)},
              {Package('pkg4', 'repo-out', None)}, (7, 8), (7, 9), []),
        Event(
            2,
            Action.MERGED,
            {
                Package('pkg1', 'repo-in', None),
                Package('pkg2', 'repo-in', None)
            },
            {Package('pkg3', 'repo-out', None)},
            (7, 9),
            (8, 0),
            [],
        ),
        Event(
            3,
            Action.MERGED,
            {
                Package('pkg1', 'repo-in', 'wuzza:11'),
                Package('pkg2', 'repo-in', 'wuzza:11')
            },
            {Package('pkg3', 'repo-out', None)},
            (7, 9),
            (8, 0),
            [],
        )
    ]

    tasks = process_events([(7, 9), (8, 0)], events, installed_pkgs)

    if expected_relevance:
        assert not set(tasks[Task.INSTALL].keys()) - {('pkg3', None),
                                                      ('pkg4', None)}
        removed_packages = set()
        if any(p[1] for p in installed_pkgs):
            removed_packages = installed_pkgs
        if ('pkg0', None) in installed_pkgs:
            removed_packages.add(('pkg0', None))
        if ('pkg1', None) in installed_pkgs or ('pkg2',
                                                None) in installed_pkgs:
            removed_packages.add(('pkg1', None))
            removed_packages.add(('pkg2', None))

        assert not set(tasks[Task.REMOVE].keys()) - removed_packages
    else:
        assert not tasks[Task.INSTALL]
        assert not tasks[Task.REMOVE]
コード例 #6
0
def test_filter_events_by_architecture():
    events = [
        Event(1, Action.PRESENT, {'pkg1': 'repo'}, {}, (7, 6), (8, 0), ['arch1']),
        Event(2, Action.PRESENT, {'pkg2': 'repo'}, {}, (7, 6), (8, 0), ['arch2', 'arch1', 'arch3']),
        Event(3, Action.PRESENT, {'pkg3': 'repo'}, {}, (7, 6), (8, 0), ['arch2', 'arch3', 'arch4']),
        Event(4, Action.PRESENT, {'pkg4': 'repo'}, {}, (7, 6), (8, 0), [])
    ]

    filtered = filter_events_by_architecture(events, 'arch1')
    assert {'pkg1': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg2': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg3': 'repo'} not in [event.in_pkgs for event in filtered]
    assert {'pkg4': 'repo'} in [event.in_pkgs for event in filtered]
コード例 #7
0
def test_filter_events_by_releases():
    events = [
        Event(1, Action.PRESENT, {'pkg1': 'repo'}, {}, (7, 6), (7, 7), []),
        Event(2, Action.PRESENT, {'pkg2': 'repo'}, {}, (7, 7), (7, 8), []),
        Event(3, Action.PRESENT, {'pkg3': 'repo'}, {}, (7, 8), (8, 0), []),
        Event(4, Action.PRESENT, {'pkg4': 'repo'}, {}, (8, 0), (8, 1), []),
        Event(5, Action.PRESENT, {'pkg5': 'repo'}, {}, (8, 1), (8, 2), [])
    ]

    filtered = filter_events_by_releases(events, [(7, 6), (7, 7), (8, 0), (8, 3)])
    assert {'pkg1': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg2': 'repo'} not in [event.in_pkgs for event in filtered]
    assert {'pkg3': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg4': 'repo'} not in [event.in_pkgs for event in filtered]
    assert {'pkg5': 'repo'} not in [event.in_pkgs for event in filtered]
コード例 #8
0
def test_filter_events_by_architecture():
    """
    Verifies that the packages are correctly filtered based on the architecture.
    """
    events = [
        Event(1, Action.PRESENT, {'pkg1': 'repo'}, {}, (7, 6), (8, 0), ['arch1']),
        Event(2, Action.PRESENT, {'pkg2': 'repo'}, {}, (7, 6), (8, 0), ['arch2', 'arch1', 'arch3']),
        Event(3, Action.PRESENT, {'pkg3': 'repo'}, {}, (7, 6), (8, 0), ['arch2', 'arch3', 'arch4']),
        Event(4, Action.PRESENT, {'pkg4': 'repo'}, {}, (7, 6), (8, 0), [])
    ]

    filtered = filter_events_by_architecture(events, 'arch1')
    assert {'pkg1': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg2': 'repo'} in [event.in_pkgs for event in filtered]
    assert {'pkg3': 'repo'} not in [event.in_pkgs for event in filtered]
    assert {'pkg4': 'repo'} in [event.in_pkgs for event in filtered]
コード例 #9
0
def test_process_events(monkeypatch):
    """
    Verifies that the event processing algorithm works as expected.
    """
    monkeypatch.setattr(peseventsscanner,
                        '_get_repositories_mapping',
                        lambda dummy_target_pesids: {'rhel8-repo': 'rhel8-mapped'})
    monkeypatch.setattr(peseventsscanner, 'get_repositories_blacklisted', get_repos_blacklisted_mocked(set()))

    events = [
        Event(1, Action.SPLIT, {'original': 'rhel7-repo'}, {'split01': 'rhel8-repo', 'split02': 'rhel8-repo'},
              (7, 6), (8, 0), []),
        Event(2, Action.REMOVED, {'removed': 'rhel7-repo'}, {}, (7, 6), (8, 0), []),
        Event(3, Action.PRESENT, {'present': 'rhel8-repo'}, {}, (7, 6), (8, 0), []),
        # this package is present at the start, gets removed and then reintroduced
        Event(4, Action.REMOVED, {'reintroduced': 'rhel7-repo'}, {}, (7, 6), (8, 0), []),
        Event(5, Action.PRESENT, {'reintroduced': 'rhel8-repo'}, {}, (8, 0), (8, 1), []),
        # however, this package was never there
        Event(6, Action.REMOVED, {'neverthere': 'rhel7-repo'}, {}, (7, 6), (8, 0), []),
        Event(7, Action.PRESENT, {'neverthere': 'rhel8-repo'}, {}, (8, 0), (8, 1), [])]
    installed_pkgs = {'original', 'removed', 'present', 'reintroduced'}
    tasks = process_events([(8, 0), (8, 1)], events, installed_pkgs)

    assert tasks[Task.INSTALL] == {'split02': 'rhel8-mapped', 'split01': 'rhel8-mapped'}
    assert tasks[Task.REMOVE] == {'removed': 'rhel7-repo', 'original': 'rhel7-repo'}
    assert tasks[Task.KEEP] == {'present': 'rhel8-mapped', 'reintroduced': 'rhel8-mapped'}
コード例 #10
0
def test_process_modular_events(monkeypatch):
    monkeypatch.setattr(peseventsscanner, 'map_repositories', lambda x: x)
    monkeypatch.setattr(peseventsscanner,
                        'filter_out_pkgs_in_blacklisted_repos', lambda x: x)

    events = [
        # match the right modular package without touching the ones with absent or different module/stream
        # in practice, installed packages can't have the same name, just testing that it matches the right one
        Event(1,
              Action.REMOVED, {Package('removed', 'repo', ('module', '42'))},
              set(), (8, 4), (9, 0), []),
        Event(2, Action.SPLIT,
              {Package('split_in', 'repo', ('splitin', 'foo'))}, {
                  Package('split_out1', 'repo', None),
                  Package('split_out2', 'repo', ('splitout', 'foo'))
              }, (8, 4), (9, 0), []),
        Event(3, Action.SPLIT,
              {Package('split_in', 'repo', ('splitin', 'bar'))}, {
                  Package('split_out3', 'repo', None),
                  Package('split_out2', 'repo', ('splitout', 'bar'))
              }, (8, 4), (9, 0), []),
    ]
    installed_pkgs = {('removed', ('module', '42')),
                      ('removed', ('model', '42')),
                      ('removed', ('module', '420')), ('removed', None),
                      ('split_in', ('splitin', 'foo'))}

    tasks = process_events([(9, 0)], events, installed_pkgs)

    assert ('removed',
            ('module',
             '42')) in tasks[Task.REMOVE]  # name, module and stream match
    assert ('removed', ('model',
                        '42')) not in tasks[Task.REMOVE]  # different module
    assert ('removed', ('module',
                        '420')) not in tasks[Task.REMOVE]  # different stream
    assert ('removed', None) not in tasks[Task.REMOVE]  # no module stream

    assert ('split_in', ('splitin', 'foo')) in tasks[Task.REMOVE]
    assert ('split_out1', None) in tasks[Task.INSTALL]
    assert ('split_out2', ('splitout', 'foo')) in tasks[Task.INSTALL]
    assert ('split_in', ('splitin', 'bar')) not in tasks[Task.REMOVE]
    assert ('split_out3', None) not in tasks[Task.INSTALL]
    assert ('split_out2', ('splitout', 'bar')) not in tasks[Task.INSTALL]
コード例 #11
0
def test_add_output_pkgs_to_transaction_conf():
    events = [
        Event(1, Action.split, {'split_in': 'repo'}, {
            'split_out1': 'repo',
            'split_out2': 'repo'
        }, (7, 6), (8, 0), []),
        Event(2, Action.merged, {
            'merge_in1': 'repo',
            'merge_in2': 'repo'
        }, {'merge_out': 'repo'}, (7, 6), (8, 0), []),
        Event(3, Action.renamed, {'renamed_in': 'repo'},
              {'renamed_out': 'repo'}, (7, 6), (8, 0), []),
        Event(4, Action.replaced, {'replaced_in': 'repo'},
              {'replaced_out': 'repo'}, (7, 6), (8, 0), []),
    ]

    conf_empty = RpmTransactionTasks()
    add_output_pkgs_to_transaction_conf(conf_empty, events)
    assert conf_empty.to_remove == []

    conf_split = RpmTransactionTasks(to_remove=['split_in'])
    add_output_pkgs_to_transaction_conf(conf_split, events)
    assert sorted(
        conf_split.to_remove) == ['split_in', 'split_out1', 'split_out2']

    conf_merged_incomplete = RpmTransactionTasks(to_remove=['merge_in1'])
    add_output_pkgs_to_transaction_conf(conf_merged_incomplete, events)
    assert conf_merged_incomplete.to_remove == ['merge_in1']

    conf_merged = RpmTransactionTasks(to_remove=['merge_in1', 'merge_in2'])
    add_output_pkgs_to_transaction_conf(conf_merged, events)
    assert sorted(
        conf_merged.to_remove) == ['merge_in1', 'merge_in2', 'merge_out']

    conf_renamed = RpmTransactionTasks(to_remove=['renamed_in'])
    add_output_pkgs_to_transaction_conf(conf_renamed, events)
    assert sorted(conf_renamed.to_remove) == ['renamed_in', 'renamed_out']

    conf_replaced = RpmTransactionTasks(to_remove=['replaced_in'])
    add_output_pkgs_to_transaction_conf(conf_replaced, events)
    assert sorted(conf_replaced.to_remove) == ['replaced_in', 'replaced_out']
コード例 #12
0
def test_drop_conflicting_release_events():
    """
    Tests whether correct events are dropped from conflicting release events.
    From conflicting events only the one with highest target release should be kept.
    """

    conflict1a = Event(1, Action.PRESENT, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 0), [])
    conflict1b = Event(2, Action.REPLACED, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 2), [])
    conflict1c = Event(3, Action.REMOVED, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 1), [])
    conflict2a = Event(4, Action.REMOVED, {Package('pkg2a', 'repo', None)},
                       set(), (7, 6), (8, 0), [])
    conflict2b = Event(5, Action.REPLACED, {Package('pkg2a', 'repo', None)},
                       {Package('pkg2b', 'repo', None)}, (7, 6), (8, 1), [])
    # two input packages
    conflict3a = Event(
        6, Action.MERGED,
        {Package('pkg3a', 'repo', None),
         Package('pkg3b', 'repo', None)}, {Package('pkg3c', 'repo', None)},
        (7, 6), (8, 0), [])
    conflict3b = Event(
        7, Action.MERGED,
        {Package('pkg3a', 'repo', None),
         Package('pkg3b', 'repo', None)}, {Package('pkg3d', 'repo', None)},
        (7, 6), (8, 1), [])
    # these two can't be chained, don't remove anything
    okay1a = Event(8, Action.REPLACED, {Package('pkg4a', 'repo', None)},
                   {Package('pkg4b', 'repo', None)}, (7, 6), (8, 0), [])
    okay1b = Event(9, Action.REPLACED, {Package('pkg4b', 'repo', None)},
                   {Package('pkg4c', 'repo', None)}, (8, 0), (8, 1), [])

    events = [
        conflict1a, conflict1b, conflict1c, conflict2a, conflict2b, conflict3a,
        conflict3b, okay1a, okay1b
    ]
    drop_conflicting_release_events(events)

    for event in [conflict1b, conflict2b, conflict3b, okay1a, okay1b]:
        assert event in events
    for event in [conflict1a, conflict1c, conflict2a, conflict3a]:
        assert event not in events
コード例 #13
0
def test_merge_events_relevance_assessment(monkeypatch, installed_pkgs, expected_relevance):
    """
    Verifies that the relevance of the MERGED events is correctly assessed when processing events.
    """
    monkeypatch.setattr(peseventsscanner, 'map_repositories', lambda x: x)
    monkeypatch.setattr(peseventsscanner, 'filter_out_pkgs_in_blacklisted_repos', lambda x: x)

    events = [
        Event(1, Action.REPLACED, {'pkg0': 'repo-in'}, {'pkg1': 'repo-in'}, (7, 8), (7, 9), []),
        Event(2, Action.MERGED, {'pkg1': 'repo-in', 'pkg2': 'repo-in'}, {'pkg3': 'repo-out'}, (7, 9), (8, 0), [])
    ]

    tasks = process_events([(7, 9), (8, 0)], events, installed_pkgs)

    if expected_relevance:
        assert tasks[Task.INSTALL] == {'pkg3': 'repo-out'}
        if 'pkg0' in installed_pkgs:
            assert tasks[Task.REMOVE] == {'pkg0': 'repo-in', 'pkg2': 'repo-in'}
        else:
            assert tasks[Task.REMOVE] == {'pkg1': 'repo-in', 'pkg2': 'repo-in'}
    else:
        assert not tasks[Task.INSTALL]
        assert not tasks[Task.REMOVE]
コード例 #14
0
def test_drop_conflicting_release_events():
    conflict1a = Event(1, Action.PRESENT, {'pkg1': 'repo'}, {}, (7, 6), (8, 0), [])
    conflict1b = Event(2, Action.REPLACED, {'pkg1': 'repo'}, {}, (7, 6), (8, 2), [])
    conflict1c = Event(3, Action.REMOVED, {'pkg1': 'repo'}, {}, (7, 6), (8, 1), [])
    conflict2a = Event(4, Action.REMOVED, {'pkg2a': 'repo'}, {}, (7, 6), (8, 0), [])
    conflict2b = Event(5, Action.REPLACED, {'pkg2a': 'repo'}, {'pkg2b': 'repo'}, (7, 6), (8, 1), [])
    # two input packages
    conflict3a = Event(6, Action.MERGED, {'pkg3a': 'repo', 'pkg3b': 'repo'}, {'pkg3c': 'repo'}, (7, 6), (8, 0), [])
    conflict3b = Event(7, Action.MERGED, {'pkg3a': 'repo', 'pkg3b': 'repo'}, {'pkg3d': 'repo'}, (7, 6), (8, 1), [])
    # these two can't be chained, don't remove anything
    okay1a = Event(8, Action.REPLACED, {'pkg4a': 'repo'}, {'pkg4b': 'repo'}, (7, 6), (8, 0), [])
    okay1b = Event(9, Action.REPLACED, {'pkg4b': 'repo'}, {'pkg4c': 'repo'}, (8, 0), (8, 1), [])

    events = [conflict1a, conflict1b, conflict1c, conflict2a, conflict2b, conflict3a, conflict3b, okay1a, okay1b]
    drop_conflicting_release_events(events)

    for event in [conflict1b, conflict2b, conflict3b, okay1a, okay1b]:
        assert event in events
    for event in [conflict1a, conflict1c, conflict2a, conflict3a]:
        assert event not in events
コード例 #15
0
def test_request_pesid_repo_not_mapped_by_default(monkeypatch, source_repoid, expected_target_repoid):
    """
    Tests whether a target repository that is not mapped by default (e.g. CRB)
    is requested to be enabled on the target system if it results from the relevant events.

    Note: Since the resulting target repository is not mapped by default from the enabled repositories,
          the data handler should fail to get expected repoids for the given pesid as it works with enabled
          repositories. Therefor, this test tests whether the fallback lookup with representative repository works.
    """

    repositories_mapping = RepositoriesMapping(
        mapping=[
            RepoMapEntry(source='rhel7-base', target=['rhel8-BaseOS', 'rhel8-AppStream']),
            RepoMapEntry(source='rhel7-optional', target=['rhel8-CRB']),
        ],
        repositories=[
            PESIDRepositoryEntry(pesid='rhel7-base', major_version='7', repoid='rhel7-base-repoid',
                                 arch='x86_64', repo_type='rpm', channel='ga', rhui=''),
            PESIDRepositoryEntry(pesid='rhel7-base', major_version='7', repoid='rhel7-base-repoid-eus',
                                 arch='x86_64', repo_type='rpm', channel='eus', rhui=''),
            PESIDRepositoryEntry(pesid='rhel7-optional', major_version='7', repoid='rhel7-optional-repoid',
                                 arch='x86_64', repo_type='rpm', channel='ga', rhui=''),
            PESIDRepositoryEntry(pesid='rhel8-BaseOS', major_version='8', repoid='rhel8-baseos-repoid',
                                 arch='x86_64', repo_type='rpm', channel='ga', rhui=''),
            PESIDRepositoryEntry(pesid='rhel8-BaseOS', major_version='8', repoid='rhel8-baseos-repoid-eus',
                                 arch='x86_64', repo_type='rpm', channel='eus', rhui=''),
            PESIDRepositoryEntry(pesid='rhel8-AppStream', major_version='8', repoid='rhel8-appstream-repoid',
                                 arch='x86_64', repo_type='rpm', channel='ga', rhui=''),
            PESIDRepositoryEntry(pesid='rhel8-CRB', major_version='8', repoid='rhel8-crb-repoid',
                                 arch='x86_64', repo_type='rpm', channel='ga', rhui=''),
            PESIDRepositoryEntry(pesid='rhel8-CRB', major_version='8', repoid='rhel8-crb-repoid-eus',
                                 arch='x86_64', repo_type='rpm', channel='eus', rhui=''),
        ])

    monkeypatch.setattr(peseventsscanner, '_get_enabled_repoids', lambda: {source_repoid})
    monkeypatch.setattr(api,
                        'current_actor',
                        CurrentActorMocked(msgs=[repositories_mapping], src_ver='7.9', dst_ver='8.4'))

    event = Event(1, Action.MOVED, {'test-pkg': 'rhel7-base'}, {'test-pkg': 'rhel8-CRB'},
                  (7, 9), (8, 0), [])
    installed_pkgs = {'test-pkg'}

    tasks = process_events([(8, 0)], [event], installed_pkgs)

    assert tasks[Task.KEEP] == {'test-pkg': expected_target_repoid}
コード例 #16
0
def drop_conflicting_release_events(events):
    conflict1a = Event(1, Action.present, {'pkg1': 'repo'}, {}, (7, 6), (8, 0),
                       [])
    conflict1b = Event(2, Action.replacement, {'pkg1': 'repo'}, {}, (7, 6),
                       (8, 2), [])
    conflict1c = Event(3, Action.removal, {'pkg1': 'repo'}, {}, (7, 6), (8, 1),
                       [])
    conflict2a = Event(4, Action.removal, {'pkg2a': 'repo'}, {}, (7, 6),
                       (8, 0), [])
    conflict2b = Event(5, Action.replacement, {
        'pkg2a': 'repo',
        'pkg2b': 'repo'
    }, {}, (7, 6), (8, 1), [])
    # two input packages
    conflict3a = Event(6, Action.merge, {
        'pkg3a': 'repo',
        'pkg3b': 'repo'
    }, {'pkg3c': 'repo'}, (7, 6), (8, 0), [])
    conflict3b = Event(7, Action.merge, {
        'pkg3a': 'repo',
        'pkg3b': 'repo'
    }, {'pkg3d': 'repo'}, (7, 6), (8, 1), [])
    # these two can't be chained, don't remove anything
    okay1a = Event(8, Action.replacement, {'pkg4a': 'repo'}, {'pkg4b': 'repo'},
                   (7, 6), (8, 0), [])
    okay1b = Event(9, Action.replacement, {'pkg4b': 'repo'}, {'pkg4c': 'repo'},
                   (8, 0), (8, 1), [])

    events = [
        conflict1a, conflict1b, conflict1c, conflict2a, conflict2b, conflict3a,
        conflict3b, okay1a, okay1b
    ]
    drop_conflicting_release_events(events)

    for event in [conflict1b, conflict2b, conflict3b, okay1a, okay1b]:
        assert event in events
    for event in [conflict1a, conflict1c, conflict2a, conflict3a]:
        assert event not in events
コード例 #17
0
def test_process_events(monkeypatch):
    monkeypatch.setattr(peseventsscanner, '_get_repositories_mapping',
                        lambda: {'rhel8-repo': 'rhel8-mapped'})
    monkeypatch.setattr(peseventsscanner, 'get_repositories_blacklisted',
                        get_repos_blacklisted_mocked(set()))

    events = [
        Event(1, Action.split, {'original': 'rhel7-repo'}, {
            'split01': 'rhel8-repo',
            'split02': 'rhel8-repo'
        }, (7, 6), (8, 0), []),
        Event(2, Action.removed, {'removed': 'rhel7-repo'}, {}, (7, 6), (8, 0),
              []),
        Event(3, Action.present, {'present': 'rhel8-repo'}, {}, (7, 6), (8, 0),
              []),
        # this package is present at the start, gets removed and then reintroduced
        Event(4, Action.removed, {'reintroduced': 'rhel7-repo'}, {}, (7, 6),
              (8, 0), []),
        Event(5, Action.present, {'reintroduced': 'rhel8-repo'}, {}, (8, 0),
              (8, 1), []),
        # however, this package was never there
        Event(6, Action.removed, {'neverthere': 'rhel7-repo'}, {}, (7, 6),
              (8, 0), []),
        Event(7, Action.present, {'neverthere': 'rhel8-repo'}, {}, (8, 0),
              (8, 1), [])
    ]
    installed_pkgs = {'original', 'removed', 'present', 'reintroduced'}
    tasks = process_events([(8, 0), (8, 1)], events, installed_pkgs)

    assert tasks[Task.install] == {
        'split02': 'rhel8-mapped',
        'split01': 'rhel8-mapped'
    }
    assert tasks[Task.remove] == {
        'removed': 'rhel7-repo',
        'original': 'rhel7-repo'
    }
    assert tasks[Task.keep] == {
        'present': 'rhel8-mapped',
        'reintroduced': 'rhel8-mapped'
    }