diff --git a/test/ci_support/trilinos_cdash_analyze_and_report_random_failures.py b/test/ci_support/trilinos_cdash_analyze_and_report_random_failures.py new file mode 100755 index 000000000..6d27a35a5 --- /dev/null +++ b/test/ci_support/trilinos_cdash_analyze_and_report_random_failures.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +import sys +import argparse +import re as regex + +import CDashAnalyzeReportRandomFailures as CDARRF + + +def main(): + + cdashAnalyzeAndReportRandomFailures = \ + CDARRF.CDashAnalyzeReportRandomFailuresDriver( + TrilinosVersionInfoStrategy(), + ExtractBuildNameStrategy()) + + cdashAnalyzeAndReportRandomFailures.runDriver() + +class TrilinosVersionInfoStrategy: + + def getTopicTargetSha1s(self, buildData): + pattern = r"Parent [12]:\n\s+(\w+)" + matchedList = regex.findall(pattern, buildData) + + if len(matchedList) != 2: return None + return tuple(matchedList) + + def checkTargetTopicRandomFailure(self, targetTopicPair, knownTargetTopicPairs): + return targetTopicPair in knownTargetTopicPairs + +class TrilinosExtractBuildNameStrategy: + + def getCoreBuildName(self, fullBuildName): + coreBuildName = fullBuildName.rsplit('-',1)[0] + return coreBuildName + + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/test/ci_support/trilinos_cdash_analyze_and_report_random_failures_UnitTests.py b/test/ci_support/trilinos_cdash_analyze_and_report_random_failures_UnitTests.py new file mode 100644 index 000000000..b207a16ab --- /dev/null +++ b/test/ci_support/trilinos_cdash_analyze_and_report_random_failures_UnitTests.py @@ -0,0 +1,53 @@ + +import unittest + +from FindCISupportDir import * +from trilinos_cdash_analyze_and_report_random_failures import * + + +class TestTrilinosVersionInfoStrategy(unittest.TestCase): + + def setUp(self): + self.strategy = TrilinosVersionInfoStrategy() + + def test_getTargetTopicSha1s_with_valid_versionData(self): + versionData = "Parent 1:\n target\nParent 2:\n topic" + + expected = ('target','topic') + result = self.strategy.getTopicTargetSha1s(versionData) + + self.assertEqual(result, expected) + + def test_checkTargetTopicRandomFailure_true(self): + targetTopicPair = ('target', 'topic') + knownTargetTopicPairs = {('target','topic')} + + result = self.strategy.checkTargetTopicRandomFailure(targetTopicPair, knownTargetTopicPairs) + + self.assertTrue(result) + + def test_checkTargetTopicRandomFailure_false(self): + targetTopicPair = ('some','other') + knownTargetTopicPairs = {('target','topic')} + + result = self.strategy.checkTargetTopicRandomFailure(targetTopicPair, knownTargetTopicPairs) + + self.assertFalse(result) + + +class TrilinosExtractBuildName(unittest.TestCase): + + def setUp(self): + self.strategy = TrilinosExtractBuildNameStrategy() + + def test_getCoreBuildName(self): + fullBuildName = "PR-number-test-core_build-name-number" + + expected = "PR-number-test-core_build-name" + result = self.strategy.getCoreBuildName(fullBuildName) + + self.assertEqual(result, expected) + + +if __name__ == '__main__': + unittest.main()