Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | |
| 6 import json | |
| 7 | |
| 5 from pipeline_utils.appengine_third_party_pipeline_src_pipeline import handlers | 8 from pipeline_utils.appengine_third_party_pipeline_src_pipeline import handlers |
| 6 from testing_utils import testing | 9 from testing_utils import testing |
| 7 | 10 |
| 8 from model.wf_step import WfStep | 11 from model.wf_step import WfStep |
| 9 from waterfall import buildbot | 12 from waterfall import buildbot |
| 10 from waterfall import extractors | 13 from waterfall import extractors |
| 11 from waterfall.extract_signal_pipeline import ExtractSignalPipeline | 14 from waterfall.extract_signal_pipeline import ExtractSignalPipeline |
| 12 | 15 |
| 13 | 16 |
| 14 class ExtractSignalPipelineTest(testing.AppengineTestCase): | 17 class ExtractSignalPipelineTest(testing.AppengineTestCase): |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 master_name, builder_name, build_number, step_name) | 91 master_name, builder_name, build_number, step_name) |
| 89 with self.mock_urlfetch() as urlfetch: | 92 with self.mock_urlfetch() as urlfetch: |
| 90 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG) | 93 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG) |
| 91 | 94 |
| 92 pipeline = ExtractSignalPipeline(self.FAILURE_INFO) | 95 pipeline = ExtractSignalPipeline(self.FAILURE_INFO) |
| 93 pipeline.start() | 96 pipeline.start() |
| 94 self.execute_queued_tasks() | 97 self.execute_queued_tasks() |
| 95 | 98 |
| 96 step = WfStep.Create(master_name, builder_name, build_number, step_name) | 99 step = WfStep.Create(master_name, builder_name, build_number, step_name) |
| 97 self.assertIsNotNone(step) | 100 self.assertIsNotNone(step) |
| 101 | |
| 102 def _GetGtestResultLog(self, | |
| 103 master_name, builder_name, build_number, step_name): | |
| 104 file_name = os.path.join( | |
| 105 os.path.dirname(__file__), 'data', | |
| 106 '%s_%s_%d_%s.json' % (master_name, | |
| 107 builder_name, build_number, step_name)) | |
| 108 with open(file_name, 'r') as f: | |
| 109 return f.read() | |
| 110 | |
| 111 def testGetTestLevelFailures(self): | |
| 112 master_name = 'm' | |
| 113 builder_name = 'b' | |
| 114 build_number = 123 | |
| 115 step_name = 'abc_test' | |
| 116 | |
| 117 expected_failure_log = ("'Unittest2.Subtest1': a/b/u2s1.cc:567: Failure\\n"+ | |
|
stgao
2015/05/22 01:30:37
No double quote in python code.
Escape \' if need
| |
| 118 "[2]: 2594735000 bogo-microseconds\\n\n" + | |
| 119 "'Unittest2.Subtest1': a/b/u2s1.cc:567: Failure\n" + | |
| 120 "'Unittest2.Subtest1': a/b/u2s1.cc:567: Failure\n" + | |
| 121 "'Unittest2.Subtest1': a/b/u2s1.cc:567: Failure\n" + | |
| 122 "'Unittest3.Subtest2': a/b/u3s2.cc:110: Failure\n" + | |
| 123 "'Unittest3.Subtest2': a/b/u3s2.cc:110: Failure\n" + | |
| 124 "'Unittest3.Subtest2': a/b/u3s2.cc:110: Failure\n" + | |
| 125 "'Unittest3.Subtest2': a/b/u3s2.cc:110: Failure\n") | |
| 126 | |
| 127 step_log = self._GetGtestResultLog(master_name, | |
| 128 builder_name, build_number, step_name) | |
| 129 | |
| 130 failed_test_log = ExtractSignalPipeline._GetTestLevelFailures(step_log) | |
| 131 self.assertEqual(expected_failure_log, failed_test_log) | |
| 132 | |
| 133 def testGetSignalFromStepLog(self): | |
| 134 master_name = 'm' | |
| 135 builder_name = 'b' | |
| 136 build_number = 123 | |
| 137 step_name = 'abc_test' | |
| 138 | |
| 139 # Mock both stdiolog and step log to test whether Findit will | |
| 140 # go to step log first when both logs exist. | |
| 141 step_log_url = buildbot.CreateStdioLogUrl( | |
| 142 master_name, builder_name, build_number, step_name) | |
| 143 with self.mock_urlfetch() as urlfetch: | |
| 144 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG) | |
| 145 | |
| 146 def _MockGetGtestResultLog(master_name, | |
| 147 builder_name, build_number, step_name): | |
| 148 return self._GetGtestResultLog(master_name, | |
| 149 builder_name, build_number, step_name) | |
| 150 self.mock(buildbot, 'GetGtestResultLog', _MockGetGtestResultLog) | |
| 151 | |
| 152 pipeline = ExtractSignalPipeline(self.FAILURE_INFO) | |
| 153 signals = pipeline.run(self.FAILURE_INFO) | |
| 154 | |
| 155 step = WfStep.Get(master_name, builder_name, build_number, step_name) | |
| 156 | |
| 157 expected_files = { | |
| 158 'a/b/u2s1.cc': [567], | |
|
Sharu Jiang
2015/05/22 17:54:30
Should the indent here be 4 spaces?
| |
| 159 'a/b/u3s2.cc': [110] | |
| 160 } | |
| 161 | |
| 162 self.assertIsNotNone(step) | |
| 163 self.assertIsNotNone(step.log_data) | |
| 164 self.assertEqual(expected_files, signals['abc_test']['files']) | |
| OLD | NEW |