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

Side by Side Diff: appengine/findit/waterfall/process_swarming_task_result_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 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
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 class ProcessSwarmingTaskResultPipeline(BasePipeline): 56 class ProcessSwarmingTaskResultPipeline(BasePipeline):
57 """A pipeline for monitoring swarming task and processing task result. 57 """A pipeline for monitoring swarming task and processing task result.
58 58
59 This pipeline waits for result for a swarming task and processes the result to 59 This pipeline waits for result for a swarming task and processes the result to
60 generate a dict for statuses for each test run. 60 generate a dict for statuses for each test run.
61 """ 61 """
62 62
63 HTTP_CLIENT = HttpClient() 63 HTTP_CLIENT = HttpClient()
64 # Arguments number differs from overridden method - pylint: disable=W0221 64 # Arguments number differs from overridden method - pylint: disable=W0221
65 def run(self, master_name, builder_name, build_number, step_name, task_id): 65 def run(self, master_name, builder_name, build_number, step_name):
66 """ 66 """
67 Args: 67 Args:
68 master_name (str): The master name. 68 master_name (str): The master name.
69 builder_name (str): The builder name. 69 builder_name (str): The builder name.
70 build_number (str): The build number. 70 build_number (str): The build number.
71 step_name (str): The failed test step name. 71 step_name (str): The failed test step name.
72 task_id (str): Id for the swarming task which is triggered by Findit.
73 72
74 Returns: 73 Returns:
75 A dict of lists for reliable/flaky tests. 74 A dict of lists for reliable/flaky tests.
76 """ 75 """
77 76
78 assert task_id
79 timeout_hours = waterfall_config.GetSwarmingSettings().get( 77 timeout_hours = waterfall_config.GetSwarmingSettings().get(
80 'task_timeout_hours') 78 'task_timeout_hours')
81 deadline = time.time() + timeout_hours * 60 * 60 79 deadline = time.time() + timeout_hours * 60 * 60
82 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get( 80 server_query_interval_seconds = waterfall_config.GetSwarmingSettings().get(
83 'server_query_interval_seconds') 81 'server_query_interval_seconds')
84 82
85 task_started = False 83 task_started = False
86 task_completed = False 84 task_completed = False
87 tests_statuses = {} 85 tests_statuses = {}
88 step_name_no_platform = None 86 step_name_no_platform = None
89 87
88 task = WfSwarmingTask.Get(
89 master_name, builder_name, build_number, step_name)
90 task_id = task.task_id
90 while not task_completed: 91 while not task_completed:
91 # Keeps monitoring the swarming task, waits for it to complete. 92 # Keeps monitoring the swarming task, waits for it to complete.
92 data = swarming_util.GetSwarmingTaskResultById( 93 data = swarming_util.GetSwarmingTaskResultById(
93 task_id, self.HTTP_CLIENT) 94 task_id, self.HTTP_CLIENT)
94 task_state = data['state'] 95 task_state = data['state']
95 step_name_no_platform = swarming_util.GetTagValue( 96 step_name_no_platform = swarming_util.GetTagValue(
96 data.get('tags', {}), 'ref_name') 97 data.get('tags', {}), 'ref_name')
97 if task_state not in swarming_util.STATES_RUNNING: 98 if task_state not in swarming_util.STATES_RUNNING:
98 task_completed = True 99 task_completed = True
99 task = WfSwarmingTask.Get( 100 task = WfSwarmingTask.Get(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 # Update swarming task metadate. 139 # Update swarming task metadate.
139 task = WfSwarmingTask.Get( 140 task = WfSwarmingTask.Get(
140 master_name, builder_name, build_number, step_name) 141 master_name, builder_name, build_number, step_name)
141 task.created_time = _ConvertDateTime(data.get('created_ts')) 142 task.created_time = _ConvertDateTime(data.get('created_ts'))
142 task.started_time = _ConvertDateTime(data.get('started_ts')) 143 task.started_time = _ConvertDateTime(data.get('started_ts'))
143 task.completed_time = _ConvertDateTime(data.get('completed_ts')) 144 task.completed_time = _ConvertDateTime(data.get('completed_ts'))
144 task.put() 145 task.put()
145 146
146 return step_name, (step_name_no_platform, task.classified_tests) 147 return step_name, (step_name_no_platform, task.classified_tests)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698