Beispiel #1
0
def setupCompleteBuilds(batch):
    """Pre-populate new object with buildqueue items.

    Single queries, using list() statement to force fetch
    of the results in python domain.

    Receive a sequence of builds, for instance, a batch.

    Return a list of built CompleteBuild instances, or empty
    list if no builds were contained in the received batch.
    """
    builds = getSpecificJobs(batch)
    if not builds:
        return []

    # This pre-population of queue entries is only implemented for
    # IBinaryPackageBuilds.
    prefetched_data = dict()
    build_ids = [
        build.id for build in builds if IBinaryPackageBuild.providedBy(build)]
    results = getUtility(IBinaryPackageBuildSet).getQueueEntriesForBuildIDs(
        build_ids)
    for (buildqueue, _builder, build_job) in results:
        # Get the build's id, 'buildqueue', 'sourcepackagerelease' and
        # 'buildlog' (from the result set) respectively.
        prefetched_data[build_job.build.id] = buildqueue

    complete_builds = []
    for build in builds:
        if IBinaryPackageBuild.providedBy(build):
            buildqueue = prefetched_data.get(build.id)
            complete_builds.append(CompleteBuild(build, buildqueue))
        else:
            complete_builds.append(build)
    return complete_builds
    def test_binary_only_false(self):
        # A builder can optionally return the more general
        # build farm job objects.
        from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJobSource
        getUtility(IBuildFarmJobSource).new(
            job_type=BuildFarmJobType.RECIPEBRANCHBUILD,
            status=BuildStatus.BUILDING, builder=self.context)

        builds = self.context.getBuildRecords(binary_only=True)
        binary_only_count = builds.count()

        self.assertTrue(
            all([IBinaryPackageBuild.providedBy(build) for build in builds]))

        builds = self.context.getBuildRecords(binary_only=False)
        all_count = builds.count()

        self.assertFalse(
            any([IBinaryPackageBuild.providedBy(build) for build in builds]))
        self.assertTrue(
            all([IBuildFarmJob.providedBy(build) for build in builds]))
        self.assertBetween(0, binary_only_count, all_count)
    def test_binary_only_false(self):
        # A builder can optionally return the more general
        # build farm job objects.
        from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJobSource
        getUtility(IBuildFarmJobSource).new(
            job_type=BuildFarmJobType.RECIPEBRANCHBUILD,
            status=BuildStatus.BUILDING,
            builder=self.context)

        builds = self.context.getBuildRecords(binary_only=True)
        binary_only_count = builds.count()

        self.assertTrue(
            all([IBinaryPackageBuild.providedBy(build) for build in builds]))

        builds = self.context.getBuildRecords(binary_only=False)
        all_count = builds.count()

        self.assertFalse(
            any([IBinaryPackageBuild.providedBy(build) for build in builds]))
        self.assertTrue(
            all([IBuildFarmJob.providedBy(build) for build in builds]))
        self.assertBetween(0, binary_only_count, all_count)
Beispiel #4
0
def setupCompleteBuilds(batch):
    """Pre-populate new object with buildqueue items.

    Single queries, using list() statement to force fetch
    of the results in python domain.

    Receive a sequence of builds, for instance, a batch.

    Return a list of built CompleteBuild instances, or empty
    list if no builds were contained in the received batch.
    """
    builds = getSpecificJobs(batch)
    if not builds:
        return []

    # This pre-population of queue entries is only implemented for
    # IBinaryPackageBuilds.
    prefetched_data = dict()
    build_ids = [
        build.id for build in builds if IBinaryPackageBuild.providedBy(build)
    ]
    results = getUtility(IBinaryPackageBuildSet).getQueueEntriesForBuildIDs(
        build_ids)
    for (buildqueue, _builder, build_job) in results:
        # Get the build's id, 'buildqueue', 'sourcepackagerelease' and
        # 'buildlog' (from the result set) respectively.
        prefetched_data[build_job.build.id] = buildqueue

    complete_builds = []
    for build in builds:
        if IBinaryPackageBuild.providedBy(build):
            buildqueue = prefetched_data.get(build.id)
            complete_builds.append(CompleteBuild(build, buildqueue))
        else:
            complete_builds.append(build)
    return complete_builds