diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/mozharness/test/test_mozilla_structured.py | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozharness/test/test_mozilla_structured.py')
-rw-r--r-- | testing/mozharness/test/test_mozilla_structured.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/testing/mozharness/test/test_mozilla_structured.py b/testing/mozharness/test/test_mozilla_structured.py new file mode 100644 index 0000000000..8bc30d5f8c --- /dev/null +++ b/testing/mozharness/test/test_mozilla_structured.py @@ -0,0 +1,68 @@ +import unittest + +from mozharness.base.log import INFO, WARNING +from mozharness.mozilla.automation import TBPL_SUCCESS, TBPL_WARNING +from mozharness.mozilla.mozbase import MozbaseMixin +from mozharness.mozilla.structuredlog import StructuredOutputParser +from mozlog.handlers.statushandler import RunSummary + +success_summary = RunSummary( + unexpected_statuses={}, + expected_statuses={"PASS": 3, "OK": 1, "FAIL": 1}, + known_intermittent_statuses={"FAIL": 1}, + log_level_counts={"info": 5}, + action_counts={"test_status": 4, "test_end": 1, "suite_end": 1}, +) + +failure_summary = RunSummary( + unexpected_statuses={"FAIL": 2}, + expected_statuses={"PASS": 2, "OK": 1}, + known_intermittent_statuses={}, + log_level_counts={"warning": 2, "info": 3}, + action_counts={"test_status": 3, "test_end": 2, "suite_end": 1}, +) + + +class TestParser(MozbaseMixin, StructuredOutputParser): + def __init__(self, *args, **kwargs): + super(TestParser, self).__init__(*args, **kwargs) + self.config = {} + + +class TestStructuredOutputParser(unittest.TestCase): + def setUp(self): + self.parser = TestParser() + + def test_evaluate_parser_success(self): + self.parser.handler.expected_statuses = {"PASS": 3, "OK": 1, "FAIL": 1} + self.parser.handler.log_level_counts = {"info": 5} + self.parser.handler.action_counts = { + "test_status": 4, + "test_end": 1, + "suite_end": 1, + } + self.parser.handler.known_intermittent_statuses = {"FAIL": 1} + result = self.parser.evaluate_parser( + return_code=TBPL_SUCCESS, success_codes=[TBPL_SUCCESS] + ) + tbpl_status, worst_log_level, joined_summary = result + self.assertEqual(tbpl_status, TBPL_SUCCESS) + self.assertEqual(worst_log_level, INFO) + self.assertEqual(joined_summary, success_summary) + + def test_evaluate_parser_failure(self): + self.parser.handler.unexpected_statuses = {"FAIL": 2} + self.parser.handler.expected_statuses = {"PASS": 2, "OK": 1} + self.parser.handler.log_level_counts = {"warning": 2, "info": 3} + self.parser.handler.action_counts = { + "test_status": 3, + "test_end": 2, + "suite_end": 1, + } + result = self.parser.evaluate_parser( + return_code=TBPL_SUCCESS, success_codes=[TBPL_SUCCESS] + ) + tbpl_status, worst_log_level, joined_summary = result + self.assertEqual(tbpl_status, TBPL_WARNING) + self.assertEqual(worst_log_level, WARNING) + self.assertEqual(joined_summary, failure_summary) |