def testBasic(self): self.setup_step( DownloadSecretsToWorker([ (os.path.join(self.temp_path, "pathA"), "something"), (os.path.join(self.temp_path, "pathB"), "something more") ])) self.expect_commands( ExpectDownloadFile( maxsize=None, mode=stat.S_IRUSR | stat.S_IWUSR, reader=ExpectRemoteRef(remotetransfer.StringFileReader), blocksize=32 * 1024, workerdest=os.path.join(self.temp_path, "pathA"), workdir="wkdir").exit(0), ExpectDownloadFile( maxsize=None, mode=stat.S_IRUSR | stat.S_IWUSR, reader=ExpectRemoteRef(remotetransfer.StringFileReader), blocksize=32 * 1024, workerdest=os.path.join(self.temp_path, "pathB"), workdir="wkdir").exit(0), ) self.expect_outcome(result=SUCCESS, state_string="finished") d = self.run_step() return d
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_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 testBasicWorker2_16(self): master_file = __file__ self.setup_step(transfer.FileDownload(mastersrc=master_file, workerdest=self.destfile), worker_version={'*': '2.16'}) # A place to store what gets read read = [] self.expect_commands( ExpectDownloadFile(slavedest=self.destfile, workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.FileReader)).download_string( read.append, size=1000).exit(0)) self.expect_outcome(result=SUCCESS, state_string="downloading to {0}".format( os.path.basename(self.destfile))) yield self.run_step() def checkCalls(res): with open(master_file, "rb") as f: contents = f.read() contents = contents[:1000] self.assertEqual(b''.join(read), contents)
def testBasic(self): self.setup_step(transfer.JSONPropertiesDownload("props.json")) self.step.build.setProperty('key1', 'value1', 'test') read = [] self.expect_commands( ExpectDownloadFile( workerdest="props.json", workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader)).download_string( read.append).exit(0)) self.expect_outcome(result=SUCCESS, state_string="downloading to props.json") yield self.run_step() # we decode as key order is dependent of python version self.assertEqual(json.loads((b''.join(read)).decode()), { "properties": { "key1": "value1" }, "sourcestamps": [] })
def test_basic_with_renderable(self): msg = dict(message=Interpolate("Hello World")) self.setup_step(transfer.JSONStringDownload(msg, "hello.json")) self.step.worker = Mock() self.step.remote = Mock() # A place to store what gets read read = [] self.expect_commands( ExpectDownloadFile( workerdest="hello.json", workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader)).download_string( read.append).exit(0)) self.expect_outcome(result=SUCCESS, state_string="downloading to hello.json") yield self.run_step() self.assertEqual(b''.join(read), b'{"message": "Hello World"}')
def testBasicWorker2_16(self): self.setup_step(transfer.StringDownload("Hello World", "hello.txt"), worker_version={'*': '2.16'}) self.step.worker = Mock() self.step.remote = Mock() # A place to store what gets read read = [] self.expect_commands( ExpectDownloadFile( slavedest="hello.txt", workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader)).download_string( read.append).exit(0)) self.expect_outcome(result=SUCCESS, state_string="downloading to hello.txt") yield self.run_step() self.assertEqual(b''.join(read), b"Hello World")
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_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 testFailure(self): self.setup_step(transfer.StringDownload("Hello World", "hello.txt")) self.expect_commands( ExpectDownloadFile(workerdest="hello.txt", workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.StringFileReader)).exit(1)) self.expect_outcome(result=FAILURE, state_string="downloading to hello.txt (failure)") return self.run_step()
def test_downloadFileContentToWorker(self): @defer.inlineCallbacks def testFunc(x): res = yield x.downloadFileContentToWorker("/path/dest1", "file text") self.assertEqual(res, None) self.setup_step(CompositeUser(testFunc)) self.expect_commands( ExpectDownloadFile(maxsize=None, workdir='wkdir', mode=None, reader=ExpectRemoteRef( remotetransfer.FileReader), blocksize=32768, workerdest='/path/dest1')) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_mode_full_clean_patch_worker_2_16(self): self.setup_step(mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='clean', branchType='inrepo'), patch=(1, 'patch'), worker_version={'*': '2.16'}) 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), 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=[ 'hg', '--verbose', 'import', '--no-commit', '-p', '1', '-' ], initial_stdin='patch').exit(0), ExpectRmdir(dir='wkdir/.buildbot-diff', 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()