| OLD | NEW |
| 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from dashboard.pinpoint.handlers import quest_generator | 7 from dashboard.pinpoint.handlers import quest_generator |
| 8 from dashboard.pinpoint.models import quest | 8 from dashboard.pinpoint.models import quest |
| 9 | 9 |
| 10 | 10 |
| 11 _MIN_RUN_TEST_ARGUMENTS = [ | 11 _MIN_TELEMETRY_RUN_TEST_ARGUMENTS = [ |
| 12 'speedometer', '--pageset-repeat', '20', '--browser', 'release', | 12 'speedometer', '--pageset-repeat', '20', '--browser', 'release', |
| 13 '-v', '--upload-results', '--output-format', 'chartjson', | 13 '-v', '--upload-results', '--output-format', 'chartjson', |
| 14 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', | 14 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 15 '--isolated-script-test-chartjson-output', | 15 '--isolated-script-test-chartjson-output', |
| 16 '${ISOLATED_OUTDIR}/chartjson-output.json', | 16 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 17 ] | 17 ] |
| 18 | 18 |
| 19 | 19 |
| 20 _ALL_RUN_TEST_ARGUMENTS = [ | 20 _ALL_TELEMETRY_RUN_TEST_ARGUMENTS = [ |
| 21 'speedometer', '--story-filter', 'http://www.fifa.com/', | 21 'speedometer', '--story-filter', 'http://www.fifa.com/', |
| 22 '--pageset-repeat', '50', '--browser', 'release', | 22 '--pageset-repeat', '50', '--browser', 'release', |
| 23 '-v', '--upload-results', '--output-format', 'chartjson', | 23 '-v', '--upload-results', '--output-format', 'chartjson', |
| 24 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', | 24 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 25 '--isolated-script-test-chartjson-output', | 25 '--isolated-script-test-chartjson-output', |
| 26 '${ISOLATED_OUTDIR}/chartjson-output.json', | 26 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 27 ] | 27 ] |
| 28 | 28 |
| 29 | 29 |
| 30 _MIN_GTEST_RUN_TEST_ARGUMENTS = [ |
| 31 '--gtest_repeat', '20', |
| 32 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 33 '--isolated-script-test-chartjson-output', |
| 34 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 35 ] |
| 36 |
| 37 |
| 38 _ALL_GTEST_RUN_TEST_ARGUMENTS = [ |
| 39 '--gtest_filter', 'test_name', '--gtest_repeat', '50', |
| 40 '--isolated-script-test-output', '${ISOLATED_OUTDIR}/output.json', |
| 41 '--isolated-script-test-chartjson-output', |
| 42 '${ISOLATED_OUTDIR}/chartjson-output.json', |
| 43 ] |
| 44 |
| 45 |
| 30 class FindIsolateTest(unittest.TestCase): | 46 class FindIsolateTest(unittest.TestCase): |
| 31 | 47 |
| 32 def testMissingArguments(self): | 48 def testMissingArguments(self): |
| 33 arguments = {'target': 'telemetry_perf_tests'} | 49 arguments = {'target': 'telemetry_perf_tests'} |
| 34 # configuration is missing. | 50 # configuration is missing. |
| 35 with self.assertRaises(TypeError): | 51 with self.assertRaises(TypeError): |
| 36 quest_generator.GenerateQuests(arguments) | 52 quest_generator.GenerateQuests(arguments) |
| 37 | 53 |
| 38 arguments = {'configuration': 'chromium-rel-mac11-pro'} | 54 arguments = {'configuration': 'chromium-rel-mac11-pro'} |
| 39 # target is missing. | 55 # target is missing. |
| 40 with self.assertRaises(TypeError): | 56 with self.assertRaises(TypeError): |
| 41 quest_generator.GenerateQuests(arguments) | 57 quest_generator.GenerateQuests(arguments) |
| 42 | 58 |
| 43 def testAllArguments(self): | 59 def testAllArguments(self): |
| 44 arguments = { | 60 arguments = { |
| 45 'configuration': 'chromium-rel-mac11-pro', | 61 'configuration': 'chromium-rel-mac11-pro', |
| 46 'target': 'telemetry_perf_tests', | 62 'target': 'telemetry_perf_tests', |
| 47 } | 63 } |
| 48 expected_quests = [ | 64 expected_quests = [ |
| 49 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), | 65 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 50 ] | 66 ] |
| 51 self.assertEqual(quest_generator.GenerateQuests(arguments), | 67 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 52 (arguments, expected_quests)) | 68 (arguments, expected_quests)) |
| 53 | 69 |
| 54 | 70 |
| 55 class TelemetryRunTestQuest(unittest.TestCase): | 71 class TelemetryRunTest(unittest.TestCase): |
| 56 | 72 |
| 57 def testMissingArguments(self): | 73 def testMissingArguments(self): |
| 58 arguments = { | 74 arguments = { |
| 59 'configuration': 'chromium-rel-mac11-pro', | 75 'configuration': 'chromium-rel-mac11-pro', |
| 60 'target': 'telemetry_perf_tests', | 76 'target': 'telemetry_perf_tests', |
| 61 'dimensions': '{}', | 77 'dimensions': '{}', |
| 62 # benchmark is missing. | 78 # benchmark is missing. |
| 63 'browser': 'release', | 79 'browser': 'release', |
| 64 } | 80 } |
| 65 with self.assertRaises(TypeError): | 81 with self.assertRaises(TypeError): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 arguments = { | 95 arguments = { |
| 80 'configuration': 'chromium-rel-mac11-pro', | 96 'configuration': 'chromium-rel-mac11-pro', |
| 81 'target': 'telemetry_perf_tests', | 97 'target': 'telemetry_perf_tests', |
| 82 'dimensions': '{}', | 98 'dimensions': '{}', |
| 83 'benchmark': 'speedometer', | 99 'benchmark': 'speedometer', |
| 84 'browser': 'release', | 100 'browser': 'release', |
| 85 } | 101 } |
| 86 | 102 |
| 87 expected_quests = [ | 103 expected_quests = [ |
| 88 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), | 104 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 89 quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), | 105 quest.RunTest({}, _MIN_TELEMETRY_RUN_TEST_ARGUMENTS), |
| 90 ] | 106 ] |
| 91 self.assertEqual(quest_generator.GenerateQuests(arguments), | 107 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 92 (arguments, expected_quests)) | 108 (arguments, expected_quests)) |
| 93 | 109 |
| 94 def testAllArguments(self): | 110 def testAllArguments(self): |
| 95 arguments = { | 111 arguments = { |
| 96 'configuration': 'chromium-rel-mac11-pro', | 112 'configuration': 'chromium-rel-mac11-pro', |
| 97 'target': 'telemetry_perf_tests', | 113 'target': 'telemetry_perf_tests', |
| 98 'dimensions': '{"key": "value"}', | 114 'dimensions': '{"key": "value"}', |
| 99 'benchmark': 'speedometer', | 115 'benchmark': 'speedometer', |
| 100 'browser': 'release', | 116 'browser': 'release', |
| 101 'story': 'http://www.fifa.com/', | 117 'story': 'http://www.fifa.com/', |
| 102 'repeat_count': '50', | 118 'repeat_count': '50', |
| 103 } | 119 } |
| 104 | 120 |
| 105 expected_quests = [ | 121 expected_quests = [ |
| 106 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), | 122 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 107 quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), | 123 quest.RunTest({'key': 'value'}, _ALL_TELEMETRY_RUN_TEST_ARGUMENTS), |
| 108 ] | 124 ] |
| 109 self.assertEqual(quest_generator.GenerateQuests(arguments), | 125 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 110 (arguments, expected_quests)) | 126 (arguments, expected_quests)) |
| 111 | 127 |
| 112 | 128 |
| 113 class ReadChartJsonValueQuest(unittest.TestCase): | 129 class GTestRunTest(unittest.TestCase): |
| 114 | 130 |
| 115 def testMinimumArguments(self): | 131 def testMinimumArguments(self): |
| 116 arguments = { | 132 arguments = { |
| 133 'configuration': 'chromium-rel-mac11-pro', |
| 134 'target': 'net_perftests', |
| 135 'dimensions': '{}', |
| 136 } |
| 137 |
| 138 expected_quests = [ |
| 139 quest.FindIsolate('chromium-rel-mac11-pro', 'net_perftests'), |
| 140 quest.RunTest({}, _MIN_GTEST_RUN_TEST_ARGUMENTS), |
| 141 ] |
| 142 print quest_generator.GenerateQuests(arguments)[1][1]._extra_args |
| 143 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 144 (arguments, expected_quests)) |
| 145 |
| 146 def testAllArguments(self): |
| 147 arguments = { |
| 148 'configuration': 'chromium-rel-mac11-pro', |
| 149 'target': 'net_perftests', |
| 150 'dimensions': '{"key": "value"}', |
| 151 'test': 'test_name', |
| 152 'repeat_count': '50', |
| 153 } |
| 154 |
| 155 expected_quests = [ |
| 156 quest.FindIsolate('chromium-rel-mac11-pro', 'net_perftests'), |
| 157 quest.RunTest({'key': 'value'}, _ALL_GTEST_RUN_TEST_ARGUMENTS), |
| 158 ] |
| 159 print quest_generator.GenerateQuests(arguments)[1][1]._extra_args |
| 160 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 161 (arguments, expected_quests)) |
| 162 |
| 163 |
| 164 class ReadChartJsonValue(unittest.TestCase): |
| 165 |
| 166 def testMinimumArguments(self): |
| 167 arguments = { |
| 117 'configuration': 'chromium-rel-mac11-pro', | 168 'configuration': 'chromium-rel-mac11-pro', |
| 118 'target': 'telemetry_perf_tests', | 169 'target': 'telemetry_perf_tests', |
| 119 'dimensions': '{}', | 170 'dimensions': '{}', |
| 120 'benchmark': 'speedometer', | 171 'benchmark': 'speedometer', |
| 121 'browser': 'release', | 172 'browser': 'release', |
| 122 'metric': 'pcv1-cold@@timeToFirst', | 173 'metric': 'pcv1-cold@@timeToFirst', |
| 123 } | 174 } |
| 124 | 175 |
| 125 expected_quests = [ | 176 expected_quests = [ |
| 126 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), | 177 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 127 quest.RunTest({}, _MIN_RUN_TEST_ARGUMENTS), | 178 quest.RunTest({}, _MIN_TELEMETRY_RUN_TEST_ARGUMENTS), |
| 128 quest.ReadChartJsonValue('pcv1-cold@@timeToFirst', None), | 179 quest.ReadChartJsonValue('pcv1-cold@@timeToFirst', None), |
| 129 ] | 180 ] |
| 130 self.assertEqual(quest_generator.GenerateQuests(arguments), | 181 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 131 (arguments, expected_quests)) | 182 (arguments, expected_quests)) |
| 132 | 183 |
| 133 def testAllArguments(self): | 184 def testAllArguments(self): |
| 134 arguments = { | 185 arguments = { |
| 135 'configuration': 'chromium-rel-mac11-pro', | 186 'configuration': 'chromium-rel-mac11-pro', |
| 136 'target': 'telemetry_perf_tests', | 187 'target': 'telemetry_perf_tests', |
| 137 'dimensions': '{"key": "value"}', | 188 'dimensions': '{"key": "value"}', |
| 138 'benchmark': 'speedometer', | 189 'benchmark': 'speedometer', |
| 139 'browser': 'release', | 190 'browser': 'release', |
| 140 'story': 'http://www.fifa.com/', | 191 'story': 'http://www.fifa.com/', |
| 141 'repeat_count': '50', | 192 'repeat_count': '50', |
| 142 'metric': 'pcv1-cold@@timeTo', | 193 'metric': 'pcv1-cold@@timeTo', |
| 143 } | 194 } |
| 144 | 195 |
| 145 expected_quests = [ | 196 expected_quests = [ |
| 146 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), | 197 quest.FindIsolate('chromium-rel-mac11-pro', 'telemetry_perf_tests'), |
| 147 quest.RunTest({'key': 'value'}, _ALL_RUN_TEST_ARGUMENTS), | 198 quest.RunTest({'key': 'value'}, _ALL_TELEMETRY_RUN_TEST_ARGUMENTS), |
| 148 quest.ReadChartJsonValue('pcv1-cold@@timeTo', 'http://www.fifa.com/'), | 199 quest.ReadChartJsonValue('pcv1-cold@@timeTo', 'http://www.fifa.com/'), |
| 149 ] | 200 ] |
| 150 self.assertEqual(quest_generator.GenerateQuests(arguments), | 201 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 151 (arguments, expected_quests)) | 202 (arguments, expected_quests)) |
| 203 |
| 204 |
| 205 class ReadGraphJsonValue(unittest.TestCase): |
| 206 |
| 207 def testMissingArguments(self): |
| 208 arguments = { |
| 209 'configuration': 'chromium-rel-mac11-pro', |
| 210 'target': 'net_perftests', |
| 211 'dimensions': '{"key": "value"}', |
| 212 'test': 'test_name', |
| 213 'repeat_count': '50', |
| 214 'trace': 'trace_name', |
| 215 } |
| 216 |
| 217 with self.assertRaises(TypeError): |
| 218 quest_generator.GenerateQuests(arguments) |
| 219 |
| 220 arguments = { |
| 221 'configuration': 'chromium-rel-mac11-pro', |
| 222 'target': 'net_perftests', |
| 223 'dimensions': '{"key": "value"}', |
| 224 'test': 'test_name', |
| 225 'repeat_count': '50', |
| 226 'chart': 'chart_name', |
| 227 } |
| 228 |
| 229 with self.assertRaises(TypeError): |
| 230 quest_generator.GenerateQuests(arguments) |
| 231 |
| 232 def testAllArguments(self): |
| 233 arguments = { |
| 234 'configuration': 'chromium-rel-mac11-pro', |
| 235 'target': 'net_perftests', |
| 236 'dimensions': '{"key": "value"}', |
| 237 'test': 'test_name', |
| 238 'repeat_count': '50', |
| 239 'chart': 'chart_name', |
| 240 'trace': 'trace_name', |
| 241 } |
| 242 |
| 243 expected_quests = [ |
| 244 quest.FindIsolate('chromium-rel-mac11-pro', 'net_perftests'), |
| 245 quest.RunTest({'key': 'value'}, _ALL_GTEST_RUN_TEST_ARGUMENTS), |
| 246 quest.ReadGraphJsonValue('chart_name', 'trace_name'), |
| 247 ] |
| 248 self.assertEqual(quest_generator.GenerateQuests(arguments), |
| 249 (arguments, expected_quests)) |
| OLD | NEW |