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 | |
| 5 from pipeline_utils.appengine_third_party_pipeline_src_pipeline import handlers | 7 from pipeline_utils.appengine_third_party_pipeline_src_pipeline import handlers |
| 6 from testing_utils import testing | 8 from testing_utils import testing |
| 7 | 9 |
| 8 from model.wf_step import WfStep | 10 from model.wf_step import WfStep |
| 9 from waterfall import buildbot | 11 from waterfall import buildbot |
| 10 from waterfall import extractors | 12 from waterfall import extractors |
| 11 from waterfall.extract_signal_pipeline import ExtractSignalPipeline | 13 from waterfall.extract_signal_pipeline import ExtractSignalPipeline |
| 12 | 14 |
| 13 | 15 |
| 14 class ExtractSignalPipelineTest(testing.AppengineTestCase): | 16 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) | 90 master_name, builder_name, build_number, step_name) |
| 89 with self.mock_urlfetch() as urlfetch: | 91 with self.mock_urlfetch() as urlfetch: |
| 90 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG) | 92 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG) |
| 91 | 93 |
| 92 pipeline = ExtractSignalPipeline(self.FAILURE_INFO) | 94 pipeline = ExtractSignalPipeline(self.FAILURE_INFO) |
| 93 pipeline.start() | 95 pipeline.start() |
| 94 self.execute_queued_tasks() | 96 self.execute_queued_tasks() |
| 95 | 97 |
| 96 step = WfStep.Create(master_name, builder_name, build_number, step_name) | 98 step = WfStep.Create(master_name, builder_name, build_number, step_name) |
| 97 self.assertIsNotNone(step) | 99 self.assertIsNotNone(step) |
| 100 | |
| 101 def _GetGtestResultLog(self, | |
| 102 master_name, builder_name, build_number, step_name): | |
| 103 file_name = os.path.join( | |
| 104 os.path.dirname(__file__), 'data', | |
| 105 '%s_%s_%d_%s.json' % (master_name, | |
| 106 builder_name, build_number, step_name)) | |
| 107 with open(file_name, 'r') as f: | |
| 108 return f.read() | |
| 109 | |
| 110 def testGetTestLevelFailures(self): | |
| 111 master_name = 'm' | |
| 112 builder_name = 'b' | |
| 113 build_number = 123 | |
| 114 step_name = 'abc_test' | |
| 115 | |
| 116 expected_failure_log = ('\'Unittest2.Subtest1\': a/b/u2s1.cc:567: Failure' | |
| 117 '\\n[2]: 2594735000 bogo-microseconds\\n\n' | |
| 118 '\'Unittest2.Subtest1\': a/b/u2s1.cc:567: Failure\n' | |
| 119 '\'Unittest2.Subtest1\': a/b/u2s1.cc:567: Failure\n' | |
| 120 '\'Unittest2.Subtest1\': a/b/u2s1.cc:567: Failure\n' | |
| 121 '\'Unittest3.Subtest2\': a/b/u3s2.cc:110: 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 ) | |
| 126 | |
| 127 step_log = self._GetGtestResultLog(master_name, | |
| 128 builder_name, build_number, step_name) | |
| 129 | |
| 130 failed_test_log = ExtractSignalPipeline._GetReliableTestFailureLog(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, | |
|
stgao
2015/05/26 18:14:49
'_' could be removed.
Because function defined her
chanli
2015/05/26 19:07:39
Done.
| |
| 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], | |
| 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 |