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

Side by Side Diff: dashboard/dashboard/pinpoint/handlers/quest_generator.py

Issue 2998283002: [pinpoint] Add GTest support to quest_generator. (Closed)
Patch Set: Rebase Created 3 years, 3 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 | « no previous file | dashboard/dashboard/pinpoint/handlers/quest_generator_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 import json 5 import json
6 6
7 from dashboard.pinpoint.models import quest as quest_module 7 from dashboard.pinpoint.models import quest as quest_module
8 8
9 9
10 _DEFAULT_REPEAT_COUNT = 20 10 _DEFAULT_REPEAT_COUNT = 20
(...skipping 11 matching lines...) Expand all
22 GenerateQuests uses the request parameters to infer what types of Quests the 22 GenerateQuests uses the request parameters to infer what types of Quests the
23 user wants to run, and creates a list of Quests with the given configuration. 23 user wants to run, and creates a list of Quests with the given configuration.
24 24
25 Arguments: 25 Arguments:
26 request: A WebOb/webapp2 Request object. 26 request: A WebOb/webapp2 Request object.
27 27
28 Returns: 28 Returns:
29 A tuple of (arguments, quests), where arguments is a dict containing the 29 A tuple of (arguments, quests), where arguments is a dict containing the
30 request arguments that were used, and quests is a list of Quests. 30 request arguments that were used, and quests is a list of Quests.
31 """ 31 """
32 target = request.get('target')
33 if target in ('telemetry_perf_tests', 'telemetry_perf_webview_tests'):
34 quest_functions = (_FindIsolate, _TelemetryRunTest, _ReadChartJsonValue)
35 else:
36 quest_functions = (_FindIsolate, _GTestRunTest, _ReadGraphJsonValue)
37
32 arguments = {} 38 arguments = {}
33 quests = [] 39 quests = []
34 40 for quest_function in quest_functions:
35 quest_arguments, quest = _FindIsolateQuest(request) 41 quest_arguments, quest = quest_function(request)
36 arguments.update(quest_arguments) 42 if not quest:
37 quests.append(quest) 43 return arguments, quests
38
39 dimensions = request.get('dimensions')
40 if not dimensions:
41 return arguments, quests
42 dimensions = json.loads(dimensions)
43 arguments['dimensions'] = json.dumps(dimensions)
44
45 if arguments['target'] in ('telemetry_perf_tests',
46 'telemetry_perf_webview_tests'):
47 quest_arguments, quest = _TelemetryRunTestQuest(request, dimensions)
48 arguments.update(quest_arguments) 44 arguments.update(quest_arguments)
49 quests.append(quest) 45 quests.append(quest)
50 46
51 metric = request.get('metric')
52 if not metric:
53 return arguments, quests
54 arguments['metric'] = metric
55
56 quests.append(quest_module.ReadChartJsonValue(metric, request.get('story')))
57 else:
58 raise NotImplementedError()
59
60 return arguments, quests 47 return arguments, quests
61 48
62 49
63 def _FindIsolateQuest(request): 50 def _FindIsolate(request):
64 arguments = {} 51 arguments = {}
65 52
66 configuration = request.get('configuration') 53 configuration = request.get('configuration')
67 if not configuration: 54 if not configuration:
68 raise TypeError('Missing "configuration" argument.') 55 raise TypeError('Missing "configuration" argument.')
69 arguments['configuration'] = configuration 56 arguments['configuration'] = configuration
70 57
71 target = request.get('target') 58 target = request.get('target')
72 if not target: 59 if not target:
73 raise TypeError('Missing "target" argument.') 60 raise TypeError('Missing "target" argument.')
74 arguments['target'] = target 61 arguments['target'] = target
75 62
76 return arguments, quest_module.FindIsolate(configuration, target) 63 return arguments, quest_module.FindIsolate(configuration, target)
77 64
78 65
79 def _TelemetryRunTestQuest(request, dimensions): 66 def _TelemetryRunTest(request):
80 arguments = {} 67 arguments = {}
81 swarming_extra_args = [] 68 swarming_extra_args = []
82 69
70 dimensions = request.get('dimensions')
71 if not dimensions:
72 return {}, None
73 dimensions = json.loads(dimensions)
74 arguments['dimensions'] = json.dumps(dimensions)
75
83 benchmark = request.get('benchmark') 76 benchmark = request.get('benchmark')
84 if not benchmark: 77 if not benchmark:
85 raise TypeError('Missing "benchmark" argument.') 78 raise TypeError('Missing "benchmark" argument.')
86 arguments['benchmark'] = benchmark 79 arguments['benchmark'] = benchmark
87 swarming_extra_args.append(benchmark) 80 swarming_extra_args.append(benchmark)
88 81
89 story = request.get('story') 82 story = request.get('story')
90 if story: 83 if story:
91 arguments['story'] = story 84 arguments['story'] = story
92 swarming_extra_args += ('--story-filter', story) 85 swarming_extra_args += ('--story-filter', story)
93 86
94 repeat_count = request.get('repeat_count') 87 repeat_count = request.get('repeat_count')
95 if repeat_count: 88 if repeat_count:
96 arguments['repeat_count'] = repeat_count 89 arguments['repeat_count'] = repeat_count
97 else: 90 else:
98 repeat_count = '20' 91 repeat_count = str(_DEFAULT_REPEAT_COUNT)
99 swarming_extra_args += ('--pageset-repeat', repeat_count) 92 swarming_extra_args += ('--pageset-repeat', repeat_count)
100 93
101 browser = request.get('browser') 94 browser = request.get('browser')
102 if not browser: 95 if not browser:
103 raise TypeError('Missing "browser" argument.') 96 raise TypeError('Missing "browser" argument.')
104 arguments['browser'] = browser 97 arguments['browser'] = browser
105 swarming_extra_args += ('--browser', browser) 98 swarming_extra_args += ('--browser', browser)
106 99
107 swarming_extra_args += ('-v', '--upload-results', 100 swarming_extra_args += ('-v', '--upload-results',
108 '--output-format', 'chartjson') 101 '--output-format', 'chartjson')
109 swarming_extra_args += _SWARMING_EXTRA_ARGS 102 swarming_extra_args += _SWARMING_EXTRA_ARGS
110 103
111 return arguments, quest_module.RunTest(dimensions, swarming_extra_args) 104 return arguments, quest_module.RunTest(dimensions, swarming_extra_args)
105
106
107 def _GTestRunTest(request):
108 arguments = {}
109 swarming_extra_args = []
110
111 dimensions = request.get('dimensions')
112 if not dimensions:
113 return {}, None
114 dimensions = json.loads(dimensions)
115 arguments['dimensions'] = json.dumps(dimensions)
116
117 test = request.get('test')
118 if test:
119 arguments['test'] = test
120 swarming_extra_args += ('--gtest_filter', test)
121
122 repeat_count = request.get('repeat_count')
123 if repeat_count:
124 arguments['repeat_count'] = repeat_count
125 else:
126 repeat_count = str(_DEFAULT_REPEAT_COUNT)
127 swarming_extra_args += ('--gtest_repeat', repeat_count)
128
129 swarming_extra_args += _SWARMING_EXTRA_ARGS
130
131 return arguments, quest_module.RunTest(dimensions, swarming_extra_args)
132
133
134 def _ReadChartJsonValue(request):
135 arguments = {}
136
137 metric = request.get('metric')
138 if not metric:
139 return {}, None
140 arguments['metric'] = metric
141
142 story = request.get('story')
143 if story:
144 arguments['story'] = story
145
146 return arguments, quest_module.ReadChartJsonValue(metric, story)
147
148
149 def _ReadGraphJsonValue(request):
150 arguments = {}
151
152 chart = request.get('chart')
153 trace = request.get('trace')
154 if not (chart or trace):
155 return {}, None
156 if chart and not trace:
157 raise TypeError('"chart" specified but no "trace" given.')
158 if trace and not chart:
159 raise TypeError('"trace" specified but no "chart" given.')
160 arguments['chart'] = chart
161 arguments['trace'] = trace
162
163 return arguments, quest_module.ReadGraphJsonValue(chart, trace)
OLDNEW
« no previous file with comments | « no previous file | dashboard/dashboard/pinpoint/handlers/quest_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698