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

Unified Diff: appengine/findit/handlers/swarming_task.py

Issue 1797093002: [Findit] Fix bug when display try job result for non-swarming step. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: . Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/handlers/handlers_util.py ('k') | appengine/findit/handlers/test/handlers_util_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/handlers/swarming_task.py
diff --git a/appengine/findit/handlers/swarming_task.py b/appengine/findit/handlers/swarming_task.py
index d158349e660e67881466bd8e03c374798504a0be..601e789ac1c73b60d8f40b829f8a1bb9f1038b35 100644
--- a/appengine/findit/handlers/swarming_task.py
+++ b/appengine/findit/handlers/swarming_task.py
@@ -2,105 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from collections import defaultdict
-
from base_handler import BaseHandler
from base_handler import Permission
-from model import wf_analysis_status
-from model.wf_analysis import WfAnalysis
-from model.wf_swarming_task import WfSwarmingTask
+from handlers import handlers_util
from waterfall import buildbot
-from waterfall import waterfall_config
-
-
-def _GenerateSwarmingTasksData(master_name, builder_name, build_number):
- """Collects info for all related swarming tasks.
-
- Returns: A dict as below:
- {
- 'step1': {
- 'swarming_tasks': [
- {
- 'status': 'Completed',
- 'task_id': 'task1',
- 'task_url': (
- 'https://chromium-swarm.appspot.com/user/task/task1')
- },
- {
- 'status': 'Completed',
- 'task_id': 'task0',
- 'task_url': (
- 'https://chromium-swarm.appspot.com/user/task/task0')
- }
- ],
- 'tests': {
- 'test1': {
- 'status': 'Completed',
- 'task_id': 'task0',
- 'task_url': (
- 'https://chromium-swarm.appspot.com/user/task/task0')
- },
- 'test2': {
- 'status': 'Completed',
- 'task_id': 'task1',
- 'task_url': (
- 'https://chromium-swarm.appspot.com/user/task/task1')
- }
- }
- },
- 'step2': {
- 'swarming_tasks': [
- {
- 'status': 'Pending'
- }
- ],
- 'tests': {
- 'test1': {
- 'status': 'Pending'
- }
- }
- }
- }
- """
- tasks_info = defaultdict(dict)
-
- analysis = WfAnalysis.Get(master_name, builder_name, build_number)
- if not analysis:
- return tasks_info
-
- failure_result_map = analysis.failure_result_map
- if failure_result_map:
- for step_name, failure in failure_result_map.iteritems():
- if isinstance(failure, dict):
- # Only trigger swarming task for swarming test failures.
- key_test_map = defaultdict(list)
- for test_name, first_failure_key in failure.iteritems():
- key_test_map[first_failure_key].append(test_name)
-
- tasks_info[step_name]['swarming_tasks'] = []
- tasks_info[step_name]['tests'] = defaultdict(dict)
- step_tasks_info = tasks_info[step_name]['swarming_tasks']
- tests = tasks_info[step_name]['tests']
- for key in key_test_map:
- referred_build_keys = key.split('/')
- task = WfSwarmingTask.Get(*referred_build_keys, step_name=step_name)
- if not task:
- continue
- task_info = {
- 'status': wf_analysis_status.SWARMING_STATUS_TO_DESCRIPTION.get(
- task.status)
- }
- if task.task_id:
- task_info['task_id'] = task.task_id
- task_info['task_url'] = 'https://%s/user/task/%s' % (
- waterfall_config.GetSwarmingSettings()['server_host'],
- task.task_id)
-
- step_tasks_info.append(task_info)
- for test_name in key_test_map[key]:
- tests[test_name] = task_info
- return tasks_info
class SwarmingTask(BaseHandler):
PERMISSION_LEVEL = Permission.ANYONE
@@ -113,7 +19,7 @@ class SwarmingTask(BaseHandler):
if not build_keys: # pragma: no cover
return {'data': {}}
- data = _GenerateSwarmingTasksData(*build_keys)
+ data = handlers_util.GenerateSwarmingTasksData(*build_keys)
return {'data': data}
def HandlePost(self): # pragma: no cover
« no previous file with comments | « appengine/findit/handlers/handlers_util.py ('k') | appengine/findit/handlers/test/handlers_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698