def test_skipped_just_repos(current_actor_context):
    reported_repos = ['repo_a', 'repo_b', 'repo_c']
    current_actor_context.feed(
        SkippedRepositories(packages=[], repos=list(reported_repos)))

    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports
    assert len(reports) == 1
    report = reports[0]
    for repo in reported_repos:
        assert '\n- {}'.format(repo) in report.detail.get('summary')
示例#2
0
def test_skipped_repos(current_actor_context):
    reported_packages = ['pkg_a', 'pkg_b', 'pkg_c']
    reported_repos = ['repo_a', 'repo_b', 'repo_c']
    current_actor_context.feed(
        SkippedRepositories(packages=list(reported_packages),
                            repos=list(reported_repos)))

    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert reports
    assert len(reports) == 1
    report_fields = reports[0].report
    for pkg in reported_packages:
        assert '\n- {}'.format(pkg) in report_fields['summary']
    for repo in reported_repos:
        assert '\n- {}'.format(repo) in report_fields['summary']
def process():
    # load all data / messages
    used_repoids_dict = _get_used_repo_dict()
    enabled_repoids = _get_enabled_repoids()
    excluded_repoids = _get_blacklisted_repoids()
    custom_repos = _get_custom_target_repos()

    # TODO(pstodulk): isn't that a potential issue that we map just enabled repos
    # instead of enabled + used repos??
    # initialise basic data
    repomap = _setup_repomap_handler(enabled_repoids)
    mapped_repoids = _get_mapped_repoids(repomap, enabled_repoids)
    skipped_repoids = enabled_repoids & set(
        used_repoids_dict.keys()) - mapped_repoids

    # Now get the info what should be the target RHEL repositories
    expected_repos = repomap.get_expected_target_pesid_repos(enabled_repoids)
    target_rhel_repoids = set()
    for target_pesid, target_pesidrepo in expected_repos.items():
        if not target_pesidrepo:
            # With the original repomap data, this should not happen (this should
            # currently point to a problem in our data
            # TODO(pstodulk): add report? inhibitor? what should be in the report?
            api.current_logger().error(
                'Missing target repository from the {} family (PES ID).'.
                format(target_pesid))
            continue
        if target_pesidrepo.repoid in excluded_repoids:
            api.current_logger().debug(
                'Skipping the {} repo (excluded).'.format(
                    target_pesidrepo.repoid))
            continue
        target_rhel_repoids.add(target_pesidrepo.repoid)

    # FIXME: this could possibly result into a try to enable multiple repositories
    # from the same family (pesid). But unless we have a bug in previous actors,
    # it should not happen :) it's not blocker error anyway, so survive it.
    # - We expect to deliver the fix as part of the refactoring when we merge
    # setuptargetrepos & peseventsscanner actors together (+ blacklistrepos?)
    for task in api.consume(RepositoriesSetupTasks):
        for repo in task.to_enable:
            if repo in excluded_repoids:
                api.current_logger().debug(
                    'Skipping the {} repo from setup task (excluded).'.format(
                        repo))
                continue
            target_rhel_repoids.add(repo)

    # create the final lists and sort them (for easier testing)
    rhel_repos = [
        RHELTargetRepository(repoid=repoid)
        for repoid in sorted(target_rhel_repoids)
    ]
    custom_repos = [
        repo for repo in custom_repos if repo.repoid not in excluded_repoids
    ]
    custom_repos = sorted(custom_repos, key=lambda x: x.repoid)

    if skipped_repoids:
        pkgs = set()
        for repo in skipped_repoids:
            pkgs.update(used_repoids_dict[repo])
        api.produce(
            SkippedRepositories(repos=sorted(skipped_repoids),
                                packages=sorted(pkgs)))

    api.produce(
        TargetRepositories(
            rhel_repos=rhel_repos,
            custom_repos=custom_repos,
        ))
示例#4
0
    def process(self):
        # TODO: Think about Beta and Alpha repositories. How will we tell we
        # + want to go to GA, Alpha, Beta, ... repos?

        custom_repos = []
        for repo in self.consume(CustomTargetRepository):
            custom_repos.append(repo)

        enabled_repos = set()
        for repos in self.consume(RepositoriesFacts):
            for repo_file in repos.repositories:
                for repo in repo_file.data:
                    if repo.enabled:
                        enabled_repos.add(repo.repoid)

        rhel_repos = []
        mapped_repos = set()
        for repos_map in self.consume(RepositoriesMap):
            for repo_map in repos_map.repositories:
                # Check if repository map architecture matches system architecture
                if platform.machine() != repo_map.arch:
                    continue

                mapped_repos.add(repo_map.from_repoid)
                if repo_map.from_repoid in enabled_repos:
                    rhel_repos.append(
                        RHELTargetRepository(repoid=repo_map.to_repoid))

        skipped_repos = enabled_repos.difference(mapped_repos)

        used = {}
        for used_repos in self.consume(UsedRepositories):
            for used_repo in used_repos.repositories:
                used[used_repo.repository] = used_repo.packages
                for repo in repo_file.data:
                    enabled_repos.add(repo.repoid)

        skipped_repos = skipped_repos.intersection(set(used.keys()))

        if skipped_repos:
            pkgs = set()
            for repo in skipped_repos:
                pkgs.update(used[repo])
            self.produce(
                SkippedRepositories(repos=list(skipped_repos),
                                    packages=list(pkgs)))

        for task in self.consume(RepositoriesSetupTasks):
            for repo in task.to_enable:
                rhel_repos.append(RHELTargetRepository(repoid=repo))

        repos_blacklisted = set()
        for blacklist in self.consume(RepositoriesBlacklisted):
            repos_blacklisted.update(blacklist.repoids)
        rhel_repos = [
            repo for repo in rhel_repos if repo.repoid not in repos_blacklisted
        ]
        custom_repos = [
            repo for repo in custom_repos
            if repo.repoid not in repos_blacklisted
        ]

        self.produce(
            TargetRepositories(
                rhel_repos=rhel_repos,
                custom_repos=custom_repos,
            ))
def test_skipped_repos_no_repos(current_actor_context):
    current_actor_context.feed(SkippedRepositories(packages=['woot'],
                                                   repos=[]))
    current_actor_context.run()
    reports = list(current_actor_context.consume(Report))
    assert not reports