Esempio n. 1
0
 def test_mode_full_clean_logEnviron(self):
     self.setupStep(
         mercurial.Mercurial(repourl='http://hg.mozilla.org',
                             mode='full',
                             method='clean',
                             branchType='inrepo',
                             logEnviron=False))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version'],
                     logEnviron=False) + 0,
         Expect('stat', dict(file='wkdir/.hg', logEnviron=False)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', '--config', 'extensions.purge=',
                         'purge'
                     ],
                     logEnviron=False) + 0,
         ExpectShell(
             workdir='wkdir',
             command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org'],
             logEnviron=False) + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch'],
                     logEnviron=False) +
         ExpectShell.log('stdio', stdout='default') + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'update', '--clean'],
                     logEnviron=False) + 0,
         ExpectShell(
             workdir='wkdir',
             command=['hg', '--verbose', 'identify', '--id', '--debug'],
             logEnviron=False) + ExpectShell.log('stdio', stdout='\n') +
         ExpectShell.log(
             'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') +
         0,
     )
     self.expectOutcome(result=SUCCESS, status_text=["update"])
     return self.runStep()
Esempio n. 2
0
    def test_with_head_branch(self):
        self.setupStep(
            self.stepClass(repourl='http://github.com/buildbot/buildbot.git',
                           mode='full',
                           method='clean'),
            dict(branch='refs/pull/1234/head', revision='12345678'))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['git', '--version']) +
            ExpectShell.log('stdio', stdout='git version 1.7.5') + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('listdir', {
                'dir': 'wkdir',
                'logEnviron': True,
                'timeout': 1200
            }) + Expect.update('files', ['.git']) + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'clean', '-f', '-f', '-d']) + 0,
            # in the case of the head, we try to find if the head is already present
            # and reset to that without fetching
            ExpectShell(workdir='wkdir',
                        command=['git', 'cat-file', '-e', '12345678']) + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'reset', '--hard', '12345678', '--']) +
            0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'branch', '-M', 'refs/pull/1234/head'
                                 ]) + 0,
            ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD'])
            + ExpectShell.log(
                'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') +
            0,
        )
        self.expectOutcome(result=SUCCESS)
        self.expectProperty('got_revision',
                            'f6ad368298bd941e934a41f3babc827b2aa95a1d',
                            'GitHub')
        return self.runStep()
Esempio n. 3
0
    def test_mode_incremental_retry(self):
        self.setupStep(
            mtn.Monotone(repourl='mtn://localhost/monotone',
                         mode='incremental',
                         branch='master',
                         retry=(0, 1)))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['mtn', '--version']) +
            ExpectShell.log('stdio', stdout=self.MTN_VER) + 0,
            Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0,
            ExpectShell(workdir='.',
                        command=['mtn', 'db', 'info', '--db', 'db.mtn']) +
            ExpectShell.log('stdio', stdout='') + 0,
            ExpectShell(workdir='.',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db', 'db.mtn', '--ticker=dot'
                        ]) + 1,
            ExpectShell(workdir='.',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db', 'db.mtn', '--ticker=dot'
                        ]) + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'update', '--revision', 'h:master',
                            '--branch', 'master'
                        ]) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'automate', 'select', 'w:']) +
            ExpectShell.log('stdio', stdout=self.REVID) + 0,
        )
        self.expectOutcome(result=SUCCESS)
        self.expectProperty('got_revision', self.REVID, 'Monotone')
        return self.runStep()
 def test_mode_incremental_existing_repo(self):
     self.setupStep(
         mercurial.Mercurial(repourl='http://hg.mozilla.org',
                             mode='incremental', branchType='inrepo'))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version'])
         + 0,
         Expect('stat', dict(file='wkdir/.buildbot-patched',
                             logEnviron=True))
         + 1,
         Expect('stat', dict(file='wkdir/.hg',
                             logEnviron=True))
         + 0,  # directory exists
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'pull',
                              'http://hg.mozilla.org'])
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch'])
         + ExpectShell.log('stdio', stdout='default')
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'locate', 'set:added()'])
         + 1,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'update', '--clean',
                              '--rev', 'default'])
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'parents',
                              '--template', '{node}\\n'])
         + ExpectShell.log('stdio', stdout='\n')
         + ExpectShell.log('stdio',
                           stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
         + 0,
     )
     self.expectOutcome(result=SUCCESS)
     return self.runStep()
    def test_mode_full_clean_force_build(self):
        self.setupStep(
            gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git',
                          mode='full',
                          method='clean'))
        self.build.setProperty("gerrit_change", "1234/567")

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['git', '--version']) +
            ExpectShell.log('stdio', stdout='git version 1.7.5') + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/.git', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'clean', '-f', '-f', '-d']) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'git', 'fetch', '-t',
                            'http://github.com/buildbot/buildbot.git',
                            'refs/changes/34/1234/567'
                        ]) + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'
                                 ]) + 0,
            ExpectShell(
                workdir='wkdir',
                command=['git', 'branch', '-M', 'refs/changes/34/1234/567']) +
            0,
            ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD'])
            + ExpectShell.log(
                'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') +
            0,
        )
        self.expectOutcome(result=SUCCESS, status_text=["update"])
        self.expectProperty('got_revision',
                            'f6ad368298bd941e934a41f3babc827b2aa95a1d',
                            'Gerrit')
        return self.runStep()
 def test_mode_incremental_branch_change(self):
     self.setupStep(
         mercurial.Mercurial(repourl='http://hg.mozilla.org',
                             mode='incremental',
                             branchType='inrepo'), dict(branch='stable', ))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version']) + 0,
         Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 0,
         ExpectShell(
             workdir='wkdir',
             command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org']) +
         0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch']) +
         ExpectShell.log('stdio', stdout='default') + 0,
         Expect('rmdir', dict(dir='wkdir', logEnviron=True)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', 'clone', '--noupdate',
                         'http://hg.mozilla.org', '.'
                     ]) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', 'update', '--clean', '--rev',
                         'stable'
                     ]) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', 'parents', '--template',
                         '{node}\\n'
                     ]) + ExpectShell.log('stdio', stdout='\n') +
         ExpectShell.log(
             'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') +
         0,
     )
     self.expectOutcome(result=SUCCESS, status_text=["update"])
     return self.runStep()
Esempio n. 7
0
    def test_mode_full_clean_no_existing_db(self):
        self.setupStep(
            mtn.Monotone(repourl='mtn://localhost/monotone',
                         mode='full',
                         method='clean',
                         branch='master'))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['mtn', '--version']) +
            ExpectShell.log('stdio', stdout=self.MTN_VER) + 0,
            Expect('stat', dict(file='db.mtn', logEnviron=True)) + 1,
            ExpectShell(workdir='.',
                        command=['mtn', 'db', 'init', '--db', 'db.mtn']) + 0,
            ExpectShell(workdir='.',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db', 'db.mtn', '--ticker=dot'
                        ]) + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) +
            ExpectShell.log('stdio', stdout='file1\nfile2') + 0,
            Expect('rmdir',
                   dict(dir=['wkdir/file1', 'wkdir/file2'], logEnviron=True)) +
            0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'update', '--revision', 'h:master',
                            '--branch', 'master'
                        ]) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'automate', 'select', 'w:']) +
            ExpectShell.log('stdio', stdout=self.REVID) + 0,
        )
        self.expectOutcome(result=SUCCESS)
        self.expectProperty('got_revision', self.REVID, 'Monotone')
        return self.runStep()
Esempio n. 8
0
 def test_mode_incremental_existing_repo_added_files_old_rmdir(self):
     self.setupStep(
         mercurial.Mercurial(repourl='http://hg.mozilla.org',
                             mode='incremental',
                             branchType='inrepo'))
     self.patch_slaveVersionIsOlderThan(True)
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version']) + 0,
         Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) +
         0,  # directory exists
         ExpectShell(
             workdir='wkdir',
             command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org']) +
         0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch']) +
         ExpectShell.log('stdio', stdout='default') + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'locate', 'set:added()']) +
         ExpectShell.log('stdio', stdout='foo\nbar/baz\n') + 1,
         Expect('rmdir', dict(dir='wkdir/foo', logEnviron=True)) + 0,
         Expect('rmdir', dict(dir='wkdir/bar/baz', logEnviron=True)) + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'update', '--clean']) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', 'parents', '--template',
                         '{node}\\n'
                     ]) + ExpectShell.log('stdio', stdout='\n') +
         ExpectShell.log(
             'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') +
         0,
     )
     self.expectOutcome(result=SUCCESS, status_text=["update"])
     return self.runStep()
Esempio n. 9
0
    def test_mode_incremental_retryFetch(self):
        self.setupStep(
                git.Git(repourl='http://github.com/buildbot/buildbot.git',
                        mode='incremental', retryFetch=True))

        self.expectCommands(
            ExpectShell(workdir='wkdir',
                        command=['git', '--version'])
            + 0,
            Expect('stat', dict(file='wkdir/.git',
                                logEnviron=True))
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'fetch', '-t',
                                 'http://github.com/buildbot/buildbot.git',
                                 'HEAD'])
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'reset', '--hard', 'FETCH_HEAD'])
            + 1,
            ExpectShell(workdir='wkdir',
                        command=['git', 'fetch', '-t',
                                 'http://github.com/buildbot/buildbot.git',
                                 'HEAD'])
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'reset', '--hard', 'FETCH_HEAD'])
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['git', 'rev-parse', 'HEAD'])
            + ExpectShell.log('stdio',
                stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
            + 0,
        )
        self.expectOutcome(result=SUCCESS, status_text=["update"])
        return self.runStep()
Esempio n. 10
0
 def test_mode_full_clean_patch(self):
     self.setupStep(cvs.CVS(
         cvsroot=":pserver:[email protected]:/cvsroot",
         cvsmodule="mozilla/browser/",
         mode='full',
         method='clean',
         login=True),
                    patch=(1, 'patch'))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['cvs', '--version']) + 0,
         Expect('stat', dict(file='wkdir/.buildbot-patched',
                             logEnviron=True)) + 0,
         ExpectShell(workdir='wkdir', command=['cvsdiscard']) + 0,
         Expect(
             'uploadFile',
             dict(blocksize=32768,
                  maxsize=None,
                  slavesrc='Root',
                  workdir='wkdir/CVS',
                  writer=ExpectRemoteRef(shell.StringFileWriter))) +
         Expect.behavior(
             uploadString(
                 ':pserver:[email protected]:/cvsroot')) + 0,
         Expect(
             'uploadFile',
             dict(blocksize=32768,
                  maxsize=None,
                  slavesrc='Repository',
                  workdir='wkdir/CVS',
                  writer=ExpectRemoteRef(shell.StringFileWriter))) +
         Expect.behavior(uploadString('mozilla/browser/')) + 0,
         ExpectShell(workdir='wkdir', command=['cvsdiscard']) + 0,
         ExpectShell(workdir='wkdir',
                     command=['cvs', '-z3', 'update', '-dP']) + 0,
         Expect(
             'downloadFile',
             dict(blocksize=16384,
                  maxsize=None,
                  reader=ExpectRemoteRef(_FileReader),
                  slavedest='.buildbot-diff',
                  workdir='wkdir',
                  mode=None)) + 0,
         Expect(
             'downloadFile',
             dict(blocksize=16384,
                  maxsize=None,
                  reader=ExpectRemoteRef(_FileReader),
                  slavedest='.buildbot-patched',
                  workdir='wkdir',
                  mode=None)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'patch', '-p1', '--remove-empty-files', '--force',
                         '--forward', '-i', '.buildbot-diff'
                     ]) + 0,
         Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
                              logEnviron=True)) + 0,
     )
     self.expectOutcome(result=SUCCESS, status_text=["update"])
     self.expectProperty('got_revision', '2012-09-09 12:00:39 +0000', 'CVS')
     return self.runStep()
    def test_mode_incremental_p4base_with_revision(self):
        self.setupStep(
            P4(p4port='localhost:12000',
               mode='incremental',
               p4base='//depot',
               p4branch='trunk',
               p4user='******',
               p4client='p4_client1',
               p4passwd='pass'), dict(revision='100', ))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/... //p4_client1/...
        ''' % root_dir)

        self.expectCommands(
            ExpectShell(
                workdir=
                'wkdir',  # defaults to this, only changes if it has a copy mode.
                command=['p4', '-V'])  # expected remote command
            + 0,  # expected exit status
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-P',
                            'pass', '-c', 'p4_client1', 'client', '-i'
                        ],
                        initialStdin=client_spec) + 0,
            ExpectShell(
                workdir='wkdir',
                command=[
                    'p4', '-p', 'localhost:12000', '-u', 'user', '-P', 'pass',
                    '-c', 'p4_client1', 'sync', '//depot...@100'
                ]) + 0,
            ExpectShell(
                workdir='wkdir',
                command=[
                    'p4', '-p', 'localhost:12000', '-u', 'user', '-P', 'pass',
                    '-c', 'p4_client1', 'changes', '-m1', '#have'
                ]) +
            ExpectShell.log(
                'stdio',
                stdout="Change 100 on 2013/03/21 by user@machine \'duh\'") + 0,
        )
        self.expectOutcome(result=SUCCESS, status_text=["update"])
        self.expectProperty('got_revision', '100', 'P4')
        return self.runStep()
 def test_plain(self):
     self.setupStep(CMake())
     self.expectCommands(
         ExpectShell(command=[CMake.DEFAULT_CMAKE], workdir='wkdir') + 0)
     self.expectOutcome(result=SUCCESS)
     return self.runStep()
    def expect_and_run_command(self, *params):
        command = [CMake.DEFAULT_CMAKE] + list(params)

        self.expectCommands(ExpectShell(command=command, workdir='wkdir') + 0)
        self.expectOutcome(result=SUCCESS)
        return self.runStep()
Esempio n. 14
0
    def test_ticket_auth(self):
        self.setupStep(
            P4(p4port='localhost:12000',
               p4base='//depot',
               p4branch='trunk',
               p4user='******',
               p4client='p4_client1',
               p4passwd='pass',
               use_tickets=True))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/... //p4_client1/...
        ''' % root_dir)

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['p4', '-V']) + 0,

            # This is the extra step that gets run when using tickets,
            # and the password is not passed anymore after that.
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'login'
                        ],
                        initialStdin='pass\n') + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'client', '-i'
                        ],
                        initialStdin=client_spec) + 0,
            ExpectShell(workdir='wkdir',
                        command=([
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'sync'
                        ])) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'changes', '-m1', '#have'
                        ]) +
            ExpectShell.log(
                'stdio',
                stdout="Change 100 on 2013/03/21 by user@machine \'duh\'") + 0,
        )
        self.expectOutcome(result=SUCCESS)
        return self.runStep()
 def test_mode_full_clean_patch(self):
     self.setupStep(
         mercurial.Mercurial(repourl='http://hg.mozilla.org',
                             mode='full', method='clean', branchType='inrepo'),
         patch=(1, 'patch'))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version'])
         + 0,
         Expect('stat', dict(file='wkdir/.buildbot-patched',
                             logEnviron=True))
         + 0,
         Expect('stat', dict(file='wkdir/.hg',
                             logEnviron=True))
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--config',
                              'extensions.purge=', 'purge'])
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'pull',
                              'http://hg.mozilla.org'])
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch'])
         + ExpectShell.log('stdio',
                           stdout='default')
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'locate', 'set:added()'])
         + 1,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'update',
                              '--clean', '--rev', 'default'])
         + 0,
         Expect('downloadFile', dict(blocksize=16384, maxsize=None,
                                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                                     slavedest='.buildbot-diff', workdir='wkdir',
                                     mode=None))
         + 0,
         Expect('downloadFile', dict(blocksize=16384, maxsize=None,
                                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                                     slavedest='.buildbot-patched', workdir='wkdir',
                                     mode=None))
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'import', '--no-commit', '-p', '1', '-'],
                     initialStdin='patch')
         + 0,
         Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
                              logEnviron=True))
         + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'parents',
                              '--template', '{node}\\n'])
         + ExpectShell.log('stdio', stdout='\n')
         + ExpectShell.log('stdio',
                           stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
         + 0,
     )
     self.expectOutcome(result=SUCCESS)
     return self.runStep()
Esempio n. 16
0
 def test_skipped(self):
     command = "rpm -qa | grep -qE '^redhat-release.+'"
     self.setupStep(UnregisterRedhat(doStepIf=isRedhat))
     self.expectCommands(ExpectShell(workdir='/', command=command) + 1)
     self.expectOutcome(result=SKIPPED)
     return self.runStep()
Esempio n. 17
0
 def test_mode_full_clean_patch_fail(self):
     self.setupStep(mercurial.Mercurial(repourl='http://hg.mozilla.org',
                                        mode='full',
                                        method='clean',
                                        branchType='inrepo'),
                    patch=(1, 'patch'))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', '--version']) + 0,
         Expect('stat', dict(file='wkdir/.buildbot-patched',
                             logEnviron=True)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', '--config', 'extensions.purge=',
                         'purge'
                     ]) + 0,
         Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', '--config', 'extensions.purge=',
                         'purge'
                     ]) + 0,
         ExpectShell(
             workdir='wkdir',
             command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org']) +
         0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'identify', '--branch']) +
         ExpectShell.log('stdio', stdout='default') + 0,
         ExpectShell(workdir='wkdir',
                     command=['hg', '--verbose', 'locate', 'set:added()']) +
         1,
         ExpectShell(workdir='wkdir',
                     command=[
                         'hg', '--verbose', 'update', '--clean', '--rev',
                         'default'
                     ]) + 0,
         Expect(
             'downloadFile',
             dict(blocksize=16384,
                  maxsize=None,
                  reader=ExpectRemoteRef(_FileReader),
                  slavedest='.buildbot-diff',
                  workdir='wkdir',
                  mode=None)) + 0,
         Expect(
             'downloadFile',
             dict(blocksize=16384,
                  maxsize=None,
                  reader=ExpectRemoteRef(_FileReader),
                  slavedest='.buildbot-patched',
                  workdir='wkdir',
                  mode=None)) + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'patch', '-p1', '--remove-empty-files', '--force',
                         '--forward', '-i', '.buildbot-diff'
                     ]) + 1,
     )
     self.expectOutcome(result=FAILURE, status_text=["updating"])
     return self.runStep()
Esempio n. 18
0
 def test_success(self):
     self.setupStep(python.PyFlakes())
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['make', 'pyflakes']) + 0)
     self.expectOutcome(result=SUCCESS, state_string='pyflakes')
     return self.runStep()
Esempio n. 19
0
    def test_download_artifact_fromchildren_reusing_artifacts(self):
        # In this test we expect DownloadArtifactsFromChildren to download artifacts from following build request ids:
        # '2' because `artifactbrid` is null which means that build request contains artifacts on itself
        # '666' - because build request '3' reused it
        # The test data also include and build request '4', referring '666'.
        # The test also checks that it will not be downloaded.
        # We don't want to download the same artifact more than once
        br2 = fakedb.BuildRequest(id=2,
                                  buildsetid=2,
                                  buildername="B",
                                  triggeredbybrid=1,
                                  artifactbrid=None)
        br3 = fakedb.BuildRequest(id=3,
                                  buildsetid=3,
                                  buildername="B",
                                  triggeredbybrid=1,
                                  artifactbrid=666)
        br4 = fakedb.BuildRequest(id=4,
                                  buildsetid=4,
                                  buildername="B",
                                  triggeredbybrid=1,
                                  artifactbrid=666)
        br666 = fakedb.BuildRequest(id=666,
                                    buildsetid=5,
                                    buildername="B",
                                    triggeredbybrid=None)

        self.setupStep(
            artifact.DownloadArtifactsFromChildren(
                workdir='build',
                artifactServer='*****@*****.**',
                artifactServerDir='/artifacts',
                artifactServerPort=22,
                artifactDirectory='mydir',
                artifactBuilderName='B',
                artifactDestination='./base/local',
            ), [br2, br3, br4, br666])

        expectedRemote1 = '\'[email protected]:/artifacts/B/2_01_01_1970_00_00_00_+0000/mydir/\''
        expectedRemote2 = '\'[email protected]:/artifacts/B/666_01_01_1970_00_00_00_+0000/mydir/\''

        expectedLocal1 = './base/local/2'
        expectedLocal2 = './base/local/666'

        self.expectCommands(
            ExpectShell(workdir='build',
                        usePTY='slave-config',
                        command=['mkdir', '-p', expectedLocal1]) + 0,
            ExpectShell(
                workdir='build',
                usePTY='slave-config',
                command='for i in 1 2 3 4 5; do rsync -var --progress --partial '
                + expectedRemote1 + " '" + expectedLocal1 + "'"
                ' --rsh=\'ssh -p 22\'; if [ $? -eq 0 ]; then exit 0; else sleep 5; fi; done; exit -1'
            ) + 0,
            ExpectShell(workdir='build',
                        usePTY='slave-config',
                        command=['mkdir', '-p', expectedLocal2]) + 0,
            ExpectShell(
                workdir='build',
                usePTY='slave-config',
                command='for i in 1 2 3 4 5; do rsync -var --progress --partial '
                + expectedRemote2 + " '" + expectedLocal2 + "'" +
                ' --rsh=\'ssh -p 22\'; if [ $? -eq 0 ]; then exit 0; else sleep 5; fi; done; exit -1'
            ) + 0 + ExpectShell.log('stdio', stdout=''))

        self.expectOutcome(
            result=SUCCESS,
            status_text=['Downloaded artifacts from 2 partitions'])
        return self.runStep()
Esempio n. 20
0
 def test_empty(self):
     self.setupStep(subunit.SubunitShellCommand(command='test'))
     self.expectCommands(ExpectShell(workdir='wkdir', command="test") + 0)
     self.expectOutcome(result=SUCCESS, state_string="shell no tests run")
     return self.runStep()
Esempio n. 21
0
    def test_mode_full_clean_patch_fail(self):
        self.setupStep(mtn.Monotone(repourl='mtn://localhost/monotone',
                                    mode='full',
                                    method='clean',
                                    branch='master'),
                       patch=(1, 'patch'))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['mtn', '--version']) +
            ExpectShell.log(
                'stdio',
                stdout=
                'monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)'
            ) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'db', 'info', '--db', '../db.mtn']) +
            ExpectShell.log('stdio', stdout='') + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0,
            Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) +
            ExpectShell.log('stdio', stdout='file1\nfile2') + 0,
            Expect('rmdir',
                   dict(dir=['wkdir/file1', 'wkdir/file2'], logEnviron=True)) +
            0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db=../db.mtn', '--ticker=dot'
                        ]) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'update', '--db=../db.mtn', '-r',
                            'h:master', '-b', 'master'
                        ]) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                     slavedest='.buildbot-diff',
                     workdir='wkdir',
                     mode=None)) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                     slavedest='.buildbot-patched',
                     workdir='wkdir',
                     mode=None)) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'patch', '-p1', '--remove-empty-files', '--force',
                            '--forward', '-i', '.buildbot-diff'
                        ]) + 0,
            Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
                                 logEnviron=True)) + 1,
        )
        self.expectOutcome(result=FAILURE, state_string="update (failure)")
        return self.runStep()
Esempio n. 22
0
 async def test_echo(self):
     self.setupStep(ShellCommand(command=['echo', '1'], workdir='build'))
     self.expectCommands(
         ExpectShell(workdir='build', command=['echo', '1']) + 0)
     self.expectOutcome(result=SUCCESS)
     return await self.runStep()
Esempio n. 23
0
    def test_mode_full_clean_patch(self):
        self.setupStep(mtn.Monotone(repourl='mtn://localhost/monotone',
                                    mode='full',
                                    method='clean',
                                    branch='master'),
                       patch=(1, 'patch'))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['mtn', '--version']) +
            ExpectShell.log('stdio', stdout=self.MTN_VER) + 0,
            Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0,
            ExpectShell(workdir='.',
                        command=['mtn', 'db', 'info', '--db', 'db.mtn']) +
            ExpectShell.log('stdio', stdout='') + 0,
            ExpectShell(workdir='.',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db', 'db.mtn', '--ticker=dot'
                        ]) + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) +
            ExpectShell.log('stdio', stdout='file1\nfile2') + 0,
            Expect('rmdir',
                   dict(dir=['wkdir/file1', 'wkdir/file2'], logEnviron=True)) +
            0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'update', '--revision', 'h:master',
                            '--branch', 'master'
                        ]) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                     workerdest='.buildbot-diff',
                     workdir='wkdir',
                     mode=None)) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(remotetransfer.StringFileReader),
                     workerdest='.buildbot-patched',
                     workdir='wkdir',
                     mode=None)) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'patch', '-p1', '--remove-empty-files', '--force',
                            '--forward', '-i', '.buildbot-diff'
                        ]) + 0,
            Expect('rmdir', dict(dir='wkdir/.buildbot-diff',
                                 logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'automate', 'select', 'w:']) +
            ExpectShell.log('stdio', stdout=self.REVID) + 0,
        )
        self.expectOutcome(result=SUCCESS)
        self.expectProperty('got_revision', self.REVID, 'Monotone')
        return self.runStep()
Esempio n. 24
0
 def ExpectShell(self, **kw):
     if not kw.has_key('workdir'):
         kw['workdir'] = 'wkdir'
     if not kw.has_key('logEnviron'):
         kw['logEnviron'] = self.shouldLogEnviron()
     return ExpectShell(**kw)
Esempio n. 25
0
 def ExpectShell(self, **kw):
     if 'workdir' not in kw:
         kw['workdir'] = 'wkdir'
     if 'logEnviron' not in kw:
         kw['logEnviron'] = self.shouldLogEnviron()
     return ExpectShell(**kw)
Esempio n. 26
0
    def test_mode_full_clean_patch(self):
        self.setupStep(mtn.Monotone(repourl='mtn://localhost/monotone',
                                    mode='full',
                                    method='clean',
                                    branch='master'),
                       patch=(1, 'patch'))

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['mtn', '--version']) +
            ExpectShell.log(
                'stdio',
                stdout=
                'monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)'
            ) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'db', 'info', '--db', '../db.mtn']) +
            ExpectShell.log('stdio', stdout='') + 0,
            Expect('stat', dict(file='wkdir/.buildbot-patched',
                                logEnviron=True)) + 1,
            Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0,
            Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0,
            ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) +
            ExpectShell.log('stdio', stdout='file1\nfile2') + 0,
            Expect(
                'rmdir',
                dict(dir=['wkdir/file1', 'wkdir/file2'],
                     logEnviron=True,
                     timeout=1200)) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'pull', 'mtn://localhost/monotone?master',
                            '--db=../db.mtn', '--ticker=dot'
                        ]) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'mtn', 'update', '--db=../db.mtn', '-r',
                            'h:master', '-b', 'master'
                        ]) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(_FileReader),
                     slavedest='.buildbot-diff',
                     workdir='wkdir',
                     mode=None)) + 0,
            Expect(
                'downloadFile',
                dict(blocksize=16384,
                     maxsize=None,
                     reader=ExpectRemoteRef(_FileReader),
                     slavedest='.buildbot-patched',
                     workdir='wkdir',
                     mode=None)) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'patch', '-p1', '--remove-empty-files', '--force',
                            '--forward', '-i', '.buildbot-diff'
                        ]) + 0,
            Expect(
                'rmdir',
                dict(dir='wkdir/.buildbot-diff', logEnviron=True,
                     timeout=1200)) + 0,
            ExpectShell(workdir='wkdir',
                        command=['mtn', 'automate', 'select', 'w:']) +
            ExpectShell.log(
                'stdio', stdout='95215e2a9a9f8b6f5c9664e3807cd34617ea928c') +
            0,
        )
        self.expectOutcome(result=SUCCESS, status_text=["update"])
        self.expectProperty('got_revision',
                            '95215e2a9a9f8b6f5c9664e3807cd34617ea928c',
                            'Monotone')
        return self.runStep()