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

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

Issue 2243673002: [Findit] Added algorithm to analysis (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: gclient sync Created 4 years, 4 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
« no previous file with comments | « appengine/findit/waterfall/flake/test/recursive_flake_pipeline_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
14 from waterfall import swarming_util 13 from waterfall import swarming_util
15 from waterfall import waterfall_config 14 from waterfall import waterfall_config
16 15
17 16
18 class ProcessBaseSwarmingTaskResultPipeline(BasePipeline): 17 class ProcessBaseSwarmingTaskResultPipeline(BasePipeline):
19 """A pipeline for monitoring swarming task and processing task result. 18 """A pipeline for monitoring swarming task and processing task result.
20 19
21 This pipeline waits for result for a swarming task and processes the result to 20 This pipeline waits for result for a swarming task and processes the result to
22 generate a dict for statuses for each test run. 21 generate a dict for statuses for each test run.
23 """ 22 """
24 23
25 HTTP_CLIENT = HttpClient() 24 HTTP_CLIENT = HttpClient()
26 25
27 def _CheckTestsRunStatuses(self, output_json): 26 def _CheckTestsRunStatuses(self, output_json):
28 # Checks result status for each test run and saves the numbers accordingly. 27 # Checks result status for each test run and saves the numbers accordingly.
29 # Should be overridden by subclass. 28 # Should be overridden by subclass.
30 raise NotImplementedError( 29 raise NotImplementedError(
31 '_CheckTestsRunStatuses should be implemented in the child class') 30 '_CheckTestsRunStatuses should be implemented in the child class')
32 31
33 def _ConvertDateTime(self, time_string): 32 def _ConvertDateTime(self, time_string):
34 """Convert UTC time string to datetime.datetime.""" 33 """Convert UTC time string to datetime.datetime."""
35 # Match the time conversion with swarming.py which elides the suffix 34 # Match the time conversion with swarming.py which elides the suffix
36 # when microseconds are 0. 35 # when microseconds are 0.
37 if not time_string: 36 if not time_string:
38 return None 37 return None
39 for fmt in ('%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S'): 38 for fmt in ('%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S'):
40 try: 39 try:
41 return datetime.datetime.strptime(time_string, fmt) 40 return datetime.datetime.strptime(time_string, fmt)
42 except ValueError: 41 except ValueError:
43 pass 42 pass
44 raise ValueError('Failed to parse %s' % time_string) # pragma: no cover 43 raise ValueError('Failed to parse %s' % time_string) # pragma: no cover
45 44
46 def _GetSwarmingTask(self): 45 def _GetSwarmingTask(self):
47 # Get the appropriate kind of Swarming Task (Wf or Flake). 46 # Get the appropriate kind of Swarming Task (Wf or Flake).
48 # Should be overwritten by subclass. 47 # Should be overwritten by subclass.
49 raise NotImplementedError( 48 raise NotImplementedError(
50 '_GetSwarmingTask should be implemented in the child class') 49 '_GetSwarmingTask should be implemented in the child class')
51 50
52 def _GetArgs(self): 51 def _GetArgs(self):
53 # Return list of arguments to call _CheckTestsRunStatuses with - output_json 52 # Return list of arguments to call _CheckTestsRunStatuses with - output_json
54 # Should be overwritten by subclass. 53 # Should be overwritten by subclass.
55 raise NotImplementedError( 54 raise NotImplementedError(
56 '_GetArgs should be implemented in the child class') 55 '_GetArgs should be implemented in the child class')
57 56
58 # Arguments number differs from overridden method - pylint: disable=W0221 57 # Arguments number differs from overridden method - pylint: disable=W0221
59 def run(self, master_name, builder_name, build_number, 58 def run(self, master_name, builder_name, build_number,
60 step_name, task_id, *args): #pragma: no cover. 59 step_name, task_id, *args): # pragma: no cover.
61 """ 60 """
62 Args: 61 Args:
63 master_name (str): The master name. 62 master_name (str): The master name.
64 builder_name (str): The builder name. 63 builder_name (str): The builder name.
65 build_number (str): The build number. 64 build_number (str): The build number.
66 step_name (str): The failed test step name. 65 step_name (str): The failed test step name.
67 task_id (str): Id for the swarming task which is triggered by Findit. 66 task_id (str): Id for the swarming task which is triggered by Findit.
68 67
69 Returns: 68 Returns:
70 A dict of lists for reliable/flaky tests. 69 A dict of lists for reliable/flaky tests.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 logging.error('Swarming task timed out after %d hours.' % timeout_hours) 124 logging.error('Swarming task timed out after %d hours.' % timeout_hours)
126 break # Stops the loop and return. 125 break # Stops the loop and return.
127 # Update swarming task metadate. 126 # Update swarming task metadate.
128 task = self._GetSwarmingTask(*call_args) 127 task = self._GetSwarmingTask(*call_args)
129 task.created_time = self._ConvertDateTime(data.get('created_ts')) 128 task.created_time = self._ConvertDateTime(data.get('created_ts'))
130 task.started_time = self._ConvertDateTime(data.get('started_ts')) 129 task.started_time = self._ConvertDateTime(data.get('started_ts'))
131 task.completed_time = self._ConvertDateTime(data.get('completed_ts')) 130 task.completed_time = self._ConvertDateTime(data.get('completed_ts'))
132 task.put() 131 task.put()
133 132
134 return step_name, step_name_no_platform 133 return step_name, step_name_no_platform
OLDNEW
« no previous file with comments | « appengine/findit/waterfall/flake/test/recursive_flake_pipeline_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698