Пример #1
0
    def testMultipleWorker2_16(self):
        self.setup_step(transfer.MultipleFileUpload(
            workersrcs=["srcfile", "srcdir"], masterdest=self.destdir),
                        worker_version={'*': '2.16'})

        self.expect_commands(
            ExpectStat(file="srcfile", workdir='wkdir').stat_file().exit(0),
            ExpectUploadFile(slavesrc="srcfile",
                             workdir='wkdir',
                             blocksize=16384,
                             maxsize=None,
                             keepstamp=False,
                             writer=ExpectRemoteRef(
                                 remotetransfer.FileWriter)).upload_string(
                                     "Hello world!\n").exit(0),
            ExpectStat(file="srcdir", workdir='wkdir').stat_dir().exit(0),
            ExpectUploadDirectory(
                slavesrc="srcdir",
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {
                            "test": "Hello world!"
                        }).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="uploading 2 files")
        d = self.run_step()
        return d
Пример #2
0
    def testException(self):
        self.setup_step(
            transfer.DirectoryUpload(workersrc='srcdir',
                                     masterdest=self.destdir))

        writers = []

        self.expect_commands(
            ExpectUploadDirectory(
                workersrc="srcdir",
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {"test": "Hello world!"},
                        error=RuntimeError('uh oh'),
                        out_writers=writers))

        self.expect_outcome(result=EXCEPTION,
                            state_string="uploading srcdir (exception)")
        yield self.run_step()

        self.assertEqual(len(writers), 1)
        self.assertEqual(writers[0].cancel.called, True)

        self.assertEqual(len(self.flushLoggedErrors(RuntimeError)), 1)
Пример #3
0
    def test_url_text(self):
        self.setup_step(
            transfer.DirectoryUpload(workersrc="srcdir",
                                     masterdest=self.destdir,
                                     url="http://server/dir",
                                     urlText='url text'))

        self.step.addURL = Mock()

        self.expect_commands(
            ExpectUploadDirectory(
                workersrc='srcdir',
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {
                            "test": "Hello world!"
                        }).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="uploading srcdir")

        yield self.run_step()

        self.step.addURL.assert_called_once_with("url text",
                                                 "http://server/dir")
Пример #4
0
    def testSubclass(self):
        class CustomStep(transfer.MultipleFileUpload):
            uploadDone = Mock(return_value=None)
            allUploadsDone = Mock(return_value=None)

        step = CustomStep(workersrcs=["srcfile", "srcdir"],
                          masterdest=self.destdir)
        self.setup_step(step)

        self.expect_commands(
            ExpectStat(file="srcfile", workdir='wkdir').stat_file().exit(0),
            ExpectUploadFile(workersrc="srcfile",
                             workdir='wkdir',
                             blocksize=16384,
                             maxsize=None,
                             keepstamp=False,
                             writer=ExpectRemoteRef(
                                 remotetransfer.FileWriter)).upload_string(
                                     "Hello world!\n").exit(0),
            ExpectStat(file="srcdir", workdir='wkdir').stat_dir().exit(0),
            ExpectUploadDirectory(
                workersrc="srcdir",
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {
                            "test": "Hello world!"
                        }).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="uploading 2 files")

        yield self.run_step()

        def checkCalls(res):
            self.assertEqual(step.uploadDone.call_count, 2)
            self.assertEqual(step.uploadDone.call_args_list[0],
                             ((SUCCESS, 'srcfile',
                               os.path.join(self.destdir, 'srcfile')), {}))
            self.assertEqual(step.uploadDone.call_args_list[1],
                             ((SUCCESS, 'srcdir',
                               os.path.join(self.destdir, 'srcdir')), {}))
            self.assertEqual(step.allUploadsDone.call_count, 1)
            self.assertEqual(
                step.allUploadsDone.call_args_list[0],
                ((SUCCESS, ['srcfile', 'srcdir'], self.destdir), {}))
Пример #5
0
    def testFailure(self):
        self.setup_step(
            transfer.DirectoryUpload(workersrc="srcdir",
                                     masterdest=self.destdir))

        self.expect_commands(
            ExpectUploadDirectory(workersrc="srcdir",
                                  workdir='wkdir',
                                  blocksize=16384,
                                  compress=None,
                                  maxsize=None,
                                  writer=ExpectRemoteRef(
                                      remotetransfer.DirectoryWriter)).exit(1))

        self.expect_outcome(result=FAILURE,
                            state_string="uploading srcdir (failure)")
        yield self.run_step()
Пример #6
0
    def testWorker2_16(self):
        self.setup_step(transfer.DirectoryUpload(workersrc="srcdir",
                                                 masterdest=self.destdir),
                        worker_version={'*': '2.16'})

        self.expect_commands(
            ExpectUploadDirectory(
                slavesrc="srcdir",
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {
                            "test": "Hello world!"
                        }).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="uploading srcdir")
        d = self.run_step()
        return d
Пример #7
0
    def testDirectory(self):
        self.setup_step(
            transfer.MultipleFileUpload(workersrcs=["srcdir"],
                                        masterdest=self.destdir))

        self.expect_commands(
            ExpectStat(file="srcdir", workdir='wkdir').stat_dir().exit(0),
            ExpectUploadDirectory(
                workersrc="srcdir",
                workdir='wkdir',
                blocksize=16384,
                compress=None,
                maxsize=None,
                writer=ExpectRemoteRef(
                    remotetransfer.DirectoryWriter)).upload_tar_file(
                        'fake.tar', {
                            "test": "Hello world!"
                        }).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="uploading 1 file")
        d = self.run_step()
        return d