OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import json |
| 6 |
| 7 from dashboard.pinpoint.models import quest as quest_module |
| 8 |
| 9 |
| 10 _DEFAULT_REPEAT_COUNT = 20 |
| 11 |
| 12 _SWARMING_EXTRA_ARGS = ( |
| 13 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 14 '--isolated-script-test-chartjson-output', |
| 15 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 16 ) |
| 17 |
| 18 |
| 19 def GenerateQuests(request): |
| 20 """Generate a list of Quests from a request. |
| 21 |
| 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. |
| 24 |
| 25 Arguments: |
| 26 request: A WebOb/webapp2 Request object. |
| 27 |
| 28 Returns: |
| 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. |
| 31 """ |
| 32 arguments = {} |
| 33 quests = [] |
| 34 |
| 35 quest_arguments, quest = _FindIsolateQuest(request) |
| 36 arguments.update(quest_arguments) |
| 37 quests.append(quest) |
| 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) |
| 49 quests.append(quest) |
| 50 |
| 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 |
| 61 |
| 62 |
| 63 def _FindIsolateQuest(request): |
| 64 arguments = {} |
| 65 |
| 66 configuration = request.get('configuration') |
| 67 if not configuration: |
| 68 raise TypeError('Missing "configuration" argument.') |
| 69 arguments['configuration'] = configuration |
| 70 |
| 71 target = request.get('target') |
| 72 if not target: |
| 73 raise TypeError('Missing "target" argument.') |
| 74 arguments['target'] = target |
| 75 |
| 76 return arguments, quest_module.FindIsolate(configuration, target) |
| 77 |
| 78 |
| 79 def _TelemetryRunTestQuest(request, dimensions): |
| 80 arguments = {} |
| 81 swarming_extra_args = [] |
| 82 |
| 83 benchmark = request.get('benchmark') |
| 84 if not benchmark: |
| 85 raise TypeError('Missing "benchmark" argument.') |
| 86 arguments['benchmark'] = benchmark |
| 87 swarming_extra_args.append(benchmark) |
| 88 |
| 89 story = request.get('story') |
| 90 if story: |
| 91 arguments['story'] = story |
| 92 swarming_extra_args += ('--story-filter', story) |
| 93 |
| 94 repeat_count = request.get('repeat_count') |
| 95 if repeat_count: |
| 96 arguments['repeat_count'] = repeat_count |
| 97 else: |
| 98 repeat_count = '20' |
| 99 swarming_extra_args += ('--pageset-repeat', repeat_count) |
| 100 |
| 101 browser = request.get('browser') |
| 102 if not browser: |
| 103 raise TypeError('Missing "browser" argument.') |
| 104 arguments['browser'] = browser |
| 105 swarming_extra_args += ('--browser', browser) |
| 106 |
| 107 swarming_extra_args += ('-v', '--upload-results', |
| 108 '--output-format', 'chartjson') |
| 109 swarming_extra_args += _SWARMING_EXTRA_ARGS |
| 110 |
| 111 return arguments, quest_module.RunTest(dimensions, swarming_extra_args) |
OLD | NEW |