コード例 #1
0
 def test_dispatchBuildToSlave_prefers_lxd(self):
     job = self.makeJob(allow_internet=False)
     builder = MockBuilder()
     builder.processor = job.build.processor
     slave = OkSlave()
     job.setBuilder(builder, slave)
     chroot_lfa = self.factory.makeLibraryFileAlias(db_only=True)
     job.build.distro_arch_series.addOrUpdateChroot(
         chroot_lfa, image_type=BuildBaseImageType.CHROOT)
     lxd_lfa = self.factory.makeLibraryFileAlias(db_only=True)
     job.build.distro_arch_series.addOrUpdateChroot(
         lxd_lfa, image_type=BuildBaseImageType.LXD)
     yield job.dispatchBuildToSlave(DevNullLogger())
     self.assertEqual(('ensurepresent', lxd_lfa.http_url, '', ''),
                      slave.call_log[0])
コード例 #2
0
 def _setupBuilder(self):
     processor = self.factory.makeProcessor(name="i386")
     builder = self.factory.makeBuilder(processors=[processor],
                                        virtualized=True,
                                        vm_host="bladh")
     builder.setCleanStatus(BuilderCleanStatus.CLEAN)
     self.patch(BuilderSlave, 'makeBuilderSlave', FakeMethod(OkSlave()))
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(distroseries=distroseries,
                                             architecturetag="i386",
                                             processor=processor)
     chroot = self.factory.makeLibraryFileAlias(db_only=True)
     das.addOrUpdateChroot(chroot)
     distroseries.nominatedarchindep = das
     return builder, distroseries, das
コード例 #3
0
 def test_verifyBuildRequest_archive_private_owners_mismatch(self):
     archive = self.factory.makeArchive(private=True)
     job = self.makeJob(archive=archive)
     lfa = self.factory.makeLibraryFileAlias()
     transaction.commit()
     job.build.distro_arch_series.addOrUpdateChroot(lfa)
     builder = MockBuilder()
     job.setBuilder(builder, OkSlave())
     logger = BufferLogger()
     e = self.assertRaises(SnapBuildArchiveOwnerMismatch,
                           job.verifyBuildRequest, logger)
     self.assertEqual(
         "Snap package builds against private archives are only allowed "
         "if the snap package owner and the archive owner are equal.",
         str(e))
コード例 #4
0
    def test_virtual_job_dispatch_pings_before_building(self):
        # We need to send a ping to the builder to work around a bug
        # where sometimes the first network packet sent is dropped.
        builder, build = self._setupBinaryBuildAndBuilder()
        candidate = build.queueBuild()
        removeSecurityProxy(builder)._findBuildCandidate = FakeMethod(
            result=candidate)
        vitals = extract_vitals_from_db(builder)
        slave = OkSlave()
        d = BuilderInteractor.findAndStartJob(vitals, builder, slave)

        def check_build_started(candidate):
            self.assertIn(('echo', 'ping'), slave.call_log)

        return d.addCallback(check_build_started)
コード例 #5
0
    def test_findAndStartJob_starts_job(self):
        # findAndStartJob finds the next queued job using _findBuildCandidate
        # and then starts it.
        # We don't care about the type of build at all.
        builder, build = self._setupRecipeBuildAndBuilder()
        candidate = build.queueBuild()
        removeSecurityProxy(builder)._findBuildCandidate = FakeMethod(
            result=candidate)
        vitals = extract_vitals_from_db(builder)
        d = BuilderInteractor.findAndStartJob(vitals, builder, OkSlave())

        def check_build_started(candidate):
            self.assertEqual(candidate.builder, builder)
            self.assertEqual(BuildStatus.BUILDING, build.status)

        return d.addCallback(check_build_started)
コード例 #6
0
    def testScanDispatchForResetBuilder(self):
        # A job gets dispatched to the sampledata builder after it's reset.

        # Reset sampledata builder.
        builder = getUtility(IBuilderSet)[BOB_THE_BUILDER_NAME]
        self._resetBuilder(builder)
        self.patch(BuilderSlave, 'makeBuilderSlave', FakeMethod(OkSlave()))
        # Set this to 1 here so that _checkDispatch can make sure it's
        # reset to 0 after a successful dispatch.
        builder.failure_count = 1

        # Run 'scan' and check its result.
        switch_dbuser(config.builddmaster.dbuser)
        scanner = self._getScanner()
        yield scanner.scan()
        self.assertEqual(0, builder.failure_count)
        self.assertTrue(builder.currentjob is not None)
コード例 #7
0
 def test_virtual_ppa_dispatch(self):
     archive = self.factory.makeArchive(virtualized=True)
     slave = OkSlave()
     builder = self.factory.makeBuilder(virtualized=True, vm_host="foohost")
     builder.setCleanStatus(BuilderCleanStatus.CLEAN)
     vitals = extract_vitals_from_db(builder)
     build = self.factory.makeBinaryPackageBuild(builder=builder,
                                                 archive=archive)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     bq = build.queueBuild()
     bq.markAsBuilding(builder)
     interactor = BuilderInteractor()
     yield interactor._startBuild(
         bq, vitals, builder, slave,
         interactor.getBuildBehaviour(bq, builder, slave), BufferLogger())
     yield self.assertExpectedInteraction(slave.call_log, builder, build,
                                          lf, archive, ArchivePurpose.PPA)
コード例 #8
0
 def test_partner_dispatch_no_publishing_history(self):
     archive = self.factory.makeArchive(virtualized=False,
                                        purpose=ArchivePurpose.PARTNER)
     slave = OkSlave()
     builder = self.factory.makeBuilder(virtualized=False)
     vitals = extract_vitals_from_db(builder)
     build = self.factory.makeBinaryPackageBuild(builder=builder,
                                                 archive=archive)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     bq = build.queueBuild()
     bq.markAsBuilding(builder)
     interactor = BuilderInteractor()
     d = interactor._startBuild(
         bq, vitals, builder, slave,
         interactor.getBuildBehavior(bq, builder, slave), BufferLogger())
     d.addCallback(self.assertExpectedInteraction, slave.call_log, builder,
                   build, lf, archive, ArchivePurpose.PARTNER)
     return d
コード例 #9
0
    def test_cancelling_build_is_cancelled(self):
        # If a build is CANCELLING and the cancel timeout expires, make sure
        # True is returned and the slave was resumed.
        slave = OkSlave()
        self.builder.vm_host = "fake_vm_host"
        buildqueue = self.builder.currentjob
        build = getUtility(IBinaryPackageBuildSet).getByQueueEntry(buildqueue)
        build.updateStatus(BuildStatus.CANCELLING)
        clock = task.Clock()
        scanner = self._getScanner(clock=clock)

        result = yield scanner.checkCancellation(self.vitals, slave,
                                                 self.interactor)
        self.assertNotIn("resume", slave.call_log)
        self.assertFalse(result)
        self.assertEqual(BuildStatus.CANCELLING, build.status)

        clock.advance(SlaveScanner.CANCEL_TIMEOUT)
        result = yield scanner.checkCancellation(self.vitals, slave,
                                                 self.interactor)
        self.assertEqual(1, slave.call_log.count("resume"))
        self.assertTrue(result)
        self.assertEqual(BuildStatus.CANCELLED, build.status)
コード例 #10
0
 def test_non_virtual_ppa_dispatch(self):
     # When the BinaryPackageBuildBehavior dispatches PPA builds to
     # non-virtual builders, it stores the chroot on the server and
     # requests a binary package build, lying to say that the archive
     # purpose is "PRIMARY" because this ensures that the package mangling
     # tools will run over the built packages.
     archive = self.factory.makeArchive(virtualized=False)
     slave = OkSlave()
     builder = self.factory.makeBuilder(virtualized=False)
     vitals = extract_vitals_from_db(builder)
     build = self.factory.makeBinaryPackageBuild(builder=builder,
                                                 archive=archive)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     bq = build.queueBuild()
     bq.markAsBuilding(builder)
     interactor = BuilderInteractor()
     d = interactor._startBuild(
         bq, vitals, builder, slave,
         interactor.getBuildBehavior(bq, builder, slave), BufferLogger())
     d.addCallback(self.assertExpectedInteraction, slave.call_log, builder,
                   build, lf, archive, ArchivePurpose.PRIMARY, 'universe')
     return d
コード例 #11
0
 def test_status_idle_slave(self):
     self.assertStatus(OkSlave(), builder_status='BuilderStatus.IDLE')
コード例 #12
0
 def test_nonvirtual_idle(self):
     # An IDLE non-virtual slave is already as clean as we can get it.
     yield self.assertCleanCalls(
         MockBuilder(virtualized=False,
                     clean_status=BuilderCleanStatus.DIRTY), OkSlave(),
         ['status'], True)