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

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: Fixed several small issues based on comments. 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
stgao 2015/05/22 22:49:43 style: order
chanli 2015/05/22 23:26:33 json is actually not used. Done.
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 _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'
118 '\\n[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
128 step_log = self._GetGtestResultLog(master_name,
129 builder_name, build_number, step_name)
130
131 failed_test_log = ExtractSignalPipeline._GetReliableTestFailureLog(step_log)
132 self.assertEqual(expected_failure_log, failed_test_log)
133
134 def testGetSignalFromStepLog(self):
135 master_name = 'm'
136 builder_name = 'b'
137 build_number = 123
138 step_name = 'abc_test'
139
140 # Mock both stdiolog and step log to test whether Findit will
141 # go to step log first when both logs exist.
142 step_log_url = buildbot.CreateStdioLogUrl(
143 master_name, builder_name, build_number, step_name)
144 with self.mock_urlfetch() as urlfetch:
145 urlfetch.register_handler(step_log_url, self.ABC_TEST_FAILURE_LOG)
146
147 def _MockGetGtestResultLog(master_name,
148 builder_name, build_number, step_name):
149 return self._GetGtestResultLog(master_name,
150 builder_name, build_number, step_name)
151 self.mock(buildbot, 'GetGtestResultLog', _MockGetGtestResultLog)
152
153 pipeline = ExtractSignalPipeline(self.FAILURE_INFO)
154 signals = pipeline.run(self.FAILURE_INFO)
155
156 step = WfStep.Get(master_name, builder_name, build_number, step_name)
157
158 expected_files = {
159 'a/b/u2s1.cc': [567],
160 'a/b/u3s2.cc': [110]
161 }
162
163 self.assertIsNotNone(step)
164 self.assertIsNotNone(step.log_data)
165 self.assertEqual(expected_files, signals['abc_test']['files'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698