def test_PackageRequestForReleng(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, workspace='/ws', env={ 'GERRIT_PROJECT': 'releng', 'GERRIT_REFSPEC': commits.releng.refspec, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Package') }) helper.add_input_file( '/ws/gromacs/admin/builds/get-version-info.py', 'def do_build(context):\n context.set_version_info("2017", "1234567890abcdef")\n' ) factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'source-package' }, { 'type': 'regtest-package', 'version': '2017', 'md5sum': '1234567890abcdef' }], 'revisions': commits.expected_build_revisions })
def setUp(self): self.helper = TestHelper(self) self.helper.add_input_file( "Testing/TAG", """\ YYYYMMDD-HHMM Experimental """)
def test_CrossVerifyRequestOneBuildOnly(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=3456) commits.set_commit(Project.REGRESSIONTESTS, change_number=1234) commits.set_commit(Project.RELENG) helper = TestHelper( self, commits=commits, env={ 'BUILD_URL': 'http://build', 'GERRIT_PROJECT': 'gromacs', 'GERRIT_REFSPEC': commits.gromacs.refspec, 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': commits.gromacs.patch_number, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Cross-verify 1234 quiet coverage'), 'GROMACS_REFSPEC': 'refs/heads/master', 'REGRESSIONTESTS_REFSPEC': 'refs/heads/master' }) factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'coverage' }], 'revisions': commits.expected_build_revisions })
def test_SingleBuildWithCrossVerify(self): helper = TestHelper(self, env={ 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': '3', }) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': None, 'result': 'SUCCESS' }], 'gerrit_info': { 'change': 1234, 'patchset': 5 } }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': 'http://my_build', 'message': None}) helper.assertCommandInvoked([ 'ssh', '-p', '29418', '*****@*****.**', 'gerrit', 'review', '1234,5', '-m', '"Cross-verify with http://gerrit (patch set 3) finished\n\nhttp://my_build: SUCCESS"' ])
def test_PostSubmitRequest(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, workspace='/ws', env={ 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Post-submit') }) helper.add_input_file( '/ws/gromacs/admin/builds/post-submit-matrix.txt', '\n'.join(self._MATRIX_INPUT_LINES) + '\n') factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'matrix', 'desc': 'post-submit', 'matrix': self._MATRIX_EXPECTED_RESULT }], 'revisions': commits.expected_build_revisions })
def test_GetBuildRevisionsNoRegressionTests(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=1234) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits) projects = helper.factory.projects result = projects.get_build_revisions() self.assertEqual(result, commits.expected_build_revisions)
def test_MultilineTriggeringComment(self): helper = TestHelper(self, env={ 'GERRIT_PROJECT': 'gromacs', 'GERRIT_REFSPEC': 'refs/heads/master', 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS]\nCoverage\nMore') }) gerrit = helper.factory.gerrit self.assertEqual(gerrit.get_triggering_comment(), 'Coverage\nMore')
def test_ManualTriggerInPipeline(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=1234) commits.set_commit(Project.RELENG, change_number=3456) helper = TestHelper(self, commits=commits, env={ 'GROMACS_REFSPEC': commits.gromacs.refspec, 'RELENG_REFSPEC': commits.releng.refspec }) projects = helper.factory.projects self.verifyProjectInfo(projects, commits)
def test_GetBuildRevisionsWithAutoRefspecs(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.REGRESSIONTESTS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'GROMACS_REFSPEC': 'auto', 'REGRESSIONTESTS_REFSPEC': 'auto' }) projects = helper.factory.projects result = projects.get_build_revisions() self.assertEqual(result, commits.expected_build_revisions)
def test_TarballRef(self): helper = TestHelper(self) helper.add_input_file('tarballs/gromacs/package-info.log', """\ PACKAGE_FILE_NAME = gromacs-xyz-dev.tar.gz HEAD_HASH = 1234abcd """) refspec = RefSpec('tarballs/gromacs', executor=helper.executor) self.assertFalse(refspec.is_no_op) self.assertTrue(refspec.is_tarball) self.assertFalse(refspec.is_static) self.assertEqual(refspec.tarball_path, 'tarballs/gromacs/gromacs-xyz-dev.tar.gz') self.assertEqual(str(refspec), 'tarballs/gromacs')
def test_ManualTrigger(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=1234) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'CHECKOUT_PROJECT': 'gromacs', 'CHECKOUT_REFSPEC': commits.gromacs.refspec, 'GROMACS_REFSPEC': commits.gromacs.refspec, 'RELENG_REFSPEC': 'refs/heads/master' }) projects = helper.factory.projects self.verifyProjectInfo(projects, commits)
def test_CrossVerifyRequest(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=3456, patch_number=3) commits.set_commit(Project.REGRESSIONTESTS, change_number=1234, patch_number=5) commits.set_commit(Project.RELENG) helper = TestHelper( self, commits=commits, workspace='/ws', env={ 'BUILD_URL': 'http://build', 'GERRIT_PROJECT': 'gromacs', 'GERRIT_REFSPEC': commits.gromacs.refspec, 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': commits.gromacs.patch_number, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Cross-verify 1234'), 'GROMACS_REFSPEC': 'refs/heads/master', 'REGRESSIONTESTS_REFSPEC': 'refs/heads/master' }) helper.add_input_file('/ws/gromacs/admin/builds/pre-submit-matrix.txt', '\n'.join(self._MATRIX_INPUT_LINES) + '\n') factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'matrix', 'desc': 'cross-verify', 'matrix': self._MATRIX_EXPECTED_RESULT }], 'revisions': commits.expected_build_revisions, 'gerrit_info': { 'change': commits.regressiontests.change_number, 'patchset': commits.regressiontests.patch_number } }) helper.assertCommandInvoked([ 'ssh', '-p', '29418', '*****@*****.**', 'gerrit', 'review', '1234,5', '-m', '"Cross-verify with http://gerrit (patch set 3) running at http://build"' ])
def test_SingleBuild(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': None, 'result': 'SUCCESS' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': 'http://my_build', 'message': None})
def test_TarballsWithManualTrigger(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'GROMACS_REFSPEC': 'tarballs/gromacs', 'RELENG_REFSPEC': 'refs/heads/master' }) helper.add_input_file('tarballs/gromacs/package-info.log', """\ HEAD_HASH = 1234abcd """) projects = helper.factory.projects self.verifyProjectInfo(projects, commits, tarball=Project.GROMACS)
def test_Checkout(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG, change_number=1234) helper = TestHelper(self, commits=commits, env={ 'CHECKOUT_PROJECT': 'releng', 'CHECKOUT_REFSPEC': commits.releng.refspec, 'GROMACS_REFSPEC': 'refs/heads/master', 'RELENG_REFSPEC': 'refs/heads/master' }) projects = helper.factory.projects self.verifyProjectInfo(projects, commits) projects.checkout_project(Project.GROMACS)
def test_CrossVerifyRequestReleng(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=1234) commits.set_commit(Project.REGRESSIONTESTS) commits.set_commit(Project.RELENG, change_number=3456) helper = TestHelper( self, commits=commits, workspace='/ws', env={ 'BUILD_URL': 'http://build', 'GERRIT_PROJECT': 'releng', 'GERRIT_REFSPEC': commits.releng.refspec, 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': commits.releng.patch_number, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Cross-verify 1234 quiet'), 'GROMACS_REFSPEC': 'refs/heads/master', 'REGRESSIONTESTS_REFSPEC': 'refs/heads/master' }) helper.add_input_file('/ws/gromacs/admin/builds/pre-submit-matrix.txt', '\n'.join(self._MATRIX_INPUT_LINES) + '\n') factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'matrix', 'desc': 'cross-verify', 'matrix': self._MATRIX_EXPECTED_RESULT }, { 'type': 'clang-analyzer', 'desc': 'cross-verify' }, { 'type': 'documentation', 'desc': 'cross-verify' }, { 'type': 'uncrustify', 'desc': 'cross-verify' }], 'revisions': commits.expected_build_revisions })
def test_GetBuildRevisionsWithBranchDetection(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, change_number=1234, branch='release-2019') commits.set_commit(Project.REGRESSIONTESTS, branch='release-2019') commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'GERRIT_PROJECT': 'gromacs', 'GERRIT_REFSPEC': commits.gromacs.refspec, 'GROMACS_REFSPEC': 'auto', 'REGRESSIONTESTS_REFSPEC': 'auto' }) projects = helper.factory.projects result = projects.get_build_revisions() self.assertEqual(result, commits.expected_build_revisions)
def test_ManualTriggerWithHash(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'CHECKOUT_PROJECT': 'gromacs', 'CHECKOUT_REFSPEC': 'refs/heads/master', 'GROMACS_REFSPEC': 'refs/heads/master', 'GROMACS_HASH': commits.gromacs.sha1, 'RELENG_REFSPEC': 'refs/heads/master', 'RELENG_HASH': commits.releng.sha1 }) projects = helper.factory.projects self.verifyProjectInfo(projects, commits, expect_hashes=True)
def test_FailedSingleBuildWithoutUrl(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'title': 'My title', 'url': None, 'desc': None, 'result': 'FAILURE', 'reason': 'Failure reason' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': None, 'message': 'Failure reason'})
def test_CoverageRequest(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Coverage') }) factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'coverage' }], 'revisions': commits.expected_build_revisions })
def test_ReleaseBranchRequest(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS, branch='release-2016') commits.set_commit(Project.REGRESSIONTESTS, branch='release-2016') commits.set_commit(Project.RELENG, change_number=1234) helper = TestHelper(self, commits=commits, workspace='/ws', env={ 'GERRIT_PROJECT': 'releng', 'GERRIT_REFSPEC': commits.releng.refspec, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] release-2016'), 'GROMACS_REFSPEC': 'refs/heads/master', 'REGRESSIONTESTS_REFSPEC': 'refs/heads/master' }) helper.add_input_file('/ws/gromacs/admin/builds/pre-submit-matrix.txt', '\n'.join(self._MATRIX_INPUT_LINES) + '\n') factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'matrix', 'desc': 'release-2016', 'matrix': self._MATRIX_EXPECTED_RESULT }, { 'type': 'clang-analyzer', 'desc': 'release-2016' }, { 'type': 'documentation', 'desc': 'release-2016' }, { 'type': 'uncrustify', 'desc': 'release-2016' }], 'revisions': commits.expected_build_revisions })
def test_TwoBuilds(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' }, { 'url': 'http://my_build2', 'desc': None, 'result': 'SUCCESS' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual( result, { 'url': None, 'message': 'http://my_build (cross-verify): SUCCESS\nhttp://my_build2: SUCCESS' })
def test_PackageRequestForSource(self): commits = RepositoryTestState() commits.set_commit(Project.GROMACS) commits.set_commit(Project.RELENG) helper = TestHelper(self, commits=commits, env={ 'GERRIT_PROJECT': 'gromacs', 'GERRIT_REFSPEC': commits.gromacs.refspec, 'GERRIT_EVENT_COMMENT_TEXT': base64.b64encode('[JENKINS] Package') }) factory = helper.factory result = get_actions_from_triggering_comment(factory) self.assertEqual( result, { 'builds': [{ 'type': 'source-package' }], 'revisions': commits.expected_build_revisions })
def setUp(self): self.helper = TestHelper(self, workspace='/ws')
def setUp(self): self.helper = TestHelper(self)
def setUp(self): env = { 'STATUS_FILE': 'logs/status.json', 'NO_PROPAGATE_FAILURE': '1' } self.helper = TestHelper(self, workspace='ws', env=env)
def setUp(self): env = { 'STATUS_FILE': 'logs/status.json' } self.helper = TestHelper(self, workspace='ws', env=env)
def test_String(self): helper = TestHelper(self, env={ 'FOO': 'text' }) params = BuildParameters(helper.factory) self.assertEqual(params.get('FOO', ParameterTypes.string), 'text')
def test_Boolean(self): helper = TestHelper(self, env={ 'FOO': 'true', 'BAR': 'false' }) params = BuildParameters(helper.factory) self.assertEqual(params.get('FOO', ParameterTypes.bool), True) self.assertEqual(params.get('BAR', ParameterTypes.bool), False)
def test_Unknown(self): helper = TestHelper(self) params = BuildParameters(helper.factory) self.assertIsNone(params.get('FOO', ParameterTypes.bool))