Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 from collections import defaultdict | 5 from collections import defaultdict |
| 6 import datetime | 6 import datetime |
| 7 import logging | 7 import logging |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from common.http_client_appengine import HttpClientAppengine as HttpClient | 10 from common.http_client_appengine import HttpClientAppengine as HttpClient |
| 11 from common.pipeline_wrapper import BasePipeline | 11 from common.pipeline_wrapper import BasePipeline |
| 12 from model import analysis_status | 12 from model import analysis_status |
| 13 from model.wf_swarming_task import WfSwarmingTask | 13 from model.wf_swarming_task import WfSwarmingTask |
| 14 from waterfall import swarming_util | 14 from waterfall import swarming_util |
| 15 from waterfall import waterfall_config | 15 from waterfall import waterfall_config |
| 16 | 16 |
| 17 | 17 |
| 18 def _CheckTestsRunStatuses(output_json): | 18 def _CheckTestsRunStatuses(output_json, targeted_tests): |
| 19 """Checks result status for each test run and saves the numbers accordingly. | 19 """Checks result status for each test run and saves the numbers accordingly. |
| 20 | 20 |
| 21 Args: | 21 Args: |
| 22 output_json (dict): A dict of all test results in the swarming task. | 22 output_json (dict): A dict of all test results in the swarming task. |
| 23 targeted_tests (list): A list of targeted tests. | |
| 23 | 24 |
| 24 Returns: | 25 Returns: |
| 25 tests_statuses (dict): A dict of different statuses for each test. | 26 tests_statuses (dict): A dict of different statuses for each test. |
| 26 | 27 |
| 27 Currently for each test, we are saving number of total runs, | 28 Currently for each test, we are saving number of total runs, |
| 28 number of succeeded runs and number of failed runs. | 29 number of succeeded runs and number of failed runs. |
| 29 """ | 30 """ |
| 30 tests_statuses = defaultdict(lambda: defaultdict(int)) | 31 tests_statuses = defaultdict(lambda: defaultdict(int)) |
| 31 if output_json: | 32 if output_json: |
| 32 for iteration in output_json.get('per_iteration_data'): | 33 for iteration in output_json.get('per_iteration_data'): |
| 33 for test_name, tests in iteration.iteritems(): | 34 for test_name, tests in iteration.iteritems(): |
| 35 if test_name not in targeted_tests: | |
|
stgao
2016/06/02 01:31:20
If PRE_A failed on Waterfall and PRE_PRE_A failed
chanli
2016/06/02 22:40:09
In the end we should still say PRE_A failed.
stgao
2016/06/03 06:59:39
OK. The code seems fixed for this now.
| |
| 36 # Some special pseudo tests like PRE_ tests may be added to task, | |
| 37 # should filter them out when check results. | |
| 38 continue | |
| 34 tests_statuses[test_name]['total_run'] += len(tests) | 39 tests_statuses[test_name]['total_run'] += len(tests) |
| 35 for test in tests: | 40 for test in tests: |
| 36 tests_statuses[test_name][test['status']] += 1 | 41 tests_statuses[test_name][test['status']] += 1 |
| 37 | 42 |
| 38 return tests_statuses | 43 return tests_statuses |
| 39 | 44 |
| 40 | 45 |
| 41 def _ConvertDateTime(time_string): | 46 def _ConvertDateTime(time_string): |
| 42 """Convert UTC time string to datetime.datetime.""" | 47 """Convert UTC time string to datetime.datetime.""" |
| 43 # Match the time convertion with swarming.py. | 48 # Match the time convertion with swarming.py. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 55 | 60 |
| 56 class ProcessSwarmingTaskResultPipeline(BasePipeline): | 61 class ProcessSwarmingTaskResultPipeline(BasePipeline): |
| 57 """A pipeline for monitoring swarming task and processing task result. | 62 """A pipeline for monitoring swarming task and processing task result. |
| 58 | 63 |
| 59 This pipeline waits for result for a swarming task and processes the result to | 64 This pipeline waits for result for a swarming task and processes the result to |
| 60 generate a dict for statuses for each test run. | 65 generate a dict for statuses for each test run. |
| 61 """ | 66 """ |
| 62 | 67 |
| 63 HTTP_CLIENT = HttpClient() | 68 HTTP_CLIENT = HttpClient() |
| 64 # Arguments number differs from overridden method - pylint: disable=W0221 | 69 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 65 def run(self, master_name, builder_name, build_number, step_name, task_id): | 70 def run( |
| 71 self, master_name, builder_name, build_number, step_name, task_id, tests): | |
| 66 """ | 72 """ |
| 67 Args: | 73 Args: |
| 68 master_name (str): The master name. | 74 master_name (str): The master name. |
| 69 builder_name (str): The builder name. | 75 builder_name (str): The builder name. |
| 70 build_number (str): The build number. | 76 build_number (str): The build number. |
| 71 step_name (str): The failed test step name. | 77 step_name (str): The failed test step name. |
| 72 task_id (str): Id for the swarming task which is triggered by Findit. | 78 task_id (str): Id for the swarming task which is triggered by Findit. |
| 79 tests (str): A list of test cases, eg: ['suite1.test1', 'suite2.test2']. | |
| 73 | 80 |
| 74 Returns: | 81 Returns: |
| 75 A dict of lists for reliable/flaky tests. | 82 A dict of lists for reliable/flaky tests. |
| 76 """ | 83 """ |
| 77 | 84 |
| 78 assert task_id | 85 assert task_id |
| 79 timeout_hours = waterfall_config.GetSwarmingSettings().get( | 86 timeout_hours = waterfall_config.GetSwarmingSettings().get( |
| 80 'task_timeout_hours') | 87 'task_timeout_hours') |
| 81 deadline = time.time() + timeout_hours * 60 * 60 | 88 deadline = time.time() + timeout_hours * 60 * 60 |
| 82 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get( | 89 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 95 step_name_no_platform = swarming_util.GetTagValue( | 102 step_name_no_platform = swarming_util.GetTagValue( |
| 96 data.get('tags', {}), 'ref_name') | 103 data.get('tags', {}), 'ref_name') |
| 97 if task_state not in swarming_util.STATES_RUNNING: | 104 if task_state not in swarming_util.STATES_RUNNING: |
| 98 task_completed = True | 105 task_completed = True |
| 99 task = WfSwarmingTask.Get( | 106 task = WfSwarmingTask.Get( |
| 100 master_name, builder_name, build_number, step_name) | 107 master_name, builder_name, build_number, step_name) |
| 101 if task_state == swarming_util.STATE_COMPLETED: | 108 if task_state == swarming_util.STATE_COMPLETED: |
| 102 outputs_ref = data.get('outputs_ref') | 109 outputs_ref = data.get('outputs_ref') |
| 103 output_json = swarming_util.GetSwarmingTaskFailureLog( | 110 output_json = swarming_util.GetSwarmingTaskFailureLog( |
| 104 outputs_ref, self.HTTP_CLIENT) | 111 outputs_ref, self.HTTP_CLIENT) |
| 105 tests_statuses = _CheckTestsRunStatuses(output_json) | 112 tests_statuses = _CheckTestsRunStatuses(output_json, tests) |
| 106 | 113 |
| 107 task.status = analysis_status.COMPLETED | 114 task.status = analysis_status.COMPLETED |
| 108 task.tests_statuses = tests_statuses | 115 task.tests_statuses = tests_statuses |
| 109 else: | 116 else: |
| 110 task.status = analysis_status.ERROR | 117 task.status = analysis_status.ERROR |
| 111 logging.error('Swarming task stopped with status: %s' % ( | 118 logging.error('Swarming task stopped with status: %s' % ( |
| 112 task_state)) | 119 task_state)) |
| 113 priority_str = swarming_util.GetTagValue( | 120 priority_str = swarming_util.GetTagValue( |
| 114 data.get('tags', {}), 'priority') | 121 data.get('tags', {}), 'priority') |
| 115 if priority_str: | 122 if priority_str: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 137 | 144 |
| 138 # Update swarming task metadate. | 145 # Update swarming task metadate. |
| 139 task = WfSwarmingTask.Get( | 146 task = WfSwarmingTask.Get( |
| 140 master_name, builder_name, build_number, step_name) | 147 master_name, builder_name, build_number, step_name) |
| 141 task.created_time = _ConvertDateTime(data.get('created_ts')) | 148 task.created_time = _ConvertDateTime(data.get('created_ts')) |
| 142 task.started_time = _ConvertDateTime(data.get('started_ts')) | 149 task.started_time = _ConvertDateTime(data.get('started_ts')) |
| 143 task.completed_time = _ConvertDateTime(data.get('completed_ts')) | 150 task.completed_time = _ConvertDateTime(data.get('completed_ts')) |
| 144 task.put() | 151 task.put() |
| 145 | 152 |
| 146 return step_name, (step_name_no_platform, task.classified_tests) | 153 return step_name, (step_name_no_platform, task.classified_tests) |
| OLD | NEW |