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

Side by Side Diff: appengine/findit/waterfall/detect_first_failure_pipeline.py

Issue 2139093002: [Findit] Trigger swarming tasks after detech_first_faliure_pipeline (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: . Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 base64 5 import base64
6 import json 6 import json
7 7
8 from common import constants 8 from common import constants
9 from common.http_client_appengine import HttpClientAppengine as HttpClient 9 from common.http_client_appengine import HttpClientAppengine as HttpClient
10 from common.pipeline_wrapper import BasePipeline 10 from common.pipeline_wrapper import BasePipeline
11 from common.pipeline_wrapper import pipeline 11 from common.pipeline_wrapper import pipeline
12 from common.waterfall import failure_type 12 from common.waterfall import failure_type
13 from model.wf_analysis import WfAnalysis 13 from model.wf_analysis import WfAnalysis
14 from model.wf_step import WfStep 14 from model.wf_step import WfStep
15 from waterfall import build_util 15 from waterfall import build_util
16 from waterfall import buildbot 16 from waterfall import buildbot
17 from waterfall import swarming_util 17 from waterfall import swarming_util
18 18
19 19
20 _MAX_BUILDS_TO_CHECK = 20 20 _MAX_BUILDS_TO_CHECK = 20
21 _NON_FAILURE_STATUS = ['SUCCESS', 'SKIPPED', 'UNKNOWN'] 21 _NON_FAILURE_STATUS = ['SUCCESS', 'SKIPPED', 'UNKNOWN']
22 _PRE_TEST_PREFIX = 'PRE_'
23
24
25 def _RemoveAnyPrefixes(test):
lijeffrey 2016/07/12 22:36:27 Nit: should this be renamed to _RemoveAllPrefixes,
chanli 2016/07/12 22:54:56 Done.
26 """Remove prefixes from test names.
27
28 Args:
29 test (str): A test's name, eg: 'suite1.PRE_test1'.
30
31 Returns:
32 base_test (str): A base test name, eg: 'suite1.test1'.
33 """
34 test_name_start = test.find('.') if test.find('.') > -1 else 0
lijeffrey 2016/07/12 22:36:27 I think we can do this with just 1 call to test.fi
chanli 2016/07/12 22:54:56 Good idea. Done
35 if test_name_start == 0:
36 return test
lijeffrey 2016/07/12 22:36:27 nit: 1 empty line after return test
chanli 2016/07/12 22:54:56 Done.
37 test_suite = test[ : test_name_start]
lijeffrey 2016/07/12 22:36:28 nit: is the extra space in 'test[ :' necessary? Sa
chanli 2016/07/12 22:54:56 I honestly don't know... I'll remove them for now.
38 test_name = test[test_name_start + 1 : ]
39 pre_position = test_name.find(_PRE_TEST_PREFIX)
40 while pre_position == 0:
41 test_name = test_name[len(_PRE_TEST_PREFIX):]
42 pre_position = test_name.find(_PRE_TEST_PREFIX)
43 base_test = test_suite + '.' + test_name
lijeffrey 2016/07/12 22:36:28 nit: How about base_test = '%s.%s' % (test_suite,
chanli 2016/07/12 22:54:56 Done.
44 return base_test
22 45
23 46
24 class DetectFirstFailurePipeline(BasePipeline): 47 class DetectFirstFailurePipeline(BasePipeline):
25 """A pipeline to detect first failure of each step. 48 """A pipeline to detect first failure of each step.
26 49
27 TODO(stgao): do test-level detection for gtest. 50 TODO(stgao): do test-level detection for gtest.
28 """ 51 """
29 52
30 def _ExtractBuildInfo(self, master_name, builder_name, build_number): 53 def _ExtractBuildInfo(self, master_name, builder_name, build_number):
31 """Returns a BuildInfo instance for the specified build.""" 54 """Returns a BuildInfo instance for the specified build."""
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 # If a test is skipped, that means it was not run at all. 211 # If a test is skipped, that means it was not run at all.
189 # Treats it as success since the status cannot be determined. 212 # Treats it as success since the status cannot be determined.
190 is_reliable_failure = False 213 is_reliable_failure = False
191 214
192 if is_reliable_failure: 215 if is_reliable_failure:
193 if failed_step: 216 if failed_step:
194 # Adds the test to failed_step. 217 # Adds the test to failed_step.
195 failed_step['tests'][test_name] = { 218 failed_step['tests'][test_name] = {
196 'current_failure': failed_step['current_failure'], 219 'current_failure': failed_step['current_failure'],
197 'first_failure': failed_step['current_failure'], 220 'first_failure': failed_step['current_failure'],
221 'base_test_name': _RemoveAnyPrefixes(test_name)
198 } 222 }
199 if failed_step.get('last_pass'): 223 if failed_step.get('last_pass'):
200 failed_step['tests'][test_name]['last_pass'] = ( 224 failed_step['tests'][test_name]['last_pass'] = (
201 failed_step['last_pass']) 225 failed_step['last_pass'])
202 # Stores the output to the step's log_data later. 226 # Stores the output to the step's log_data later.
203 failed_test_log[test_name] = '' 227 failed_test_log[test_name] = ''
204 for test in iteration[test_name]: 228 for test in iteration[test_name]:
205 failed_test_log[test_name] = self._ConcatenateTestLog( 229 failed_test_log[test_name] = self._ConcatenateTestLog(
206 failed_test_log[test_name], test.get( 230 failed_test_log[test_name], test.get(
207 'output_snippet_base64', '')) 231 'output_snippet_base64', ''))
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 490
467 failure_info['builds'] = builds 491 failure_info['builds'] = builds
468 failure_info['failed_steps'] = failed_steps 492 failure_info['failed_steps'] = failed_steps
469 493
470 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 494 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
471 analysis.not_passed_steps = build_info.not_passed_steps 495 analysis.not_passed_steps = build_info.not_passed_steps
472 analysis.build_failure_type = build_failure_type 496 analysis.build_failure_type = build_failure_type
473 analysis.put() 497 analysis.put()
474 498
475 return failure_info 499 return failure_info
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698