Example #1
0
 def test_dont_dispatch_release_builds(self):
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     distroseries = self.factory.makeDistroSeries(
         status=SeriesStatus.CURRENT, distribution=archive.distribution)
     distro_arch_series = self.factory.makeDistroArchSeries(
         distroseries=distroseries)
     build = self.factory.makeBinaryPackageBuild(
         builder=builder,
         archive=archive,
         distroarchseries=distro_arch_series,
         pocket=PackagePublishingPocket.RELEASE)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(AssertionError, behavior.verifyBuildRequest,
                           BufferLogger())
     expected_message = (
         "%s (%s) can not be built for pocket %s: invalid pocket due "
         "to the series status of %s." %
         (build.title, build.id, build.pocket.name,
          build.distro_series.name))
     self.assertEqual(expected_message, str(e))
 def test_dont_dispatch_release_builds(self):
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     distroseries = self.factory.makeDistroSeries(
         status=SeriesStatus.CURRENT, distribution=archive.distribution)
     distro_arch_series = self.factory.makeDistroArchSeries(
         distroseries=distroseries)
     build = self.factory.makeBinaryPackageBuild(
         builder=builder, archive=archive,
         distroarchseries=distro_arch_series,
         pocket=PackagePublishingPocket.RELEASE)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(
         AssertionError, behavior.verifyBuildRequest, BufferLogger())
     expected_message = (
         "%s (%s) can not be built for pocket %s: invalid pocket due "
         "to the series status of %s." % (
             build.title, build.id, build.pocket.name,
             build.distro_series.name))
     self.assertEqual(expected_message, str(e))
 def test_verifyBuildRequest_bad_pocket(self):
     # verifyBuildRequest will raise if a bad pocket is proposed.
     build = self.factory.makeSourcePackageRecipeBuild(pocket=PackagePublishingPocket.SECURITY)
     job = self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build)
     job = IBuildFarmJobBehavior(job.specific_job)
     job.setBuilder(MockBuilder("bob-de-bouwer"), OkSlave())
     e = self.assertRaises(AssertionError, job.verifyBuildRequest, BufferLogger())
     self.assertIn("invalid pocket due to the series status of", str(e))
Example #4
0
 def test_verifyBuildRequest_bad_pocket(self):
     # verifyBuildRequest will raise if a bad pocket is proposed.
     build = self.factory.makeSourcePackageRecipeBuild(
         pocket=PackagePublishingPocket.SECURITY)
     job = self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build)
     job = IBuildFarmJobBehavior(job.specific_job)
     job.setBuilder(MockBuilder("bob-de-bouwer"), OkSlave())
     e = self.assertRaises(AssertionError, job.verifyBuildRequest,
                           BufferLogger())
     self.assertIn('invalid pocket due to the series status of', str(e))
 def test_verifyBuildRequest_no_chroot(self):
     # Don't dispatch a build when the DAS has no chroot.
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     build = self.factory.makeBinaryPackageBuild(
         builder=builder, archive=archive)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(
         CannotBuild, behavior.verifyBuildRequest, BufferLogger())
     self.assertIn("Missing CHROOT", str(e))
Example #6
0
 def test_verifyBuildRequest_no_chroot(self):
     # Don't dispatch a build when the DAS has no chroot.
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     build = self.factory.makeBinaryPackageBuild(builder=builder,
                                                 archive=archive)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(CannotBuild, behavior.verifyBuildRequest,
                           BufferLogger())
     self.assertIn("Missing CHROOT", str(e))
    def test_log_file_collection(self):
        self.build.updateStatus(BuildStatus.FULLYBUILT)
        old_tmps = sorted(os.listdir('/tmp'))

        slave = WaitingSlave('BuildStatus.OK')

        def got_log(logfile_lfa_id):
            # Grabbing logs should not leave new files in /tmp (bug #172798)
            logfile_lfa = getUtility(ILibraryFileAliasSet)[logfile_lfa_id]
            new_tmps = sorted(os.listdir('/tmp'))
            self.assertEqual(old_tmps, new_tmps)

            # The new librarian file is stored compressed with a .gz
            # extension and text/plain file type for easy viewing in
            # browsers, as it decompresses and displays the file inline.
            self.assertTrue(
                logfile_lfa.filename.endswith('_FULLYBUILT.txt.gz'))
            self.assertEqual('text/plain', logfile_lfa.mimetype)
            self.layer.txn.commit()

            # LibrarianFileAlias does not implement tell() or seek(), which
            # are required by gzip.open(), so we need to read the file out
            # of the librarian first.
            fd, fname = tempfile.mkstemp()
            self.addCleanup(os.remove, fname)
            tmp = os.fdopen(fd, 'wb')
            tmp.write(logfile_lfa.read())
            tmp.close()
            uncompressed_file = gzip.open(fname).read()

            # Now make a temp filename that getFile() can write to.
            fd, tmp_orig_file_name = tempfile.mkstemp()
            self.addCleanup(os.remove, tmp_orig_file_name)

            # Check that the original file from the slave matches the
            # uncompressed file in the librarian.
            def got_orig_log(ignored):
                orig_file_content = open(tmp_orig_file_name).read()
                self.assertEqual(orig_file_content, uncompressed_file)

            d = removeSecurityProxy(slave).getFile(
                'buildlog', tmp_orig_file_name)
            return d.addCallback(got_orig_log)

        behavior = IBuildFarmJobBehavior(self.candidate.specific_job)
        behavior.setBuilder(self.builder, slave)
        d = behavior.getLogFromSlave(self.build.buildqueue_record)
        return d.addCallback(got_log)
Example #8
0
    def test_log_file_collection(self):
        self.build.updateStatus(BuildStatus.FULLYBUILT)
        old_tmps = sorted(os.listdir('/tmp'))

        slave = WaitingSlave('BuildStatus.OK')

        def got_log(logfile_lfa_id):
            # Grabbing logs should not leave new files in /tmp (bug #172798)
            logfile_lfa = getUtility(ILibraryFileAliasSet)[logfile_lfa_id]
            new_tmps = sorted(os.listdir('/tmp'))
            self.assertEqual(old_tmps, new_tmps)

            # The new librarian file is stored compressed with a .gz
            # extension and text/plain file type for easy viewing in
            # browsers, as it decompresses and displays the file inline.
            self.assertTrue(
                logfile_lfa.filename.endswith('_FULLYBUILT.txt.gz'))
            self.assertEqual('text/plain', logfile_lfa.mimetype)
            self.layer.txn.commit()

            # LibrarianFileAlias does not implement tell() or seek(), which
            # are required by gzip.open(), so we need to read the file out
            # of the librarian first.
            fd, fname = tempfile.mkstemp()
            self.addCleanup(os.remove, fname)
            tmp = os.fdopen(fd, 'wb')
            tmp.write(logfile_lfa.read())
            tmp.close()
            uncompressed_file = gzip.open(fname).read()

            # Now make a temp filename that getFile() can write to.
            fd, tmp_orig_file_name = tempfile.mkstemp()
            self.addCleanup(os.remove, tmp_orig_file_name)

            # Check that the original file from the slave matches the
            # uncompressed file in the librarian.
            def got_orig_log(ignored):
                orig_file_content = open(tmp_orig_file_name).read()
                self.assertEqual(orig_file_content, uncompressed_file)

            d = removeSecurityProxy(slave).getFile('buildlog',
                                                   tmp_orig_file_name)
            return d.addCallback(got_orig_log)

        behavior = IBuildFarmJobBehavior(self.candidate.specific_job)
        behavior.setBuilder(self.builder, slave)
        d = behavior.getLogFromSlave(self.build.buildqueue_record)
        return d.addCallback(got_log)
    def makeBehavior(self, branch=None, use_fake_chroot=True):
        """Create a TranslationTemplatesBuildBehavior.

        Anything that might communicate with build slaves and such
        (which we can't really do here) is mocked up.
        """
        specific_job = self.factory.makeTranslationTemplatesBuildJob(
            branch=branch)
        behavior = IBuildFarmJobBehavior(specific_job)
        slave = WaitingSlave()
        behavior.setBuilder(self.factory.makeBuilder(), slave)
        if use_fake_chroot:
            lf = self.factory.makeLibraryFileAlias()
            self.layer.txn.commit()
            behavior._getChroot = lambda: lf
        return behavior
    def makeBehavior(self, branch=None, use_fake_chroot=True):
        """Create a TranslationTemplatesBuildBehavior.

        Anything that might communicate with build slaves and such
        (which we can't really do here) is mocked up.
        """
        specific_job = self.factory.makeTranslationTemplatesBuildJob(
            branch=branch)
        behavior = IBuildFarmJobBehavior(specific_job)
        slave = WaitingSlave()
        behavior.setBuilder(self.factory.makeBuilder(), slave)
        if use_fake_chroot:
            lf = self.factory.makeLibraryFileAlias()
            self.layer.txn.commit()
            behavior._getChroot = lambda: lf
        return behavior
 def test_dont_dispatch_security_builds(self):
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     build = self.factory.makeBinaryPackageBuild(
         builder=builder, archive=archive,
         pocket=PackagePublishingPocket.SECURITY)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(
         AssertionError, behavior.verifyBuildRequest, BufferLogger())
     self.assertEqual(
         'Soyuz is not yet capable of building SECURITY uploads.',
         str(e))
Example #12
0
 def test_dont_dispatch_security_builds(self):
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY)
     builder = self.factory.makeBuilder()
     build = self.factory.makeBinaryPackageBuild(
         builder=builder,
         archive=archive,
         pocket=PackagePublishingPocket.SECURITY)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(AssertionError, behavior.verifyBuildRequest,
                           BufferLogger())
     self.assertEqual(
         'Soyuz is not yet capable of building SECURITY uploads.', str(e))
 def test_verifyBuildRequest(self):
     # Don't allow a virtual build on a non-virtual builder.
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
     builder = self.factory.makeBuilder(virtualized=False)
     build = self.factory.makeBinaryPackageBuild(
         builder=builder, archive=archive,
         pocket=PackagePublishingPocket.RELEASE)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(
         AssertionError, behavior.verifyBuildRequest, BufferLogger())
     self.assertEqual(
         'Attempt to build virtual item on a non-virtual builder.',
         str(e))
Example #14
0
 def test_verifyBuildRequest(self):
     # Don't allow a virtual build on a non-virtual builder.
     archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
     builder = self.factory.makeBuilder(virtualized=False)
     build = self.factory.makeBinaryPackageBuild(
         builder=builder,
         archive=archive,
         pocket=PackagePublishingPocket.RELEASE)
     lf = self.factory.makeLibraryFileAlias()
     transaction.commit()
     build.distro_arch_series.addOrUpdateChroot(lf)
     candidate = build.queueBuild()
     behavior = IBuildFarmJobBehavior(candidate.specific_job)
     behavior.setBuilder(builder, None)
     e = self.assertRaises(AssertionError, behavior.verifyBuildRequest,
                           BufferLogger())
     self.assertEqual(
         'Attempt to build virtual item on a non-virtual builder.', str(e))
Example #15
0
 def getBuildBehavior(queue_item, builder, slave):
     if queue_item is None:
         return None
     behavior = IBuildFarmJobBehavior(queue_item.specific_job)
     behavior.setBuilder(builder, slave)
     return behavior
Example #16
0
 def getBuildBehavior(queue_item, builder, slave):
     if queue_item is None:
         return None
     behavior = IBuildFarmJobBehavior(queue_item.specific_job)
     behavior.setBuilder(builder, slave)
     return behavior