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 unittest |
| 6 |
| 7 from dashboard.pinpoint.handlers import quest_generator |
| 8 from dashboard.pinpoint.models import quest |
| 9 |
| 10 |
| 11 _MIN_RUN_TEST_ARGUMENTS = [ |
| 12 'speedometer', '--pageset-repeat', '20', '--browser', 'release', |
| 13 '-v', '--upload-results', '--output-format', 'chartjson', |
| 14 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 15 '--isolated-script-test-chartjson-output', |
| 16 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 17 ] |
| 18 |
| 19 |
| 20 _ALL_RUN_TEST_ARGUMENTS = [ |
| 21 'speedometer', '--story-filter', 'http://www.fifa.com/', |
| 22 '--pageset-repeat', '50', '--browser', 'release', |
| 23 '-v', '--upload-results', '--output-format', 'chartjson', |
| 24 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 25 '--isolated-script-test-chartjson-output', |
| 26 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 27 ] |
| 28 |
| 29 |
| 30 class FindIsolateTest(unittest.TestCase): |
| 31 |
| 32 def testMissingArguments(self): |
| 33 arguments = {'target': 'telemetry_perf_tests'} |
| 34 # configuration is missing. |
| 35 with self.assertRaises(TypeError): |
| 36 quest_generator.GenerateQuests(arguments) |
| 37 |
| 38 arguments = {'configuration': 'chromium-rel-mac11-pro'} |
| 39 # target is missing. |
| 40 with self.assertRaises(TypeError): |
| 41 quest_generator.GenerateQuests(arguments) |
| 42 |
| 43 def testAllArguments(self): |
| 44 arguments = { |
| 45 'configuration': 'chromium-rel-mac11-pro', |
| 46 'target': 'telemetry_perf_tests', |
| 47 } |
| 48 expected_quests = [ |
| 49 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 50 ] |
| 51 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 52 (arguments, expected_quests)) |
| 53 |
| 54 |
| 55 class TelemetryRunTestQuest(unittest.TestCase): |
| 56 |
| 57 def testMissingArguments(self): |
| 58 arguments = { |
| 59 'configuration': 'chromium-rel-mac11-pro', |
| 60 'target': 'telemetry_perf_tests', |
| 61 'dimensions': '{}', |
| 62 # benchmark is missing. |
| 63 'browser': 'release', |
| 64 } |
| 65 with self.assertRaises(TypeError): |
| 66 quest_generator.GenerateQuests(arguments) |
| 67 |
| 68 arguments = { |
| 69 'configuration': 'chromium-rel-mac11-pro', |
| 70 'target': 'telemetry_perf_tests', |
| 71 'dimensions': '{}', |
| 72 'benchmark': 'speedometer', |
| 73 # browser is missing. |
| 74 } |
| 75 with self.assertRaises(TypeError): |
| 76 quest_generator.GenerateQuests(arguments) |
| 77 |
| 78 def testMinimumArguments(self): |
| 79 arguments = { |
| 80 'configuration': 'chromium-rel-mac11-pro', |
| 81 'target': 'telemetry_perf_tests', |
| 82 'dimensions': '{}', |
| 83 'benchmark': 'speedometer', |
| 84 'browser': 'release', |
| 85 } |
| 86 |
| 87 expected_quests = [ |
| 88 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 89 quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), |
| 90 ] |
| 91 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 92 (arguments, expected_quests)) |
| 93 |
| 94 def testAllArguments(self): |
| 95 arguments = { |
| 96 'configuration': 'chromium-rel-mac11-pro', |
| 97 'target': 'telemetry_perf_tests', |
| 98 'dimensions': '{"key": "value"}', |
| 99 'benchmark': 'speedometer', |
| 100 'browser': 'release', |
| 101 'story': 'http://www.fifa.com/', |
| 102 'repeat_count': '50', |
| 103 } |
| 104 |
| 105 expected_quests = [ |
| 106 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 107 quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), |
| 108 ] |
| 109 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 110 (arguments, expected_quests)) |
| 111 |
| 112 |
| 113 class ReadChartJsonValueQuest(unittest.TestCase): |
| 114 |
| 115 def testMinimumArguments(self): |
| 116 arguments = { |
| 117 'configuration': 'chromium-rel-mac11-pro', |
| 118 'target': 'telemetry_perf_tests', |
| 119 'dimensions': '{}', |
| 120 'benchmark': 'speedometer', |
| 121 'browser': 'release', |
| 122 'metric': 'pcv1-cold@@timeToFirst', |
| 123 } |
| 124 |
| 125 expected_quests = [ |
| 126 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 127 quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), |
| 128 quest.ReadChartJsonValue('pcv1-cold@@timeToFirst', None), |
| 129 ] |
| 130 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 131 (arguments, expected_quests)) |
| 132 |
| 133 def testAllArguments(self): |
| 134 arguments = { |
| 135 'configuration': 'chromium-rel-mac11-pro', |
| 136 'target': 'telemetry_perf_tests', |
| 137 'dimensions': '{"key": "value"}', |
| 138 'benchmark': 'speedometer', |
| 139 'browser': 'release', |
| 140 'story': 'http://www.fifa.com/', |
| 141 'repeat_count': '50', |
| 142 'metric': 'pcv1-cold@@timeTo', |
| 143 } |
| 144 |
| 145 expected_quests = [ |
| 146 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 147 quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), |
| 148 quest.ReadChartJsonValue('pcv1-cold@@timeTo', 'http://www.fifa.com/'), |
| 149 ] |
| 150 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 151 (arguments, expected_quests)) |
OLD | NEW |