def test_mode_incremental_branch_change_dirname(self): self.setup_step( mercurial.Mercurial(repourl='http://hg.mozilla.org/', mode='incremental', branchType='dirname', defaultBranch='devel'), dict(branch='stable')) self.expect_commands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/.hg', log_environ=True).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'pull', 'http://hg.mozilla.org/stable' ]).exit(0), ExpectRmdir(dir='wkdir', log_environ=True).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org/stable', '.' ]).exit(0), ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']).exit(0), ExpectShell( workdir='wkdir', command=[ 'hg', '--verbose', 'parents', '--template', '{node}\\n' ]).stdout('\n').stdout( 'f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
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
def test_mode_full_fresh_no_existing_repo(self): self.setup_step( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='fresh', branchType='inrepo')) self.expect_commands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/.hg', log_environ=True).exit(1), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'update', '--clean', '--rev', 'default' ], log_environ=True).exit(0), ExpectShell( workdir='wkdir', command=[ 'hg', '--verbose', 'parents', '--template', '{node}\\n' ]).stdout('\n').stdout( 'f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_mode_incremental_no_existing_repo_dirname(self): self.setup_step( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='incremental', branchType='dirname'), ) self.expect_commands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/.hg', log_environ=True).exit(1), # does not exist ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.' ]).exit(0), ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'locate', 'set:added()']).exit(1), ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']).exit(0), ExpectShell( workdir='wkdir', command=[ 'hg', '--verbose', 'parents', '--template', '{node}\\n' ]).stdout('\n').stdout( 'f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_mode_full_copy(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='copy')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectRmdir(dir='build', log_environ=True) .exit(0), ExpectStat(file='source/.bzr', log_environ=True) .exit(0), ExpectShell(workdir='source', command=['bzr', 'update']) .exit(0), ExpectCpdir(fromdir='source', log_environ=True, todir='build') .exit(0), ExpectShell(workdir='source', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100', 'Bzr') return self.run_step()
def test_mode_full_win32path(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='fresh')) self.build.path_module = namedModule('ntpath') self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file=r'wkdir\.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file=r'wkdir\.bzr', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'clean-tree', '--force']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'update']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100') .exit(0) ) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_mode_incremental_retry(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='incremental', retry=(0, 1))) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/.bzr', log_environ=True) .exit(1), ExpectShell(workdir='wkdir', command=['bzr', 'checkout', 'http://bzr.squid-cache.org/bzr/squid3/trunk', '.']) .exit(1), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'checkout', 'http://bzr.squid-cache.org/bzr/squid3/trunk', '.']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100\n') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100\n', 'Bzr') return self.run_step()
def test_mode_full_clean_revision(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='clean'), args=dict(revision='2345')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/.bzr', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'clean-tree', '--ignored', '--force']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'update', '-r', '2345']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100', 'Bzr') return self.run_step()
def test_mode_full_copy(self): self.setup_step( darcs.Darcs(repourl='http://localhost/darcs', mode='full', method='copy')) self.expect_commands( ExpectShell(workdir='wkdir', command=['darcs', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectRmdir(dir='wkdir', log_environ=True, timeout=1200).exit(0), ExpectStat(file='source/_darcs', log_environ=True).exit(0), ExpectShell(workdir='source', command=['darcs', 'pull', '--all', '--verbose']).exit(0), ExpectCpdir(fromdir='source', todir='build', log_environ=True, timeout=1200).exit(0), ExpectShell( workdir='build', command=['darcs', 'changes', '--max-count=1']).stdout( 'Tue Aug 20 09:18:41 IST 2013 [email protected]').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', 'Tue Aug 20 09:18:41 IST 2013 [email protected]', 'Darcs') return self.run_step()
def test_mode_full_clean_patch_worker_2_16(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='clean', branch='master'), patch=(1, 'patch'), worker_version={'*': '2.16'}) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) .stdout('') .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) .stdout('file1\nfile2') .exit(0), ExpectRmdir(dir=['wkdir/file1', 'wkdir/file2'], log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'update', '--revision', 'h:master', '--branch', 'master']) .exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef(remotetransfer.StringFileReader), slavedest='.buildbot-diff', workdir='wkdir', mode=None) .exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef(remotetransfer.StringFileReader), slavedest='.buildbot-patched', workdir='wkdir', mode=None) .exit(0), ExpectShell(workdir='wkdir', command=['patch', '-p1', '--remove-empty-files', '--force', '--forward', '-i', '.buildbot-diff']) .exit(0), ExpectRmdir(dir='wkdir/.buildbot-diff', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) .stdout(self.REVID) .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_mode_full_clean_patch_fail(self): self.setup_step(mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='clean', branchType='inrepo'), patch=(1, 'patch')) self.expect_commands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(0), ExpectStat(file='wkdir/.hg', log_environ=True).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', '--config', 'extensions.purge=', 'purge' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'pull', 'http://hg.mozilla.org', '--rev', 'default' ]).exit(0), ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']).stdout('default').exit(0), ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'locate', 'set:added()']).exit(1), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'update', '--clean', '--rev', 'default' ]).exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader), workerdest='.buildbot-diff', workdir='wkdir', mode=None).exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader), workerdest='.buildbot-patched', workdir='wkdir', mode=None).exit(0), ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'import', '--no-commit', '-p', '1', '-' ], initial_stdin='patch').exit(1)) self.expect_outcome(result=FAILURE, state_string="update (failure)") return self.run_step()
def test_mode_full_clean_timeout(self): self.setup_step( mercurial.Mercurial(repourl='http://hg.mozilla.org', timeout=1, mode='full', method='clean', branchType='inrepo')) self.expect_commands( ExpectShell(workdir='wkdir', timeout=1, command=['hg', '--verbose', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/.hg', log_environ=True).exit(0), ExpectShell(workdir='wkdir', timeout=1, command=[ 'hg', '--verbose', '--config', 'extensions.purge=', 'purge' ]).exit(0), ExpectShell(workdir='wkdir', timeout=1, command=[ 'hg', '--verbose', 'pull', 'http://hg.mozilla.org', '--rev', 'default' ]).exit(0), ExpectShell(workdir='wkdir', timeout=1, command=['hg', '--verbose', 'identify', '--branch']).stdout('default').exit(0), ExpectShell(workdir='wkdir', timeout=1, command=['hg', '--verbose', 'locate', 'set:added()']).exit(1), ExpectShell(workdir='wkdir', timeout=1, command=[ 'hg', '--verbose', 'update', '--clean', '--rev', 'default' ]).exit(0), ExpectShell( workdir='wkdir', timeout=1, command=[ 'hg', '--verbose', 'parents', '--template', '{node}\\n' ]).stdout('\n').stdout( 'f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_mode_full_fresh(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='fresh', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) .stdout('') .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'unknown']) .stdout('file1\nfile2') .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'ls', 'ignored']) .stdout('file3\nfile4') .exit(0), ExpectRmdir(dir=['wkdir/file1', 'wkdir/file2', 'wkdir/file3', 'wkdir/file4'], log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'update', '--revision', 'h:master', '--branch', 'master']) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) .stdout(self.REVID) .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_mode_full_clobber_baseurl_nodefault(self): self.setup_step( bzr.Bzr(baseURL='http://bzr.squid-cache.org/bzr/squid3', defaultBranch='trunk', mode='full', method='clobber'), args=dict(branch='branches/SQUID_3_0')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'checkout', os.path.join('http://bzr.squid-cache.org/bzr/squid3', 'branches/SQUID_3_0'), '.']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100', 'Bzr') return self.run_step()
def test_url_text(self): self.setup_step( transfer.MultipleFileUpload(workersrcs=["srcfile"], masterdest=self.destdir, url="http://server/dir", urlText='url text')) self.step.addURL = Mock() 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)) self.expect_outcome(result=SUCCESS, state_string="uploading 1 file") yield self.run_step() self.step.addURL.assert_called_once_with("url text", "http://server/dir")
def test_with_head_branch(self): self.setup_step( self.stepClass(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='clean'), dict(branch='refs/pull/1234/head', revision='12345678')) self.expect_commands( ExpectShell(workdir='wkdir', command=['git', '--version' ]).stdout('git version 1.7.5').exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectListdir(dir='wkdir').files(['.git']).exit(0), ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']).exit(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']).exit(0), ExpectShell(workdir='wkdir', command=['git', 'checkout', '-f', '12345678']).exit(0), ExpectShell( workdir='wkdir', command=['git', 'checkout', '-B', 'refs/pull/1234/head']).exit(0), ExpectShell(workdir='wkdir', command=[ 'git', 'rev-parse', 'HEAD' ]).stdout('f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'GitHub') return self.run_step()
def testException(self): self.setup_step( transfer.MultipleFileUpload(workersrcs=["srcfile", "srcdir"], masterdest=self.destdir)) writers = [] 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", out_writers=writers, error=RuntimeError('uh oh'))) self.expect_outcome(result=EXCEPTION, state_string="uploading 2 files (exception)") yield self.run_step() self.assertEqual(len(writers), 1) self.assertEqual(writers[0].cancel.called, True) self.assertEqual(len(self.flushLoggedErrors(RuntimeError)), 1)
def expectClobber(self): # stat return 1 so we clobber self.expect_commands( ExpectStat(file='wkdir/.repo', log_environ=self.logEnviron).exit(1), ExpectRmdir(dir='wkdir', log_environ=self.logEnviron).exit(0), ExpectMkdir(dir='wkdir', log_environ=self.logEnviron).exit(0))
def test_manifest_override(self): """repo sync with manifest_override_url property set download via wget """ self.mySetupStep(manifestOverrideUrl="http://u.rl/test.manifest", syncAllBranches=True) self.expectClobber() override_commands = [ ExpectStat(file='wkdir/http://u.rl/test.manifest', log_environ=False), self.ExpectShell(log_environ=False, command=[ 'wget', 'http://u.rl/test.manifest', '-O', 'manifest_override.xml' ]), self.ExpectShell(log_environ=False, workdir='wkdir/.repo', command=[ 'ln', '-sf', '../manifest_override.xml', 'manifest.xml' ]) ] self.expectRepoSync(which_fail=2, syncoptions=[], override_commands=override_commands) return self.myRunStep()
def test_mode_full_clean_different_project(self): self.setup_step( gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='clean', codebase='buildbot')) self.build.setProperty("event.change.project", "buildbot") self.sourcestamp.project = 'not_buildbot' self.build.setProperty("gerrit_change", "1234/567") self.expect_commands( ExpectShell(workdir='wkdir', command=['git', '--version' ]).stdout('git version 1.7.5').exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectListdir(dir='wkdir').files(['.git']).exit(0), ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']).exit(0), ExpectShell(workdir='wkdir', command=[ 'git', 'fetch', '-f', '-t', 'http://github.com/buildbot/buildbot.git', 'HEAD', '--progress' ]).exit(0), ExpectShell(workdir='wkdir', command=['git', 'checkout', '-f', 'FETCH_HEAD']).exit(0), ExpectShell(workdir='wkdir', command=[ 'git', 'rev-parse', 'HEAD' ]).stdout('f6ad368298bd941e934a41f3babc827b2aa95a1d').exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_render(self): self.setup_step(worker.FileExists(file=properties.Property("x"))) self.properties.setProperty('x', 'XXX', 'here') self.expect_commands(ExpectStat(file='XXX').exit(1)) self.expect_outcome(result=FAILURE, state_string="File not found. (failure)") return self.run_step()
def test_mode_full_clobber_revision_worker_2_16(self): self.setup_step(darcs.Darcs(repourl='http://localhost/darcs', mode='full', method='clobber'), dict(revision='abcdef01'), worker_version={'*': '2.16'}) self.expect_commands( ExpectShell(workdir='wkdir', command=['darcs', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectRmdir(dir='wkdir', log_environ=True).exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader), slavedest='.darcs-context', workdir='wkdir', mode=None).exit(0), ExpectShell(workdir='.', command=[ 'darcs', 'get', '--verbose', '--lazy', '--repo-name', 'wkdir', '--context', '.darcs-context', 'http://localhost/darcs' ]).exit(0), ExpectShell( workdir='wkdir', command=['darcs', 'changes', '--max-count=1']).stdout( 'Tue Aug 20 09:18:41 IST 2013 [email protected]').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', 'Tue Aug 20 09:18:41 IST 2013 [email protected]', 'Darcs') return self.run_step()
def test_mode_full_clobber_no_existing_db(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='clobber', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(1), ExpectShell(workdir='.', command=['mtn', 'db', 'init', '--db', 'db.mtn']) .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'checkout', 'wkdir', '--db', 'db.mtn', '--branch', 'master']) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) .stdout(self.REVID) .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
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() 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), {}))
def test_mode_incremental_patch(self): self.setup_step(darcs.Darcs(repourl='http://localhost/darcs', mode='incremental'), patch=(1, 'patch')) self.expect_commands( ExpectShell(workdir='wkdir', command=['darcs', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/_darcs', log_environ=True).exit(0), ExpectShell(workdir='wkdir', command=['darcs', 'pull', '--all', '--verbose']).exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader), workerdest='.buildbot-diff', workdir='wkdir', mode=None).exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader), workerdest='.buildbot-patched', workdir='wkdir', mode=None).exit(0), ExpectShell(workdir='wkdir', command=[ 'patch', '-p1', '--remove-empty-files', '--force', '--forward', '-i', '.buildbot-diff' ]).exit(0), ExpectRmdir(dir='wkdir/.buildbot-diff', log_environ=True).exit(0), ExpectShell( workdir='wkdir', command=['darcs', 'changes', '--max-count=1']).stdout( 'Tue Aug 20 09:18:41 IST 2013 [email protected]').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', 'Tue Aug 20 09:18:41 IST 2013 [email protected]', 'Darcs') return self.run_step()
def test_database_too_new(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) .stdout('too new, cannot use') .exit(0), ExpectRmdir(dir='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'init', '--db', 'db.mtn']) .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'update', '--revision', 'h:master', '--branch', 'master']) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) .stdout(self.REVID) .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_bad_checkout(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='incremental')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/.bzr', log_environ=True) .exit(1), ExpectShell(workdir='wkdir', command=['bzr', 'checkout', 'http://bzr.squid-cache.org/bzr/squid3/trunk', '.']) .stderr('failed\n') .exit(128) ) self.expect_outcome(result=FAILURE) return self.run_step()
def test_mode_full_clean_patch_worker_2_16(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='clean'), patch=(1, 'patch'), worker_version={'*': '2.16'}) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/.bzr', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'clean-tree', '--ignored', '--force']) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'update']) .exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef(remotetransfer.FileReader), slavedest='.buildbot-diff', workdir='wkdir', mode=None) .exit(0), ExpectDownloadFile(blocksize=32768, maxsize=None, reader=ExpectRemoteRef(remotetransfer.FileReader), slavedest='.buildbot-patched', workdir='wkdir', mode=None) .exit(0), ExpectShell(workdir='wkdir', command=['patch', '-p1', '--remove-empty-files', '--force', '--forward', '-i', '.buildbot-diff']) .exit(0), ExpectRmdir(dir='wkdir/.buildbot-diff', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) .stdout('100') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100', 'Bzr') return self.run_step()
def test_mode_full_no_method(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) .stdout('') .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectRmdir(dir='wkdir', log_environ=True, timeout=1200) .exit(0), ExpectStat(file='source/_MTN', log_environ=True) .exit(0), ExpectShell(workdir='source', command=['mtn', 'update', '--revision', 'h:master', '--branch', 'master']) .exit(0), ExpectCpdir(fromdir='source', todir='build', log_environ=True, timeout=1200) .exit(0), ExpectShell(workdir='build', command=['mtn', 'automate', 'select', 'w:']) .stdout(self.REVID) .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_mode_incremental_given_revision(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master'), dict(revision='abcdef01',)) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) .stdout(self.MTN_VER) .exit(0), ExpectStat(file='db.mtn', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) .stdout('') .exit(0), ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'update', '--revision', 'abcdef01', '--branch', 'master']) .exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) .stdout('abcdef019a9f8b6f5c9664e3807cd34617ea928c') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property( 'got_revision', 'abcdef019a9f8b6f5c9664e3807cd34617ea928c', 'Monotone') return self.run_step()