Exemplo n.º 1
0
 def test_triggers_store_uploads(self):
     # The upload processor triggers store uploads if appropriate.
     self.pushConfig("snappy",
                     store_url="http://sca.example/",
                     store_upload_url="http://updown.example/")
     self.switchToAdmin()
     self.snap.store_series = self.factory.makeSnappySeries(
         usable_distro_series=[self.snap.distro_series])
     self.snap.store_name = self.snap.name
     self.snap.store_upload = True
     self.snap.store_secrets = {"root": Macaroon().serialize()}
     Store.of(self.snap).flush()
     self.switchToUploader()
     self.assertFalse(self.build.verifySuccessfulUpload())
     upload_dir = os.path.join(self.incoming_folder, "test",
                               str(self.build.id), "ubuntu")
     write_file(os.path.join(upload_dir, "wget_0_all.snap"), "snap")
     handler = UploadHandler.forProcessor(self.uploadprocessor,
                                          self.incoming_folder, "test",
                                          self.build)
     result = handler.processSnap(self.log)
     self.assertEqual(
         UploadStatusEnum.ACCEPTED, result,
         "Snap upload failed\nGot: %s" % self.log.getLogBuffer())
     self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
     self.assertTrue(self.build.verifySuccessfulUpload())
     self.assertEqual(1, len(list(self.build.store_upload_jobs)))
Exemplo n.º 2
0
 def test_requires_snap(self):
     # The upload processor fails if the upload does not contain any
     # .snap files.
     self.assertFalse(self.build.verifySuccessfulUpload())
     upload_dir = os.path.join(self.incoming_folder, "test",
                               str(self.build.id), "ubuntu")
     write_file(os.path.join(upload_dir, "wget_0_all.manifest"), "manifest")
     handler = UploadHandler.forProcessor(self.uploadprocessor,
                                          self.incoming_folder, "test",
                                          self.build)
     result = handler.processSnap(self.log)
     self.assertEqual(UploadStatusEnum.REJECTED, result)
     self.assertIn("ERROR Build did not produce any snap packages.",
                   self.log.getLogBuffer())
     self.assertFalse(self.build.verifySuccessfulUpload())
Exemplo n.º 3
0
 def test_sets_build_and_state(self):
     # The upload processor uploads files and sets the correct status.
     self.assertFalse(self.build.verifySuccessfulUpload())
     upload_dir = os.path.join(self.incoming_folder, "test",
                               str(self.build.id), "ubuntu")
     write_file(os.path.join(upload_dir, "wget_0_all.snap"), "snap")
     write_file(os.path.join(upload_dir, "wget_0_all.manifest"), "manifest")
     handler = UploadHandler.forProcessor(self.uploadprocessor,
                                          self.incoming_folder, "test",
                                          self.build)
     result = handler.processSnap(self.log)
     self.assertEqual(
         UploadStatusEnum.ACCEPTED, result,
         "Snap upload failed\nGot: %s" % self.log.getLogBuffer())
     self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
     self.assertTrue(self.build.verifySuccessfulUpload())
    def _uploadBinary(self, archtag, build):
        """Upload the base binary.

        Ensure it got processed and has a respective queue record.
        Return the IBuild attached to upload.
        """
        self._prepareUpload(self.binary_dir)
        fsroot = os.path.join(self.queue_folder, "incoming")
        handler = UploadHandler.forProcessor(
            self.build_uploadprocessor, fsroot, self.binary_dir, build=build)
        handler.processChangesFile(self.getBinaryChangesfileFor(archtag))
        last_processed = self.build_uploadprocessor.last_processed_upload
        queue_item = last_processed.queue_root
        self.assertTrue(
            queue_item is not None,
            "Binary Upload Failed\nGot: %s" % self.log.getLogBuffer())
        self.assertEqual(1, len(queue_item.builds))
        return queue_item.builds[0].build
Exemplo n.º 5
0
 def _uploadSource(self):
     """Upload and Accept (if necessary) the base source."""
     self._prepareUpload(self.source_dir)
     fsroot = os.path.join(self.queue_folder, "incoming")
     handler = UploadHandler.forProcessor(self.uploadprocessor, fsroot,
                                          self.source_dir)
     handler.processChangesFile(self.source_changesfile)
     queue_item = self.uploadprocessor.last_processed_upload.queue_root
     self.assertTrue(
         queue_item is not None,
         "Source Upload Failed\nGot: %s" % self.log.getLogBuffer())
     acceptable_statuses = [
         PackageUploadStatus.NEW,
         PackageUploadStatus.UNAPPROVED,
     ]
     if queue_item.status in acceptable_statuses:
         queue_item.setAccepted()
     # Store source queue item for future use.
     self.source_queue = queue_item
    def testSetsBuildAndState(self):
        # Ensure that the upload processor correctly links the SPR to
        # the SPRB, and that the status is set properly.
        # This test depends on write access being granted to anybody
        # (it does not matter who) on SPRB.{status,upload_log}.
        self.assertIs(None, self.build.source_package_release)
        self.assertEqual(False, self.build.verifySuccessfulUpload())
        self.queueUpload('bar_1.0-1', '%d/ubuntu' % self.build.archive.id)
        fsroot = os.path.join(self.queue_folder, "incoming")
        handler = UploadHandler.forProcessor(
            self.uploadprocessor, fsroot, 'bar_1.0-1', self.build)
        result = handler.processChangesFile(
            '%d/ubuntu/bar_1.0-1_source.changes' % self.build.archive.id)
        self.layer.txn.commit()

        self.assertEquals(UploadStatusEnum.ACCEPTED, result,
            "Source upload failed\nGot: %s" % self.log.getLogBuffer())

        self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
        self.assertEqual(True, self.build.verifySuccessfulUpload())
Exemplo n.º 7
0
    def testSetsBuildAndState(self):
        # Ensure that the upload processor correctly links the SPR to
        # the SPRB, and that the status is set properly.
        # This test depends on write access being granted to anybody
        # (it does not matter who) on SPRB.{status,upload_log}.
        self.assertIs(None, self.build.source_package_release)
        self.assertEqual(False, self.build.verifySuccessfulUpload())
        self.queueUpload('bar_1.0-1', '%d/ubuntu' % self.build.archive.id)
        fsroot = os.path.join(self.queue_folder, "incoming")
        handler = UploadHandler.forProcessor(self.uploadprocessor, fsroot,
                                             'bar_1.0-1', self.build)
        result = handler.processChangesFile(
            '%d/ubuntu/bar_1.0-1_source.changes' % self.build.archive.id)
        self.layer.txn.commit()

        self.assertEqual(
            UploadStatusEnum.ACCEPTED, result,
            "Source upload failed\nGot: %s" % self.log.getLogBuffer())

        self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
        self.assertEqual(True, self.build.verifySuccessfulUpload())