Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: appengine/findit/waterfall/test/extract_signal_pipeline_test.py

Issue 1149743002: [Findit] Use step level analysis to exclude flaky test failures. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 _GetStepLog(self, 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 = {
117 "Unittest2.Subtest1":[
118 {
119 "elapsed_time_ms": 56,
120 "losless_snippet": True,
121 "output_snippet": "a/b/u2s1.cc:567: Failure",
122 "status": "FAILURE",
123 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
124 },
125 {
126 "elapsed_time_ms": 58,
127 "losless_snippet": True,
128 "output_snippet": "a/b/u2s1.cc:567: Failure",
129 "status": "FAILURE",
130 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
131 },
132 {
133 "elapsed_time_ms": 60,
134 "losless_snippet": True,
135 "output_snippet": "a/b/u2s1.cc:567: Failure",
136 "status": "FAILURE",
137 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
138 },
139 {
140 "elapsed_time_ms": 60,
141 "losless_snippet": True,
142 "output_snippet": "a/b/u2s1.cc:567: Failure",
143 "status": "FAILURE",
144 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
145 }
146 ],
147 "Unittest3.Subtest2":[
148 {
149 "elapsed_time_ms": 80,
150 "losless_snippet": True,
151 "output_snippet": "a/b/u3s2.cc:110: Failure",
152 "status": "FAILURE",
153 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
154 },
155 {
156 "elapsed_time_ms": 58,
157 "losless_snippet": True,
158 "output_snippet": "a/b/u3s2.cc:110: Failure",
159 "status": "FAILURE",
160 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
161 },
162 {
163 "elapsed_time_ms": 60,
164 "losless_snippet": True,
165 "output_snippet": "a/b/u3s2.cc:110: Failure",
166 "status": "FAILURE",
167 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
168 },
169 {
170 "elapsed_time_ms": 60,
171 "losless_snippet": True,
172 "output_snippet": "a/b/u3s2.cc:110: Failure",
173 "status": "FAILURE",
174 "output_snippet_base64": "WyBSVU4gICAgICBdIExheWVyQW5pbWF0aW9"
175 }
176 ]
177 }
178
179 step_log = self._GetStepLog(master_name,
180 builder_name, build_number, step_name)
181
182 failed_test_log = ExtractSignalPipeline._GetTestLevelFailures(step_log)
183 self.assertEqual(expected_failure_log, failed_test_log)
184
185 def testGetSignalFromStepLog(self):
186 master_name = 'm'
187 builder_name = 'b'
188 build_number = 123
189 step_name = 'abc_test'
190
191 # Mock both stdiolog and step log to test whether Findit will
192 # go to step log first when both logs exist.
193 step_log_url = buildbot.CreateStdioLogUrl(
194 master_name, builder_name, build_number, step_name)
195 with self.mock_urlfetch() as urlfetch:
196 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG)
197
198 def _MockGetGsStepLog(master_name, builder_name, build_number, step_name):
199 return self._GetStepLog(master_name,
200 builder_name, build_number, step_name)
201 self.mock(buildbot, 'GetGsStepLog', _MockGetGsStepLog)
202
203 pipeline = ExtractSignalPipeline(self.FAILURE_INFO)
204 signals = pipeline.run(self.FAILURE_INFO)
205
206 step = WfStep.Get(master_name, builder_name, build_number, step_name)
207
208 expected_files = {
209 'a/b/u2s1.cc': [567],
210 'a/b/u3s2.cc': [110]
211 }
212
213 self.assertIsNotNone(step)
214 self.assertIsNotNone(step.log_data)
215 self.assertEqual(expected_files, signals['abc_test']['files'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698