def testShellArgsAreRenderedAnewAtEachBuild(self):
        """Unit test to ensure that ShellArg instances are properly re-rendered.

        This unit test makes sure that ShellArg instances are rendered anew at
        each new build.
        """
        arg = shellsequence.ShellArg(command=WithProperties('make %s', 'project'),
                                     logfile=WithProperties('make %s', 'project'))
        step = shellsequence.ShellSequence(commands=[arg], workdir='build')

        # First "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-1", "TEST")
        self.expectCommands(ExpectShell(workdir='build',
                            command='make BUILDBOT-TEST-1') + 0 +
                            Expect.log('stdio make BUILDBOT-TEST-1'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-1'")
        self.runStep()

        # Second "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-2", "TEST")
        self.expectCommands(ExpectShell(workdir='build',
                            command='make BUILDBOT-TEST-2') + 0 +
                            Expect.log('stdio make BUILDBOT-TEST-2'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-2'")

        return self.runStep()
Esempio n. 2
0
    def testShellArgsAreRenderedAnewAtEachBuild(self):
        """Unit test to ensure that ShellArg instances are properly re-rendered.

        This unit test makes sure that ShellArg instances are rendered anew at
        each new build.
        """
        arg = shellsequence.ShellArg(
            command=WithProperties('make %s', 'project'),
            logfile=WithProperties('make %s', 'project'))
        step = shellsequence.ShellSequence(commands=[arg], workdir='build')

        # First "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-1", "TEST")
        self.expectCommands(
            ExpectShell(workdir='build', command='make BUILDBOT-TEST-1') + 0 +
            Expect.log('stdio make BUILDBOT-TEST-1'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-1'")
        self.runStep()

        # Second "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-2", "TEST")
        self.expectCommands(
            ExpectShell(workdir='build', command='make BUILDBOT-TEST-2') + 0 +
            Expect.log('stdio make BUILDBOT-TEST-2'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-2'")

        return self.runStep()
Esempio n. 3
0
 def test_update_tarball_fail1(self, suffix="tar", option=[]):
     """tarball extract fail -> remove the tarball + remove .repo dir
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(
             command=[
                 'tar'] + option + ['-xvf', '/tarball.' + suffix]) + 1,
         self.ExpectShell(
             command=['rm', '-f', '/tarball.tar']) + 0,
         Expect(
             'rmdir', dict(dir='wkdir/.repo',
                           logEnviron=False))
         + 0)
     self.expectRepoSync()
     self.expectCommands(self.ExpectShell(command=['stat', '-c%Y', '/tarball.' + suffix])
                         + Expect.log('stdio', stdout=str(10000))
                         + 0,
                         self.ExpectShell(command=['stat', '-c%Y', '.'])
                         + Expect.log(
                             'stdio', stdout=str(10001 + 7 * 24 * 3600))
                         + 0,
                         self.ExpectShell(command=['tar'] + option +
                                          ['-cvf', '/tarball.' + suffix, '.repo'])
                         + 0)
     return self.myRunStep()
Esempio n. 4
0
 def test_update_tarball_fail2(self, suffix="tar", option=[]):
     """tarball update fail -> remove the tarball + continue repo download
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(command=['tar'] + option + ['-xvf', '/tarball.' + suffix]) + 0)
     self.expectRepoSync()
     self.expectCommands(self.ExpectShell(command=['stat', '-c%Y', '/tarball.' + suffix])
                         + Expect.log('stdio', stdout=str(10000))
                         + 0,
                         self.ExpectShell(command=['stat', '-c%Y', '.'])
                         + Expect.log(
                             'stdio', stdout=str(10001 + 7 * 24 * 3600))
                         + 0,
                         self.ExpectShell(command=['tar'] + option +
                                          ['-cvf', '/tarball.' + suffix, '.repo'])
                         + 1,
                         self.ExpectShell(
                             command=['rm', '-f', '/tarball.tar']) + 0,
                         self.ExpectShell(
                             command=['repo', 'download', 'test/bla', '564/12'])
                         + 0)
     return self.myRunStep()
Esempio n. 5
0
 def test_repo_downloads_from_change_source_codebase(self):
     """basic repo download from change source, and check that repo_downloaded is updated"""
     self.mySetupStep(
         repoDownloads=repo.RepoDownloadsFromChangeSource("mycodebase"))
     change = Change(None, None, None, properties={
         'event.change.owner.email': '*****@*****.**',
         'event.change.subject': 'fix 1234',
         'event.change.project': 'pr',
         'event.change.owner.name': 'Dustin',
         'event.change.number': '4321',
         'event.change.url': 'http://buildbot.net',
         'event.change.branch': 'br',
         'event.type': 'patchset-created',
         'event.patchSet.revision': 'abcdef',
         'event.patchSet.number': '12',
         'event.source': 'GerritChangeSource'
     })
     # getSourceStamp is faked by SourceStepMixin
     ss = self.build.getSourceStamp("")
     ss.changes = [change]
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=['repo', 'download', 'pr', '4321/12'])
         + 0
         + Expect.log(
             'stdio', stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log('stdio', stderr="HEAD is now at 0123456789abcdef...\n"))
     self.expectProperty(
         "repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep()
Esempio n. 6
0
    def test_complex_diff(self):
        self.setupStep(gitdiffinfo.GitDiffInfo())
        self.expectCommands(
            ExpectShell(workdir='wkdir',
                        command=['git', 'merge-base', 'HEAD', 'master']) +
            Expect.log('stdio-merge-base', stdout='1234123412341234') + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'git', 'diff', '--no-prefix', '-U0',
                            '1234123412341234', 'HEAD'
                        ]) + Expect.log('stdio-diff',
                                        stdout='''\
diff --git file1 file1
deleted file mode 100644
index 42f90fd..0000000
--- file1
+++ /dev/null
@@ -1,3 +0,0 @@
-line11
-line12
-line13
diff --git file2 file2
index c337bf1..1cb02b9 100644
--- file2
+++ file2
@@ -4,0 +5,3 @@ line24
+line24n
+line24n2
+line24n3
@@ -15,0 +19,3 @@ line215
+line215n
+line215n2
+line215n3
diff --git file3 file3
new file mode 100644
index 0000000..632e269
--- /dev/null
+++ file3
@@ -0,0 +1,3 @@
+line31
+line32
+line33
''') + 0,
        )
        self.expectLogfile('stdio-merge-base', '1234123412341234')
        self.expectOutcome(result=results.SUCCESS, state_string="GitDiffInfo")

        diff_info = (b'[{"source_file": "file1", "target_file": "/dev/null", '
                     + b'"is_binary": false, "is_rename": false, ' +
                     b'"hunks": [{"ss": 1, "sl": 3, "ts": 0, "tl": 0}]}, ' +
                     b'{"source_file": "file2", "target_file": "file2", ' +
                     b'"is_binary": false, "is_rename": false, ' +
                     b'"hunks": [{"ss": 4, "sl": 0, "ts": 5, "tl": 3}, ' +
                     b'{"ss": 15, "sl": 0, "ts": 19, "tl": 3}]}, ' +
                     b'{"source_file": "/dev/null", "target_file": "file3", ' +
                     b'"is_binary": false, "is_rename": false, ' +
                     b'"hunks": [{"ss": 0, "sl": 0, "ts": 1, "tl": 3}]}]')
        self.expect_build_data('diffinfo-master', diff_info, 'GitDiffInfo')
        return self.runStep()
Esempio n. 7
0
 def test_tarball(self):
     """repo sync using the tarball cache
     """
     self.mySetupStep(tarball="/tarball.tar")
     self.expectClobber()
     self.expectCommands(self.ExpectShell(command = ['tar', '-xvf', '/tarball.tar'])+0)
     self.expectRepoSync()
     self.expectCommands(self.ExpectShell(command = ['stat', '-c%Y', '/tarball.tar'])
                         + Expect.log('stdio',stdout=str(10000))
                         + 0)
     self.expectCommands(self.ExpectShell(command = ['stat', '-c%Y', '.'])
                         + Expect.log('stdio',stdout=str(10000+7*24*3600))
                         + 0)
     return self.myRunStep(status_text=["update"])
 def test_tarball(self):
     """repo sync using the tarball cache
     """
     self.mySetupStep(tarball="/tarball.tar")
     self.expectClobber()
     self.expectCommands(self.ExpectShell(command=["tar", "-xvf", "/tarball.tar"]) + 0)
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "/tarball.tar"]) + Expect.log("stdio", stdout=str(10000)) + 0
     )
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "."]) + Expect.log("stdio", stdout=str(10000 + 7 * 24 * 3600)) + 0
     )
     return self.myRunStep()
 def test_repo_downloads(self):
     """basic repo download, and check that repo_downloaded is updated"""
     self.mySetupStep()
     self.build.setProperty("repo_download", "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["repo", "download", "test/bla", "564/12"])
         + 0
         + Expect.log("stdio", stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log("stdio", stderr="HEAD is now at 0123456789abcdef...\n")
     )
     self.expectProperty("repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep()
Esempio n. 10
0
 def test_extra_logfile(self):
     self.setupStep(SimpleShellCommand(command=['cmd', 'arg'],
                                       logfiles={'logname': 'logpath.log'}))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['cmd', 'arg'],
                     logfiles={'logname': 'logpath.log'}) +
         Expect.log('logname', stdout='logline\nlogline2\n') +
         Expect.log('stdio', stdout="some log\n") +
         0,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertEqual(self.step.getLog('logname').stdout,
                      'logline\nlogline2\n')
Esempio n. 11
0
 def test_tarball(self):
     """repo sync using the tarball cache
     """
     self.mySetupStep(tarball="/tarball.tar")
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(command=['tar', '-xvf', '/tarball.tar']) + 0)
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=['stat', '-c%Y', '/tarball.tar']) +
         Expect.log('stdio', stdout=str(10000)) + 0)
     self.expectCommands(
         self.ExpectShell(command=['stat', '-c%Y', '.']) +
         Expect.log('stdio', stdout=str(10000 + 7 * 24 * 3600)) + 0)
     return self.myRunStep()
Esempio n. 12
0
 def test_repo_downloads_mirror_sync(self):
     """repo downloads, with mirror synchronization issues"""
     self.mySetupStep()
     self.step.mirror_sync_sleep = 0.001 # we dont really want the test to wait...
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +1 + Expect.log("stdio",stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +1 + Expect.log("stdio",stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +0)
     return self.myRunStep(status_text=["update"])
Esempio n. 13
0
 def test_repo_downloads_change_missing(self):
     """repo downloads, with no actual mirror synchronization issues (still retries 2 times)"""
     self.mySetupStep()
     self.step.mirror_sync_sleep = 0.001 # we dont really want the test to wait...
     self.step.mirror_sync_retry = 1 # on retry once
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +1 + Expect.log("stdio",stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +1 + Expect.log("stdio",stderr="fatal: Couldn't find remote ref \n"),
         )
     return self.myRunStep(result=FAILURE,status_text=["repo: change test/bla 564/12 does not exist"])
Esempio n. 14
0
 def test_repo_downloads_from_change_source(self):
     """basic repo download from change source, and check that repo_downloaded is updated"""
     self.mySetupStep(repoDownloads=repo.RepoDownloadsFromChangeSource())
     chdict = TestGerritChangeSource.expected_change
     change = Change(None, None, None, properties=chdict["properties"])
     self.build.allChanges = lambda x=None: [change]
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["repo", "download", "pr", "4321/12"])
         + 0
         + Expect.log("stdio", stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log("stdio", stderr="HEAD is now at 0123456789abcdef...\n")
     )
     self.expectProperty("repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep()
Esempio n. 15
0
    def test_multiple_errors(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.addError(test1, create_error('error1'))
        client.stopTest(test1)
        client.startTest(test2)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=FAILURE,
            state_string="shell Total 2 test(s) 2 errors (failure)")
        self.expectLogfile(
            'problems', '''\
test1
testtools.testresult.real._StringException: Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error1'

test2
testtools.testresult.real._StringException: Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error2'

''')
        return self.runStep()
Esempio n. 16
0
    def test_warnings(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.stopTest(test1)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=SUCCESS,  # N.B. not WARNINGS
            state_string="shell 1 test passed")
        # note that the warnings list is ignored..
        self.expectLogfile(
            'warnings', '''\
error: test2 [
Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error2'
]
''')
        return self.runStep()
Esempio n. 17
0
    def test_multiple_errors(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.addError(test1, create_error('error1'))
        client.stopTest(test1)
        client.startTest(test2)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=FAILURE,
            state_string="shell Total 2 test(s) 2 errors (failure)")
        self.expectLogfile('problems', re.compile(r'''test1
testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error1'

test2
testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error2'
.*''', re.MULTILINE | re.DOTALL))  # noqa pylint: disable=line-too-long
        return self.runStep()
Esempio n. 18
0
 def test_repo_downloads_from_change_source(self):
     """basic repo download from change source, and check that repo_downloaded is updated"""
     self.mySetupStep(repoDownloads=repo.RepoDownloadsFromChangeSource())
     chdict = TestGerritChangeSource.expected_change
     change = Change(None, None, None, properties=chdict['properties'])
     self.build.allChanges = lambda x=None: [change]
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=['repo', 'download', 'pr', '4321/12'])
         + 0
         + Expect.log(
             'stdio', stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log('stdio', stderr="HEAD is now at 0123456789abcdef...\n"))
     self.expectProperty(
         "repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep()
Esempio n. 19
0
 def do_test_update_tarball(self, suffix, option):
     """repo sync update the tarball cache at the end (tarball older than a week)
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.expectClobber()
     self.expectCommands(self.ExpectShell(command=["tar"] + option + ["-xvf", "/tarball." + suffix]) + 0)
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "/tarball." + suffix])
         + Expect.log("stdio", stdout=str(10000))
         + 0,
         self.ExpectShell(command=["stat", "-c%Y", "."])
         + Expect.log("stdio", stdout=str(10001 + 7 * 24 * 3600))
         + 0,
         self.ExpectShell(command=["tar"] + option + ["-cvf", "/tarball." + suffix, ".repo"]) + 0,
     )
     return self.myRunStep()
Esempio n. 20
0
 def do_test_update_tarball(self, suffix, option):
     """repo sync update the tarball cache at the end (tarball older than a week)
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(command=['tar'] + option +
                          ['-xvf', '/tarball.' + suffix]) + 0)
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=['stat', '-c%Y', '/tarball.' + suffix]) +
         Expect.log('stdio', stdout=str(10000)) + 0,
         self.ExpectShell(command=['stat', '-c%Y', '.']) +
         Expect.log('stdio', stdout=str(10001 + 7 * 24 * 3600)) + 0,
         self.ExpectShell(command=['tar'] + option +
                          ['-cvf', '/tarball.' + suffix, '.repo']) + 0)
     return self.myRunStep()
Esempio n. 21
0
 def test_repo_downloads(self):
     """basic repo download, and check that repo_downloaded is updated"""
     self.mySetupStep()
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12'])
         + 0
         + Expect.log(
             'stdio', stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log('stdio', stderr="HEAD is now at 0123456789abcdef...\n"))
     self.expectProperty(
         "repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep()
Esempio n. 22
0
 def do_test_update_tarball(self,suffix,option):
     """repo sync update the tarball cache at the end (tarball older than a week)
     """
     self.mySetupStep(tarball="/tarball."+suffix)
     self.expectClobber()
     self.expectCommands(self.ExpectShell(command = ['tar']+option+['-xvf', '/tarball.'+suffix])+0)
     self.expectRepoSync()
     self.expectCommands(self.ExpectShell(command = ['stat', '-c%Y', '/tarball.'+suffix])
                         + Expect.log('stdio',stdout=str(10000))
                         + 0,
                         self.ExpectShell(command = ['stat', '-c%Y', '.'])
                         + Expect.log('stdio',stdout=str(10001+7*24*3600))
                         + 0,
                         self.ExpectShell(command = ['tar']+option+
                                     ['-cvf', '/tarball.'+suffix, '.repo'])
                         + 0)
     return self.myRunStep(status_text=["update"])
Esempio n. 23
0
 def test_empty_diff(self):
     self.setupStep(gitdiffinfo.GitDiffInfo())
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['git', 'merge-base', 'HEAD', 'master']) +
         Expect.log('stdio-merge-base', stdout='1234123412341234') + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'git', 'diff', '--no-prefix', '-U0',
                         '1234123412341234', 'HEAD'
                     ]) + Expect.log('stdio-diff', stdout='') + 0,
     )
     self.expectLogfile('stdio-merge-base', '1234123412341234')
     self.expect_log_file_stderr('stdio-diff', '')
     self.expectOutcome(result=results.SUCCESS, state_string="GitDiffInfo")
     self.expect_build_data('diffinfo-master', b'[]', 'GitDiffInfo')
     return self.runStep()
Esempio n. 24
0
 def test_diff_failure(self):
     self.setupStep(gitdiffinfo.GitDiffInfo())
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['git', 'merge-base', 'HEAD', 'master']) +
         Expect.log('stdio-merge-base', stdout='1234123412341234') + 0,
         ExpectShell(workdir='wkdir',
                     command=[
                         'git', 'diff', '--no-prefix', '-U0',
                         '1234123412341234', 'HEAD'
                     ]) +
         Expect.log('stdio-diff', stderr='fatal: ambiguous argument') + 1,
     )
     self.expectLogfile('stdio-merge-base', '1234123412341234')
     self.expect_log_file_stderr('stdio-diff', 'fatal: ambiguous argument')
     self.expectOutcome(result=results.FAILURE,
                        state_string="GitDiffInfo (failure)")
     return self.runStep()
Esempio n. 25
0
 def test_repo_downloads_mirror_sync(self):
     """repo downloads, with mirror synchronization issues"""
     self.mySetupStep()
     self.step.mirror_sync_sleep = 0.001  # we dont really want the test to wait...
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 1 +
         Expect.log("stdio", stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 1 +
         Expect.log("stdio", stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 0)
     return self.myRunStep()
Esempio n. 26
0
 def test_repo_downloads_from_change_source_codebase(self):
     """basic repo download from change source, and check that repo_downloaded is updated"""
     self.mySetupStep(repoDownloads=repo.RepoDownloadsFromChangeSource("mycodebase"))
     chdict = TestGerritChangeSource.expected_change
     change = Change(None, None, None, properties=chdict["properties"])
     # getSourceStamp is faked by SourceStepMixin
     ss = self.build.getSourceStamp("")
     ss.changes = [change]
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["repo", "download", "pr", "4321/12"])
         + 0
         + Expect.log("stdio", stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log("stdio", stderr="HEAD is now at 0123456789abcdef...\n")
     )
     self.expectProperty("repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep(status_text=["update"])
Esempio n. 27
0
 def test_lazy_logfiles_stdout_has_stdout(self):
     self.setupStep(
         SimpleShellCommand(command=['cmd', 'arg'], lazylogfiles=True))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['cmd', 'arg']) +
         Expect.log('stdio', stdout="some log\n") + 0, )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertEqual(self.step.getLog('stdio').stdout, 'some log\n')
Esempio n. 28
0
 def test_example_extra_logfile(self):
     self.setupStep(ShellMixinExample(logfiles={"cleanup": "cleanup.log"}))
     self.expectCommands(
         ExpectShell(workdir="build", command=["./cleanup.sh"], logfiles={"cleanup": "cleanup.log"})
         + Expect.log("cleanup", stdout="cleaning\ncleaned\n")
         + 0
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertEqual(self.step.getLog("cleanup").stdout, u"cleaning\ncleaned\n")
Esempio n. 29
0
 def test_repo_downloads_from_change_source_codebase(self):
     """basic repo download from change source, and check that repo_downloaded is updated"""
     self.mySetupStep(repoDownloads=repo.RepoDownloadsFromChangeSource("mycodebase"))
     chdict = TestGerritChangeSource.expected_change
     change = Change(None, None, None, properties=chdict['properties'])
     # getSourceStamp is faked by SourceStepMixin
     ss = self.build.getSourceStamp("")
     ss.changes = [change]
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=['repo', 'download', 'pr', '4321/12'])
         + 0
         + Expect.log(
             'stdio', stderr="test/bla refs/changes/64/564/12 -> FETCH_HEAD\n")
         + Expect.log('stdio', stderr="HEAD is now at 0123456789abcdef...\n"))
     self.expectProperty(
         "repo_downloaded", "564/12 0123456789abcdef ", "Source")
     return self.myRunStep(status_text=["update"])
Esempio n. 30
0
 def test_example(self):
     self.setupStep(ShellMixinExample())
     self.expectCommands(
         ExpectShell(workdir="build", command=["./cleanup.sh"])
         + Expect.log("stdio", stderr="didn't go so well\n")
         + 1,
         ExpectShell(workdir="build", command=["./cleanup.sh", "--force"], logEnviron=False) + 0,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
Esempio n. 31
0
 def test_repo_downloads_change_missing(self):
     """repo downloads, with no actual mirror synchronization issues (still retries 2 times)"""
     self.mySetupStep()
     self.step.mirror_sync_sleep = 0.001  # we dont really want the test to wait...
     self.step.mirror_sync_retry = 1  # on retry once
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 1 +
         Expect.log("stdio", stderr="fatal: Couldn't find remote ref \n"),
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 1 +
         Expect.log("stdio", stderr="fatal: Couldn't find remote ref \n"),
     )
     return self.myRunStep(
         result=FAILURE,
         status_text=["repo: change test/bla 564/12 does not exist"])
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='deploy p1', logfile='deploy')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(ExpectShell(workdir='build', command='make p1') + 0,
                         ExpectShell(workdir='build', command='deploy p1') + 0 +
                         Expect.log('stdio deploy p1'))
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
Esempio n. 33
0
 def test_pathExists_logging(self):
     self.step.testMethod = lambda: self.step.pathExists("/some/path")
     self.expectCommands(
         Expect("stat", {"file": "/some/path", "logEnviron": False})
         + Expect.log("stdio", header="NOTE: never mind\n")
         + 1
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertFalse(self.step.method_return_value)
     self.assertEqual(self.step.getLog("stdio").header, "NOTE: never mind\n")
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='deploy p1', logfile='deploy')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(ExpectShell(workdir='build', command='make p1') + 0,
                         ExpectShell(workdir='build', command='deploy p1') + 0 +
                         Expect.log('stdio deploy p1'))
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
Esempio n. 35
0
 def test_example_extra_logfile(self):
     self.setupStep(ShellMixinExample(logfiles={'cleanup': 'cleanup.log'}))
     self.expectCommands(
         ExpectShell(workdir='build',
                     command=['./cleanup.sh'],
                     logfiles={'cleanup': 'cleanup.log'}) +
         Expect.log('cleanup', stdout='cleaning\ncleaned\n') + 0, )
     self.expectOutcome(result=SUCCESS, status_text=['generic'])
     yield self.runStep()
     self.assertEqual(
         self.step.getLog('cleanup').stdout, u'cleaning\ncleaned\n')
Esempio n. 36
0
 def test_example(self):
     self.setupStep(ShellMixinExample(), wantDefaultWorkdir=False)
     self.expectCommands(
         ExpectShell(workdir='build', command=['./cleanup.sh']) +
         Expect.log('stdio', stderr="didn't go so well\n") + 1,
         ExpectShell(workdir='build',
                     command=['./cleanup.sh', '--force'],
                     logEnviron=False) + 0,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
Esempio n. 37
0
 def test_update_tarball_fail2(self, suffix="tar", option=[]):
     """tarball update fail -> remove the tarball + continue repo download
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.build.setProperty("repo_download", "repo download test/bla 564/12", "test")
     self.expectClobber()
     self.expectCommands(self.ExpectShell(command=["tar"] + option + ["-xvf", "/tarball." + suffix]) + 0)
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "/tarball." + suffix])
         + Expect.log("stdio", stdout=str(10000))
         + 0,
         self.ExpectShell(command=["stat", "-c%Y", "."])
         + Expect.log("stdio", stdout=str(10001 + 7 * 24 * 3600))
         + 0,
         self.ExpectShell(command=["tar"] + option + ["-cvf", "/tarball." + suffix, ".repo"]) + 1,
         self.ExpectShell(command=["rm", "-f", "/tarball.tar"]) + 0,
         self.ExpectShell(command=["repo", "download", "test/bla", "564/12"]) + 0,
     )
     return self.myRunStep()
Esempio n. 38
0
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command="make p1")
     arg2 = shellsequence.ShellArg(command="deploy p1", logfile="deploy")
     self.setupStep(shellsequence.ShellSequence(commands=[arg1, arg2], workdir="build"))
     self.expectCommands(
         ExpectShell(workdir="build", command="make p1", usePTY="slave-config") + 0,
         ExpectShell(workdir="build", command="deploy p1", usePTY="slave-config")
         + 0
         + Expect.log("stdio deploy p1"),
     )
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
Esempio n. 39
0
 def test_update_tarball_fail1(self, suffix="tar", option=[]):
     """tarball extract fail -> remove the tarball + remove .repo dir
     """
     self.mySetupStep(tarball="/tarball." + suffix)
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(command=["tar"] + option + ["-xvf", "/tarball." + suffix]) + 1,
         self.ExpectShell(command=["rm", "-f", "/tarball.tar"]) + 0,
         Expect("rmdir", dict(dir="wkdir/.repo", logEnviron=False)) + 0,
     )
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "/tarball." + suffix])
         + Expect.log("stdio", stdout=str(10000))
         + 0,
         self.ExpectShell(command=["stat", "-c%Y", "."])
         + Expect.log("stdio", stdout=str(10001 + 7 * 24 * 3600))
         + 0,
         self.ExpectShell(command=["tar"] + option + ["-cvf", "/tarball." + suffix, ".repo"]) + 0,
     )
     return self.myRunStep()
Esempio n. 40
0
 def test_merge_base_failure(self):
     self.setupStep(gitdiffinfo.GitDiffInfo())
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=['git', 'merge-base', 'HEAD', 'master']) +
         Expect.log('stdio-merge-base',
                    stderr='fatal: Not a valid object name') + 128)
     self.expect_log_file_stderr('stdio-merge-base',
                                 'fatal: Not a valid object name')
     self.expectOutcome(result=results.FAILURE,
                        state_string="GitDiffInfo (failure)")
     return self.runStep()
Esempio n. 41
0
 def test_example_extra_logfile(self):
     self.setupStep(ShellMixinExample(logfiles={'cleanup': 'cleanup.log'}), wantDefaultWorkdir=False)
     self.expectCommands(
         ExpectShell(workdir='build', command=['./cleanup.sh'],
                     logfiles={'cleanup': 'cleanup.log'})
         + Expect.log('cleanup', stdout='cleaning\ncleaned\n')
         + 0,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertEqual(self.step.getLog('cleanup').stdout,
                      u'cleaning\ncleaned\n')
Esempio n. 42
0
 def test_pathExists_logging(self):
     self.step.testMethod = lambda: self.step.pathExists('/some/path')
     self.expectCommands(
         Expect('stat', {
             'file': '/some/path',
             'logEnviron': False
         }) + Expect.log('stdio', header='NOTE: never mind\n') + 1, )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertFalse(self.step.method_return_value)
     self.assertEqual(
         self.step.getLog('stdio').header, 'NOTE: never mind\n')
Esempio n. 43
0
 def test_pathExists_logging(self):
     self.step.testMethod = lambda: self.step.pathExists('/some/path')
     self.expectCommands(
         Expect('stat', {'file': '/some/path', 'logEnviron': False})
         + Expect.log('stdio', header='NOTE: never mind\n')
         + 1,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
     self.assertFalse(self.step.method_return_value)
     self.assertEqual(self.step.getLog('stdio').header,
                      'NOTE: never mind\n')
Esempio n. 44
0
 def test_example(self):
     self.setupStep(ShellMixinExample(), wantDefaultWorkdir=False)
     self.expectCommands(
         ExpectShell(workdir='build', command=['./cleanup.sh'])
         + Expect.log('stdio', stderr="didn't go so well\n")
         + 1,
         ExpectShell(workdir='build', command=['./cleanup.sh', '--force'],
                     logEnviron=False)
         + 0,
     )
     self.expectOutcome(result=SUCCESS)
     yield self.runStep()
Esempio n. 45
0
    def test_custom_python(self):
        self.setupStep(python_twisted.Trial(workdir='build', tests='testname',
                                            python='/bin/mypython', testpath=None))

        self.expectCommands(
            ExpectShell(workdir='build',
                        command=['/bin/mypython', 'trial', '--reporter=bwverbose', 'testname'],
                        logfiles={'test.log': '_trial_temp/test.log'})
            + Expect.log('stdio', stdout="Ran 2 tests\n")
            + 0
        )
        self.expectOutcome(result=SUCCESS, state_string='2 tests passed')
        return self.runStep()
 def testShellArgsAreRendered(self):
     arg1 = shellsequence.ShellArg(command=WithProperties('make %s', 'project'),
                                   logfile=WithProperties('make %s', 'project'))
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1],
                                     workdir='build'))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     self.expectCommands(ExpectShell(workdir='build', command='make BUILDBOT-TEST')
                         + 0 + Expect.log('stdio make BUILDBOT-TEST'))
     # TODO: need to factor command-summary stuff into a utility method and
     # use it here
     self.expectOutcome(result=SUCCESS, state_string="'make BUILDBOT-TEST'")
     return self.runStep()
 def testShellArgsAreRendered(self):
     arg1 = shellsequence.ShellArg(
         command=WithProperties("make %s", "project"), logfile=WithProperties("make %s", "project")
     )
     self.setupStep(shellsequence.ShellSequence(commands=[arg1], workdir="build"))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     self.expectCommands(
         ExpectShell(workdir="build", command="make BUILDBOT-TEST", usePTY="slave-config")
         + 0
         + Expect.log("stdio make BUILDBOT-TEST")
     )
     self.expectOutcome(result=SUCCESS, status_text=["'make", "BUILDBOT-TEST'"])
     return self.runStep()
Esempio n. 48
0
 def test_repo_downloads_fail2(self):
     """repo downloads, cherry-pick returns 0 but error in stderr"""
     self.mySetupStep()
     self.build.setProperty("repo_download", "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["repo", "download", "test/bla", "564/12"])
         + 0
         + Expect.log("stdio", stderr="Automatic cherry-pick failed \n"),
         self.ExpectShell(command=["repo", "forall", "-c", "git", "diff", "HEAD"]) + 0,
     )
     return self.myRunStep(result=FAILURE, state_string="download failed: test/bla 564/12 (failure)")
Esempio n. 49
0
 def testShellArgsAreRendered(self):
     arg1 = shellsequence.ShellArg(command=WithProperties('make %s', 'project'),
                                   logfile=WithProperties('make %s', 'project'))
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1],
                                     workdir='build'))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     self.expectCommands(ExpectShell(workdir='build', command='make BUILDBOT-TEST',
                                     usePTY="slave-config")
                         + 0 + Expect.log('stdio make BUILDBOT-TEST'))
     # TODO: need to factor command-summary stuff into a utility method and use it here
     self.expectOutcome(result=SUCCESS, state_string="'make BUILDBOT-TEST'")
     return self.runStep()
Esempio n. 50
0
 def test_repo_downloads_fail1(self):
     """repo downloads, cherry-pick returns 1"""
     self.mySetupStep()
     self.build.setProperty("repo_download", "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["repo", "download", "test/bla", "564/12"])
         + 1
         + Expect.log("stdio", stderr="patch \n"),
         self.ExpectShell(command=["repo", "forall", "-c", "git", "diff", "HEAD"]) + 0,
     )
     return self.myRunStep(result=FAILURE, status_text=["download failed: test/bla 564/12"])
 def test_checkout_bzrsvn_revision(self):
     self.setupStep(BzrSvn(baseURL="/some/bzr/repo/", branch='trunk', forceSharedRepo=True),
             dict(revision='9999'))
     self.expectCommands(
             ExpectShell(workdir='wkdir',
                        command=['bzr', 'plugins'])
             + ExpectShell.log('stdio', stdout="launchpad 1234\nsvn 2345")
             + 0,
             Expect('bzr', dict(workdir='wkdir',
                                repourl="/some/bzr/repo/trunk",
                                logEnviron=True,
                                patch=None,
                                revision='svn:9999',
                                env=None,
                                forceSharedRepo=True,
                                mode='update',
                                timeout=20*60,
                                retry=None))
             + Expect.update('got_revision', 1234)
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['bzr', 'revert', '--no-backup'])
             + 0,
             ExpectShell(workdir='wkdir',
                         command=["bzr", "clean-tree", "--force", "--ignored", "--detritus"])
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['bzr', 'version-info'])
             + Expect.log('stdio', stdout='svn-revno: 9999')
             + 0,
             ExpectShell(workdir='wkdir',
                 command=['bzr', 'log', '-r', 'last:2'])
             + Expect.log('stdio', stdout='svn-revno: 9888 on (/trunk)')
             + 0,
     )
     self.expectOutcome(result=SUCCESS, status_text=['update'])
     self.expectProperty('got_revision', '9999')
     self.expectProperty('branch_revision', '9888')
     return self.runStep()
Esempio n. 52
0
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='deploy p1', logfile='deploy')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(
         ExpectShell(
             workdir='build', command='make p1', usePTY="slave-config") + 0,
         ExpectShell(
             workdir='build', command='deploy p1', usePTY="slave-config") +
         0 + Expect.log('stdio deploy p1'))
     self.expectOutcome(result=SUCCESS, status_text=["'deploy", "p1'"])
     return self.runStep()
Esempio n. 53
0
    def test_success(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test = FakeTest(id='test1')
        client.startTest(test)
        client.stopTest(test)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(result=SUCCESS, state_string="shell 1 test passed")
        return self.runStep()
Esempio n. 54
0
 def test_repo_downloads_fail2(self):
     """repo downloads, cherry-pick returns 0 but error in stderr"""
     self.mySetupStep()
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command = ['repo', 'download', 'test/bla', '564/12'])
         +0 + Expect.log("stdio",stderr="Automatic cherry-pick failed \n"),
         self.ExpectShell(command = ['repo', 'forall', '-c',  'git', 'diff', 'HEAD'])
         +0
         )
     return self.myRunStep(result=FAILURE, status_text=["download failed: test/bla 564/12"])
Esempio n. 55
0
    def test_test_path_env_python_path(self):
        self.setupStep(python_twisted.Trial(workdir='build', tests='testname',
                                            testpath='custom/test/path',
                                            env={'PYTHONPATH': '/existing/pypath'}))

        self.expectCommands(
            ExpectShell(workdir='build',
                        command=['trial', '--reporter=bwverbose', 'testname'],
                        logfiles={'test.log': '_trial_temp/test.log'},
                        env={'PYTHONPATH': ['custom/test/path', '/existing/pypath']})
            + Expect.log('stdio', stdout="Ran 2 tests\n")
            + 0
        )
        self.expectOutcome(result=SUCCESS, state_string='2 tests passed')
        return self.runStep()
Esempio n. 56
0
 def test_repo_downloads_fail2(self):
     """repo downloads, cherry-pick returns 0 but error in stderr"""
     self.mySetupStep()
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12']) + 0 +
         Expect.log("stdio", stderr="Automatic cherry-pick failed \n"),
         self.ExpectShell(
             command=['repo', 'forall', '-c', 'git', 'diff', 'HEAD']) + 0)
     return self.myRunStep(result=FAILURE,
                           status_text=["download failed: test/bla 564/12"])
Esempio n. 57
0
 def test_repo_downloads_fail1(self):
     """repo downloads, cherry-pick returns 1"""
     self.mySetupStep()
     self.build.setProperty("repo_download",
                            "repo download test/bla 564/12", "test")
     self.expectnoClobber()
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(
             command=['repo', 'download', 'test/bla', '564/12'])
         + 1 + Expect.log("stdio", stderr="patch \n"),
         self.ExpectShell(
             command=['repo', 'forall', '-c', 'git', 'diff', 'HEAD'])
         + 0
     )
     return self.myRunStep(result=FAILURE,
                           state_string="download failed: test/bla 564/12 (failure)")
Esempio n. 58
0
 def test_create_tarball(self):
     """repo sync create the tarball if its not here
     """
     self.mySetupStep(tarball="/tarball.tgz")
     self.expectClobber()
     self.expectCommands(
         self.ExpectShell(command=["tar", "-z", "-xvf", "/tarball.tgz"]) + 1,
         self.ExpectShell(command=["rm", "-f", "/tarball.tgz"]) + 1,
         Expect("rmdir", dict(dir="wkdir/.repo", logEnviron=False)) + 1,
     )
     self.expectRepoSync()
     self.expectCommands(
         self.ExpectShell(command=["stat", "-c%Y", "/tarball.tgz"])
         + Expect.log("stdio", stderr="file not found!")
         + 1,
         self.ExpectShell(command=["tar", "-z", "-cvf", "/tarball.tgz", ".repo"]) + 0,
     )
     return self.myRunStep()