Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 """This module is to handle manual triage of analysis result. | 5 """This module is to handle manual triage of analysis result. |
| 6 | 6 |
| 7 This handler will flag the analysis result as correct or incorrect. | 7 This handler will flag the analysis result as correct or incorrect. |
| 8 TODO: work on an automatic or semi-automatic way to triage analysis result. | 8 TODO: work on an automatic or semi-automatic way to triage analysis result. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import calendar | 11 import calendar |
| 12 from datetime import datetime | 12 from datetime import datetime |
| 13 from datetime import timedelta | 13 from datetime import timedelta |
| 14 | 14 |
| 15 from google.appengine.api import users | 15 from google.appengine.api import users |
| 16 from google.appengine.ext import ndb | 16 from google.appengine.ext import ndb |
| 17 import pytz.gae | 17 import pytz.gae |
| 18 | 18 |
| 19 from common.base_handler import BaseHandler | 19 from common.base_handler import BaseHandler |
| 20 from common.base_handler import Permission | 20 from common.base_handler import Permission |
| 21 from model import result_status | 21 from model import result_status |
| 22 from model.wf_analysis import WfAnalysis | 22 from model.wf_analysis import WfAnalysis |
| 23 from waterfall import buildbot | 23 from waterfall import buildbot |
| 24 from waterfall import try_job_util | 24 from waterfall.try_job_util import GetSuspectedCLsWithFailures |
| 25 | 25 |
| 26 MATCHING_ANALYSIS_HOURS_AGO_START = 24 | 26 MATCHING_ANALYSIS_HOURS_AGO_START = 24 |
| 27 MATCHING_ANALYSIS_HOURS_AGO_END = 24 | 27 MATCHING_ANALYSIS_HOURS_AGO_END = 24 |
| 28 MATCHING_ANALYSIS_END_BOUND_TIME_ZONE = 'US/Pacific' | 28 MATCHING_ANALYSIS_END_BOUND_TIME_ZONE = 'US/Pacific' |
| 29 | 29 |
| 30 | 30 |
| 31 def _DoAnalysesMatch(analysis_1, analysis_2): | 31 def _DoAnalysesMatch(analysis_1, analysis_2): |
| 32 """Checks if two analyses match. | 32 """Checks if two analyses match. |
| 33 | 33 |
| 34 Args: | 34 Args: |
| 35 analysis_1: The first analysis to compare. | 35 analysis_1: The first analysis to compare. |
| 36 analysis_2: The second analysis to compare. | 36 analysis_2: The second analysis to compare. |
| 37 | 37 |
| 38 Returns: | 38 Returns: |
| 39 True if the two analyses' sorted potential culprit lists match, otherwise | 39 True if the two analyses' sorted suspected CLs with failures lists match, |
| 40 False. | 40 otherwise False. |
| 41 """ | 41 """ |
| 42 | 42 |
| 43 # Get list of potential culprit tuples. | 43 # Get list of suspected CLs with failures. |
| 44 potential_culprit_tuple_list_1 = ( | 44 suspected_cls_with_failures_1 = GetSuspectedCLsWithFailures(analysis_1.result) |
|
chanli
2016/08/01 19:43:49
This seems not correct. For try_job_util.GetSuspec
| |
| 45 try_job_util.GenPotentialCulpritTupleList(analysis_1.result)) | 45 suspected_cls_with_failures_2 = GetSuspectedCLsWithFailures(analysis_2.result) |
| 46 potential_culprit_tuple_list_2 = ( | |
| 47 try_job_util.GenPotentialCulpritTupleList(analysis_2.result)) | |
| 48 | 46 |
| 49 # Both analyses must have non-empty potential culprit lists. | 47 # Both analyses must have non-empty suspected CLs with failures lists. |
| 50 if not potential_culprit_tuple_list_1 or not potential_culprit_tuple_list_2: | 48 if not suspected_cls_with_failures_1 or not suspected_cls_with_failures_2: |
| 51 return False | 49 return False |
| 52 | 50 |
| 53 # Both analyses must have matching potential culprit lists. | 51 # Both analyses must have matching suspected CLs with failures lists. |
| 54 return (sorted(potential_culprit_tuple_list_1) == | 52 return (sorted(suspected_cls_with_failures_1) == |
| 55 sorted(potential_culprit_tuple_list_2)) | 53 sorted(suspected_cls_with_failures_2)) |
| 56 | 54 |
| 57 | 55 |
| 58 def _AppendTriageHistoryRecord( | 56 def _AppendTriageHistoryRecord( |
| 59 analysis, is_correct, user_name, is_duplicate=False): | 57 analysis, is_correct, user_name, is_duplicate=False): |
| 60 """Appends a triage history record to the given analysis. | 58 """Appends a triage history record to the given analysis. |
| 61 | 59 |
| 62 Args: | 60 Args: |
| 63 analysis: The analysis to which to append the history record. | 61 analysis: The analysis to which to append the history record. |
| 64 is_correct: True if the history record should indicate a correct judgement, | 62 is_correct: True if the history record should indicate a correct judgement, |
| 65 otherwise False. | 63 otherwise False. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 # already logged in. | 207 # already logged in. |
| 210 user_name = users.get_current_user().email().split('@')[0] | 208 user_name = users.get_current_user().email().split('@')[0] |
| 211 success, original_analysis = _UpdateAnalysisResultStatus( | 209 success, original_analysis = _UpdateAnalysisResultStatus( |
| 212 master_name, builder_name, build_number, is_correct, user_name) | 210 master_name, builder_name, build_number, is_correct, user_name) |
| 213 num_duplicate_analyses = 0 | 211 num_duplicate_analyses = 0 |
| 214 if success: | 212 if success: |
| 215 num_duplicate_analyses = _TriageAndCountDuplicateResults( | 213 num_duplicate_analyses = _TriageAndCountDuplicateResults( |
| 216 original_analysis, is_correct, user_name) | 214 original_analysis, is_correct, user_name) |
| 217 return {'data': {'success': success, | 215 return {'data': {'success': success, |
| 218 'num_duplicate_analyses': num_duplicate_analyses}} | 216 'num_duplicate_analyses': num_duplicate_analyses}} |
| OLD | NEW |