OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import argparse | 4 import argparse |
5 import json | 5 import json |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import StringIO | 8 import StringIO |
9 import sys | 9 import sys |
10 import unittest | 10 import unittest |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 def _MockTryserverJson(self, bots_dict): | 76 def _MockTryserverJson(self, bots_dict): |
77 data = mock.Mock() | 77 data = mock.Mock() |
78 data.read.return_value = json.dumps(bots_dict) | 78 data.read.return_value = json.dumps(bots_dict) |
79 self._urllib2_mock.urlopen.return_value = data | 79 self._urllib2_mock.urlopen.return_value = data |
80 | 80 |
81 def _AssertTryBotExceptions(self, message, func, *args): | 81 def _AssertTryBotExceptions(self, message, func, *args): |
82 with self.assertRaises(trybot_command.TrybotError) as e: | 82 with self.assertRaises(trybot_command.TrybotError) as e: |
83 func(*args) | 83 func(*args) |
84 self.assertIn(message, e.exception.message) | 84 self.assertIn(message, e.exception.message) |
85 | 85 |
86 def _SetupTrybotCommand(self, try_json_dict, trybot): | 86 def _SetupTrybotCommand( |
| 87 self, try_json_dict, trybot, benchmark_name='sunspider', |
| 88 repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None): |
87 self._MockTryserverJson(try_json_dict) | 89 self._MockTryserverJson(try_json_dict) |
88 command = trybot_command.Trybot() | 90 command = trybot_command.Trybot() |
89 command._InitializeBuilderNames(trybot) | 91 command._InitializeBuilderNames(trybot) |
90 return command | 92 opts = argparse.Namespace( |
| 93 trybot=trybot, benchmark_name=benchmark_name, repo_path=repo_path, |
| 94 deps_revision=deps_revision) |
91 | 95 |
92 def _GetConfigForTrybot(self, name, platform, extra_benchmark_args=None): | 96 return command, opts |
| 97 |
| 98 def _GetConfigForTrybot(self, name, platform, extra_benchmark_args=None, |
| 99 repo_path=trybot_command.CHROMIUM_SRC_PATH, |
| 100 deps_revision=None): |
93 bot = '%s_perf_bisect' % name.replace('', '').replace('-', '_') | 101 bot = '%s_perf_bisect' % name.replace('', '').replace('-', '_') |
94 command = self._SetupTrybotCommand({bot: 'stuff'}, name) | 102 command, options = self._SetupTrybotCommand( |
95 options = argparse.Namespace(trybot=name, benchmark_name='sunspider') | 103 {bot: 'stuff'}, name, repo_path=repo_path, deps_revision=deps_revision) |
96 extra_benchmark_args = extra_benchmark_args or [] | 104 extra_benchmark_args = extra_benchmark_args or [] |
97 arguments = [options.benchmark_name] + extra_benchmark_args | 105 arguments = [options.benchmark_name] + extra_benchmark_args |
98 cfg = command._GetPerfConfig(platform, arguments) | 106 cfg = command._GetPerfConfig(platform, arguments) |
99 | 107 |
100 return cfg, command | 108 return cfg, command |
101 | 109 |
102 def _ExpectedGitTryTestArgs(self, test_name, browser, target_arch='ia32'): | 110 def _ExpectedGitTryTestArgs(self, test_name, browser, target_arch='ia32'): |
103 return ('perf_try_config={' | 111 return ('perf_try_config={' |
104 '"repeat_count": "1", "command": "src/tools/perf/run_benchmark ' | 112 '"repeat_count": "1", "command": "src/tools/perf/run_benchmark ' |
105 '--browser=%s %s --verbose", "max_time_minutes": "120", ' | 113 '--browser=%s %s --verbose", "max_time_minutes": "120", ' |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 }) | 278 }) |
271 command = trybot_command.Trybot() | 279 command = trybot_command.Trybot() |
272 command._InitializeBuilderNames('all-linux') | 280 command._InitializeBuilderNames('all-linux') |
273 self.assertEquals( | 281 self.assertEquals( |
274 ['linux'], | 282 ['linux'], |
275 sorted(command._builder_names)) | 283 sorted(command._builder_names)) |
276 self.assertEquals( | 284 self.assertEquals( |
277 ['linux_perf_bisect'], | 285 ['linux_perf_bisect'], |
278 sorted(command._builder_names.get('linux'))) | 286 sorted(command._builder_names.get('linux'))) |
279 | 287 |
| 288 @mock.patch('core.trybot_command.os.path.abspath', |
| 289 mock.MagicMock(return_value='/dummy/path')) |
| 290 @mock.patch('core.trybot_command.os.path.exists', |
| 291 mock.MagicMock(return_value=False)) |
| 292 def testRepoPathExists(self): |
| 293 command, options = self._SetupTrybotCommand( |
| 294 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='/dummy/path') |
| 295 command.Run(options) |
| 296 self.assertEquals(( |
| 297 '(ERROR) Perf Try Job: Repository path "/dummy/path" does not exist, ' |
| 298 'please check the value of <repo_path> argument.'), |
| 299 sys.stdout.getvalue().strip()) |
| 300 |
280 def testNoGit(self): | 301 def testNoGit(self): |
281 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 302 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 303 'linux') |
282 self._ExpectProcesses(( | 304 self._ExpectProcesses(( |
283 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 305 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
284 (128, None, None)), | 306 (128, None, None)), |
285 )) | 307 )) |
286 self._AssertTryBotExceptions( | 308 self._AssertTryBotExceptions( |
287 ('%s is not a git repository, must be in a git repository to send ' | 309 ('%s is not a git repository, must be in a git repository to send ' |
288 'changes to trybots.' % os.getcwd()), | 310 'changes to trybots.' % os.getcwd()), |
289 command._GetRepoAndBranchName, | 311 command._GetRepoAndBranchName, |
290 trybot_command.CHROMIUM_SRC_PATH | 312 options.repo_path |
291 ) | 313 ) |
292 | 314 |
293 def testDettachedBranch(self): | 315 def testDettachedBranch(self): |
294 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 316 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 317 'linux') |
295 self._ExpectProcesses(( | 318 self._ExpectProcesses(( |
296 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 319 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
297 (0, '/root/path_to/repo/src\nHEAD\n', None)), | 320 (0, '/root/path_to/repo/src\nHEAD\n', None)), |
298 )) | 321 )) |
299 self._AssertTryBotExceptions( | 322 self._AssertTryBotExceptions( |
300 'Not on a valid branch, looks like branch is dettached. [branch:HEAD]', | 323 'Not on a valid branch, looks like branch is dettached. [branch:HEAD]', |
301 command._GetRepoAndBranchName, | 324 command._GetRepoAndBranchName, |
302 trybot_command.CHROMIUM_SRC_PATH | 325 options.repo_path |
303 ) | 326 ) |
304 | 327 |
305 def testDirtyTree(self): | 328 def testDirtyTree(self): |
306 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 329 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 330 'linux') |
307 self._ExpectProcesses(( | 331 self._ExpectProcesses(( |
308 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 332 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
309 (0, '/root/path_to/repo/src\nbr\n', None)), | 333 (0, '/root/path_to/repo/src\nbr\n', None)), |
310 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), | 334 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
311 (['git', 'diff-index', 'HEAD'], (0, 'dirty tree', None)), | 335 (['git', 'diff-index', 'HEAD'], (0, 'dirty tree', None)), |
312 )) | 336 )) |
313 self._AssertTryBotExceptions( | 337 self._AssertTryBotExceptions( |
314 'Cannot send a try job with a dirty tree.', | 338 'Cannot send a try job with a dirty tree.', |
315 command._GetRepoAndBranchName, | 339 command._GetRepoAndBranchName, |
316 trybot_command.CHROMIUM_SRC_PATH | 340 options.repo_path |
317 ) | 341 ) |
318 | 342 |
319 def testNoLocalCommits(self): | 343 def testNoLocalCommits(self): |
320 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 344 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 345 'linux') |
321 self._ExpectProcesses(( | 346 self._ExpectProcesses(( |
322 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 347 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
323 (0, '/root/path_to/repo/src\nbr\n', None)), | 348 (0, '/root/path_to/repo/src\nbr\n', None)), |
324 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), | 349 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
325 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 350 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
326 (['git', 'footers', 'HEAD'], (0, 'CL footers', None)), | 351 (['git', 'footers', 'HEAD'], (0, 'CL footers', None)), |
327 )) | 352 )) |
328 self._AssertTryBotExceptions( | 353 self._AssertTryBotExceptions( |
329 'No local changes found in %s repository.' % | 354 'No local changes found in %s repository.' % options.repo_path, |
330 trybot_command.CHROMIUM_SRC_PATH, | |
331 command._GetRepoAndBranchName, | 355 command._GetRepoAndBranchName, |
332 trybot_command.CHROMIUM_SRC_PATH | 356 options.repo_path |
333 ) | 357 ) |
334 | 358 |
335 def testGetRepoAndBranchName(self): | 359 def testGetRepoAndBranchName(self): |
336 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 360 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 361 'linux') |
337 self._ExpectProcesses(( | 362 self._ExpectProcesses(( |
338 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 363 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
339 (0, '/root/path_to/repo/src\nbr\n', None)), | 364 (0, '/root/path_to/repo/src\nbr\n', None)), |
340 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), | 365 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
341 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 366 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
342 (['git', 'footers', 'HEAD'], (0, '', None)), | 367 (['git', 'footers', 'HEAD'], (0, '', None)), |
343 )) | 368 )) |
344 self.assertEquals( | 369 self.assertEquals( |
345 command._GetRepoAndBranchName( | 370 command._GetRepoAndBranchName(options.repo_path), ('src', 'br')) |
346 trybot_command.CHROMIUM_SRC_PATH), ('src', 'br')) | |
347 | 371 |
348 def testErrorOnBrowserArgSpecified(self): | 372 def testErrorOnBrowserArgSpecified(self): |
349 parser = trybot_command.Trybot.CreateParser() | 373 parser = trybot_command.Trybot.CreateParser() |
350 options, extra_args = parser.parse_known_args( | 374 options, extra_args = parser.parse_known_args( |
351 ['sunspider', '--trybot=android-all', '--browser=mac']) | 375 ['sunspider', '--trybot=android-all', '--browser=mac']) |
352 with self.assertRaises(SystemExit): | 376 with self.assertRaises(SystemExit): |
353 trybot_command.Trybot.ProcessCommandLineArgs( | 377 trybot_command.Trybot.ProcessCommandLineArgs( |
354 parser, options, extra_args, None) | 378 parser, options, extra_args, None) |
355 | 379 |
356 def testConfigAndroid(self): | 380 def testConfigAndroid(self): |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 436 |
413 def testUnsupportedTrybot(self): | 437 def testUnsupportedTrybot(self): |
414 self.assertRaises( | 438 self.assertRaises( |
415 trybot_command.TrybotError, | 439 trybot_command.TrybotError, |
416 trybot_command._GetBuilderNames, | 440 trybot_command._GetBuilderNames, |
417 'arms-nvidia', | 441 'arms-nvidia', |
418 {'win_perf_bisect': 'stuff'} | 442 {'win_perf_bisect': 'stuff'} |
419 ) | 443 ) |
420 | 444 |
421 def testUploadPatchToRietveldGitCommandFailed(self): | 445 def testUploadPatchToRietveldGitCommandFailed(self): |
422 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 446 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
423 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 447 'linux') |
424 self._ExpectProcesses(( | 448 self._ExpectProcesses(( |
425 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 449 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
426 ('CL for src perf tryjob to run sunspider benchmark on linux ' | 450 ('CL for src perf tryjob to run sunspider benchmark on linux ' |
427 'platform(s)')], | 451 'platform(s)')], |
428 (128, None, None)), | 452 (128, None, None)), |
429 )) | 453 )) |
430 self._AssertTryBotExceptions( | 454 self._AssertTryBotExceptions( |
431 'Could not upload to rietveld for src', | 455 'Could not upload to rietveld for src', |
432 command._UploadPatchToRietveld, | 456 command._UploadPatchToRietveld, |
433 'src', | 457 'src', |
434 options | 458 options |
435 ) | 459 ) |
436 | 460 |
437 def testUploadPatchToRietveldNoURLMatchFound(self): | 461 def testUploadPatchToRietveldNoURLMatchFound(self): |
438 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 462 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
439 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 463 'linux') |
440 self._ExpectProcesses(( | 464 self._ExpectProcesses(( |
441 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 465 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
442 ('CL for src perf tryjob to run sunspider benchmark on linux ' | 466 ('CL for src perf tryjob to run sunspider benchmark on linux ' |
443 'platform(s)')], | 467 'platform(s)')], |
444 (0, 'stuff https://dummy.chromium.org/12345 stuff', None)), | 468 (0, 'stuff https://dummy.chromium.org/12345 stuff', None)), |
445 )) | 469 )) |
446 self._AssertTryBotExceptions( | 470 self._AssertTryBotExceptions( |
447 'Could not upload CL to rietveld for src!', | 471 'Could not upload CL to rietveld for src!', |
448 command._UploadPatchToRietveld, | 472 command._UploadPatchToRietveld, |
449 'src', | 473 'src', |
450 options | 474 options |
451 ) | 475 ) |
452 | 476 |
453 def testUploadPatchToRietveldOnSuccess(self): | 477 def testUploadPatchToRietveldOnSuccess(self): |
454 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 478 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
455 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 479 'linux') |
456 self._ExpectProcesses(( | 480 self._ExpectProcesses(( |
457 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 481 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
458 ('CL for src perf tryjob to run sunspider benchmark on linux ' | 482 ('CL for src perf tryjob to run sunspider benchmark on linux ' |
459 'platform(s)')], | 483 'platform(s)')], |
460 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 484 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
461 )) | 485 )) |
462 self.assertEquals(command._UploadPatchToRietveld('src', options), | 486 self.assertEquals(command._UploadPatchToRietveld('src', options), |
463 'https://codereview.chromium.org/12345') | 487 'https://codereview.chromium.org/12345') |
464 | 488 |
465 def testRunTryJobFailed(self): | 489 def testRunTryJobFailed(self): |
466 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 490 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
467 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 491 command, options = self._SetupTrybotCommand( |
468 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 492 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='path_to_repo/src') |
469 arguments = [options.benchmark_name] + [] | 493 arguments = [options.benchmark_name] + [] |
470 self._ExpectProcesses(( | 494 self._ExpectProcesses(( |
471 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 495 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
472 '-p', test_args, | 496 '-p', test_args, |
473 '-b', | 497 '-b', |
474 'linux_perf_bisect'], (128, None, None)),)) | 498 'linux_perf_bisect'], (128, None, None)),)) |
475 self._AssertTryBotExceptions( | 499 self._AssertTryBotExceptions( |
476 'Could not try CL for linux', | 500 'Could not try CL for linux', |
477 command._RunTryJob, 'linux', arguments) | 501 command._RunTryJob, 'linux', arguments, None) |
| 502 |
| 503 def testRunTryJobWithDepsOverrideFailed(self): |
| 504 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 505 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 506 |
| 507 command, options = self._SetupTrybotCommand( |
| 508 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='path_to_repo/v8', |
| 509 deps_revision='feedbeed') |
| 510 arguments = [options.benchmark_name] + [] |
| 511 self._ExpectProcesses(( |
| 512 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 513 '-p', test_args, |
| 514 '-p', deps_override_arg, |
| 515 '-b', |
| 516 'linux_perf_bisect'], (128, None, None)),)) |
| 517 self._AssertTryBotExceptions( |
| 518 'Could not try CL for linux with DEPS override', |
| 519 command._RunTryJob, 'linux', arguments, {'src/v8': 'feedbeed'}) |
478 | 520 |
479 def testRunTryJobSuccess(self): | 521 def testRunTryJobSuccess(self): |
480 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 522 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
481 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 523 command, options = self._SetupTrybotCommand( |
482 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 524 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='path_to_repo/src') |
483 arguments = [options.benchmark_name] + [] | 525 arguments = [options.benchmark_name] + [] |
484 self._ExpectProcesses(( | 526 self._ExpectProcesses(( |
485 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 527 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
486 '-p', test_args, | 528 '-p', test_args, |
487 '-b', | 529 '-b', |
488 'linux_perf_bisect'], (0, None, None)),)) | 530 'linux_perf_bisect'], (0, '', None)),)) |
489 command._RunTryJob('linux', arguments) | 531 command._RunTryJob('linux', arguments, None) |
490 self.assertEquals('Perf Try job sent to rietveld for linux platform.', | 532 self.assertEquals('Perf Try job sent to rietveld for linux platform.', |
491 sys.stdout.getvalue().strip()) | 533 sys.stdout.getvalue().strip()) |
492 | 534 |
| 535 def testNoUpstream(self): |
| 536 command, _ = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 537 'linux') |
| 538 self._ExpectProcesses(( |
| 539 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 540 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 541 (128, 'None', None,)), |
| 542 )) |
| 543 self._AssertTryBotExceptions( |
| 544 'Failed to get upstream branch name.', |
| 545 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') |
| 546 |
| 547 def testGitConfigBranchRemote(self): |
| 548 command, _ = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 549 'linux') |
| 550 self._ExpectProcesses(( |
| 551 (['git', 'config', 'branch.br.remote'], |
| 552 (128, 'None', None)), |
| 553 )) |
| 554 self._AssertTryBotExceptions( |
| 555 'Failed to get branch.br.remote from git config', |
| 556 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') |
| 557 |
| 558 def testGitConfigBranchRemoteUrl(self): |
| 559 command, _ = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 560 'linux') |
| 561 self._ExpectProcesses(( |
| 562 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 563 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 564 (0, 'br1', None,)), |
| 565 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 566 (['git', 'config', 'remote.origin.url'], (128, 'None', None)), |
| 567 )) |
| 568 self._AssertTryBotExceptions( |
| 569 'Failed to get remote.origin.url from git config', |
| 570 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') |
| 571 |
| 572 def testGetBaseGitHashForRemoteURLMatchFound(self): |
| 573 command, _ = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 574 'linux') |
| 575 self._ExpectProcesses(( |
| 576 (['git', 'config', 'branch.br.remote'], |
| 577 (0, '.', None)), |
| 578 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 579 (0, 'br1', None,)), |
| 580 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 581 (['git', 'config', 'remote.origin.url'], |
| 582 (0, 'http://repo/git/url.git', None)), |
| 583 (['git', 'rev-parse', 'br1@{upstream}'], (0, 'feedbeed', None)), |
| 584 )) |
| 585 self.assertEquals( |
| 586 command._GetBaseGitHashForRepo('br', 'http://repo/git/url.git'), |
| 587 'feedbeed') |
| 588 |
| 589 def testGetBaseGitHashForRemoteUrlNoMatchFound(self): |
| 590 command, _ = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 591 'linux') |
| 592 self._ExpectProcesses(( |
| 593 (['git', 'config', 'branch.br.remote'], |
| 594 (0, '.', None)), |
| 595 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 596 (0, 'br1', None,)), |
| 597 (['git', 'config', 'branch.br1.remote'], |
| 598 (0, 'origin', None)), |
| 599 (['git', 'config', 'remote.origin.url'], |
| 600 (0, 'http://non_maching_repo/git/url.git', None)), |
| 601 (['git', 'rev-parse', 'br1@{upstream}'], |
| 602 (0, 'feedbeed', None)), |
| 603 )) |
| 604 self._AssertTryBotExceptions( |
| 605 ('URL http://non_maching_repo/git/url.git on remote origin is not ' |
| 606 'recognized on branch'), |
| 607 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') |
| 608 |
| 609 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 610 @mock.patch('core.trybot_command.os.path.exists', |
| 611 mock.MagicMock(return_value='True')) |
| 612 @mock.patch('core.trybot_command.os.path.abspath', |
| 613 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH)) |
493 def testAttemptTryjobForCrRepo(self): | 614 def testAttemptTryjobForCrRepo(self): |
494 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 615 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
495 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') | 616 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
496 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') | 617 'linux') |
497 | |
498 self._ExpectProcesses(( | 618 self._ExpectProcesses(( |
499 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 619 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
500 (0, '/root/path_to/repo/src\nbr\n', None)), | 620 (0, '/root/path_to/repo/src\nbr\n', None)), |
501 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), | 621 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
502 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 622 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
503 (['git', 'footers', 'HEAD'], (0, '', None)), | 623 (['git', 'footers', 'HEAD'], (0, '', None)), |
504 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 624 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
505 ('CL for src perf tryjob to run sunspider benchmark on linux ' | 625 ('CL for src perf tryjob to run sunspider benchmark on linux ' |
506 'platform(s)')], | 626 'platform(s)')], |
507 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 627 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
508 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 628 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
509 '-p', test_args, '-b', 'linux_perf_bisect'], (0, None, None)) | 629 '-p', test_args, '-b', 'linux_perf_bisect'], (0, '', None)) |
510 )) | 630 )) |
511 command._AttemptTryjob(trybot_command.CHROMIUM_SRC_PATH, options, []) | 631 command._AttemptTryjob(options, []) |
512 | 632 |
513 output = ('Uploaded try job to rietveld.\n' | 633 output = ('Uploaded try job to rietveld.\n' |
514 'view progress here https://codereview.chromium.org/12345.\n' | 634 'view progress here https://codereview.chromium.org/12345.\n' |
515 '\tRepo Name: src\n' | 635 '\tRepo Name: src\n' |
516 '\tPath: %s\n' | 636 '\tPath: %s\n' |
517 '\tBranch: br\n' | 637 '\tBranch: br\n' |
518 'Perf Try job sent to rietveld for linux platform.') % ( | 638 'Perf Try job sent to rietveld for linux platform.') % ( |
519 trybot_command.CHROMIUM_SRC_PATH) | 639 options.repo_path) |
520 self.assertEquals(output, sys.stdout.getvalue().strip()) | 640 self.assertEquals(output, sys.stdout.getvalue().strip()) |
521 | 641 |
| 642 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 643 @mock.patch('core.trybot_command.os.path.exists', |
| 644 mock.MagicMock(return_value='True')) |
| 645 @mock.patch('core.trybot_command.os.path.abspath', |
| 646 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH)) |
522 def testAttemptTryjobAllForCrRepo(self): | 647 def testAttemptTryjobAllForCrRepo(self): |
523 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') | 648 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') |
524 winx64_config = self._ExpectedGitTryTestArgs( | 649 winx64_config = self._ExpectedGitTryTestArgs( |
525 'sunspider', 'release_x64', 'x64') | 650 'sunspider', 'release_x64', 'x64') |
526 android_config = self._ExpectedGitTryTestArgs( | 651 android_config = self._ExpectedGitTryTestArgs( |
527 'sunspider', 'android-chromium', 'ia32') | 652 'sunspider', 'android-chromium', 'ia32') |
528 | 653 |
529 command = self._SetupTrybotCommand( | 654 command, options = self._SetupTrybotCommand( |
530 {'linux_perf_bisect': 'stuff', | 655 {'linux_perf_bisect': 'stuff', |
531 'win_perf_bisect': 'stuff', | 656 'win_perf_bisect': 'stuff', |
532 'winx64_perf_bisect': 'stuff', | 657 'winx64_perf_bisect': 'stuff', |
533 'android_perf_bisect': 'stuff', | 658 'android_perf_bisect': 'stuff', |
534 'mac_perf_bisect': 'stuff'}, 'all') | 659 'mac_perf_bisect': 'stuff'}, 'all') |
535 options = argparse.Namespace(trybot='all', benchmark_name='sunspider') | |
536 self._ExpectProcesses(( | 660 self._ExpectProcesses(( |
537 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 661 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
538 (0, '/root/path_to/repo/src\nbr\n', None)), | 662 (0, '/root/path_to/repo/src\nbr\n', None)), |
539 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), | 663 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
540 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 664 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
541 (['git', 'footers', 'HEAD'], (0, '', None)), | 665 (['git', 'footers', 'HEAD'], (0, '', None)), |
542 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 666 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
543 ('CL for src perf tryjob to run sunspider benchmark on all ' | 667 ('CL for src perf tryjob to run sunspider benchmark on all ' |
544 'platform(s)')], | 668 'platform(s)')], |
545 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 669 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
546 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 670 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
547 '-p', default_config, '-b', 'win_perf_bisect'], (0, None, None)), | 671 '-p', default_config, '-b', 'win_perf_bisect'], (0, '', None)), |
548 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 672 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
549 '-p', android_config, '-b', 'android_perf_bisect'], (0, None, None)), | 673 '-p', android_config, '-b', 'android_perf_bisect'], (0, '', None)), |
550 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 674 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
551 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, None, None)), | 675 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, '', None)), |
552 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 676 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
553 '-p', default_config, '-b', 'mac_perf_bisect'], (0, None, None)), | 677 '-p', default_config, '-b', 'mac_perf_bisect'], (0, '', None)), |
554 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 678 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
555 '-p', default_config, '-b', 'linux_perf_bisect'], (0, None, None)), | 679 '-p', default_config, '-b', 'linux_perf_bisect'], (0, '', None)), |
556 )) | 680 )) |
557 command._AttemptTryjob(trybot_command.CHROMIUM_SRC_PATH, options, []) | 681 command._AttemptTryjob(options, []) |
558 output = ('Uploaded try job to rietveld.\n' | 682 output = ('Uploaded try job to rietveld.\n' |
559 'view progress here https://codereview.chromium.org/12345.\n' | 683 'view progress here https://codereview.chromium.org/12345.\n' |
560 '\tRepo Name: src\n' | 684 '\tRepo Name: src\n' |
561 '\tPath: %s\n' | 685 '\tPath: %s\n' |
562 '\tBranch: br\n' | 686 '\tBranch: br\n' |
563 'Perf Try job sent to rietveld for win platform.\n' | 687 'Perf Try job sent to rietveld for win platform.\n' |
564 'Perf Try job sent to rietveld for android platform.\n' | 688 'Perf Try job sent to rietveld for android platform.\n' |
565 'Perf Try job sent to rietveld for win-x64 platform.\n' | 689 'Perf Try job sent to rietveld for win-x64 platform.\n' |
566 'Perf Try job sent to rietveld for mac platform.\n' | 690 'Perf Try job sent to rietveld for mac platform.\n' |
567 'Perf Try job sent to rietveld for linux platform.') % ( | 691 'Perf Try job sent to rietveld for linux platform.') % ( |
568 trybot_command.CHROMIUM_SRC_PATH) | 692 options.repo_path) |
| 693 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 694 |
| 695 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 696 @mock.patch('core.trybot_command.os.path.exists', |
| 697 mock.MagicMock(return_value='True')) |
| 698 @mock.patch('core.trybot_command.os.path.abspath', |
| 699 mock.MagicMock(return_value='root/path_to/repo/v8')) |
| 700 def testAttemptTryjobForDepsRepo(self): |
| 701 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 702 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 703 command, options = self._SetupTrybotCommand( |
| 704 {'linux_perf_bisect': 'stuff'}, 'linux', |
| 705 repo_path='root/path_to/repo/v8') |
| 706 self._ExpectProcesses(( |
| 707 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 708 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 709 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 710 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 711 (['git', 'footers', 'HEAD'], (0, '', None)), |
| 712 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 713 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 714 (0, 'br1', None,)), |
| 715 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 716 (['git', 'config', 'remote.origin.url'], |
| 717 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), |
| 718 (['git', 'rev-parse', 'br1@{upstream}'], (0, 'feedbeed', None)), |
| 719 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
| 720 ('CL for v8 perf tryjob to run sunspider benchmark on linux ' |
| 721 'platform(s)')], |
| 722 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 723 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 724 '-p', test_args, '-p', deps_override_arg, |
| 725 '-b', 'linux_perf_bisect'], (0, '', None)) |
| 726 )) |
| 727 command._AttemptTryjob(options, []) |
| 728 |
| 729 output = ('Uploaded try job to rietveld.\n' |
| 730 'view progress here https://codereview.chromium.org/12345.\n' |
| 731 '\tRepo Name: v8\n' |
| 732 '\tPath: root/path_to/repo/v8\n' |
| 733 '\tBranch: br\n' |
| 734 'Perf Try job sent to rietveld for linux platform.') |
| 735 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 736 |
| 737 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 738 @mock.patch('core.trybot_command.os.path.exists', |
| 739 mock.MagicMock(return_value='True')) |
| 740 @mock.patch('core.trybot_command.os.path.abspath', |
| 741 mock.MagicMock(return_value='root/path_to/repo/v8')) |
| 742 def testAttemptTryjobAllForDepsRepo(self): |
| 743 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 744 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 745 winx64_config = self._ExpectedGitTryTestArgs( |
| 746 'sunspider', 'release_x64', 'x64') |
| 747 android_config = self._ExpectedGitTryTestArgs( |
| 748 'sunspider', 'android-chromium', 'ia32') |
| 749 command, options = self._SetupTrybotCommand( |
| 750 {'linux_perf_bisect': 'stuff', |
| 751 'winx64_perf_bisect': 'stuff', |
| 752 'android_perf_bisect': 'stuff'}, |
| 753 'all', repo_path='root/path_to/repo/v8') |
| 754 |
| 755 self._ExpectProcesses(( |
| 756 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 757 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 758 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 759 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 760 (['git', 'footers', 'HEAD'], (0, '', None)), |
| 761 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 762 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 763 (0, 'br1', None,)), |
| 764 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 765 (['git', 'config', 'remote.origin.url'], |
| 766 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), |
| 767 (['git', 'rev-parse', 'br1@{upstream}'], |
| 768 (0, 'feedbeed', None)), |
| 769 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
| 770 ('CL for v8 perf tryjob to run sunspider benchmark on all ' |
| 771 'platform(s)')], |
| 772 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 773 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 774 '-p', android_config, '-p', deps_override_arg, |
| 775 '-b', 'android_perf_bisect'], (0, '', None)), |
| 776 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 777 '-p', winx64_config, '-p', deps_override_arg, |
| 778 '-b', 'winx64_perf_bisect'], (0, '', None)), |
| 779 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 780 '-p', default_config, '-p', deps_override_arg, |
| 781 '-b', 'linux_perf_bisect'], (0, '', None)), |
| 782 )) |
| 783 command._AttemptTryjob(options, []) |
| 784 output = ('Uploaded try job to rietveld.\n' |
| 785 'view progress here https://codereview.chromium.org/12345.\n' |
| 786 '\tRepo Name: v8\n' |
| 787 '\tPath: root/path_to/repo/v8\n' |
| 788 '\tBranch: br\n' |
| 789 'Perf Try job sent to rietveld for android platform.\n' |
| 790 'Perf Try job sent to rietveld for win-x64 platform.\n' |
| 791 'Perf Try job sent to rietveld for linux platform.') |
| 792 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 793 |
| 794 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 795 @mock.patch('core.trybot_command.os.path.exists', |
| 796 mock.MagicMock(return_value='True')) |
| 797 @mock.patch('core.trybot_command.os.path.abspath', |
| 798 mock.MagicMock(return_value='root/path_to/repo/v8')) |
| 799 def testAttemptTryjobWithDepsRevisionArg(self): |
| 800 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 801 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 802 command, options = self._SetupTrybotCommand( |
| 803 {'linux_perf_bisect': 'stuff'}, 'linux', |
| 804 repo_path='root/path_to/repo/v8', deps_revision='feedbeed') |
| 805 self._ExpectProcesses(( |
| 806 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 807 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 808 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 809 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 810 (['git', 'footers', 'HEAD'], (0, '', None)), |
| 811 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', |
| 812 ('CL for v8 perf tryjob to run sunspider benchmark on linux ' |
| 813 'platform(s)')], |
| 814 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 815 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 816 '-p', test_args, '-p', deps_override_arg, |
| 817 '-b', 'linux_perf_bisect'], (0, '', None)) |
| 818 )) |
| 819 command._AttemptTryjob(options, []) |
| 820 |
| 821 output = ('Uploaded try job to rietveld.\n' |
| 822 'view progress here https://codereview.chromium.org/12345.\n' |
| 823 '\tRepo Name: v8\n' |
| 824 '\tPath: root/path_to/repo/v8\n' |
| 825 '\tBranch: br\n' |
| 826 'Perf Try job sent to rietveld for linux platform.') |
569 self.assertEquals(output, sys.stdout.getvalue().strip()) | 827 self.assertEquals(output, sys.stdout.getvalue().strip()) |
570 | 828 |
571 | 829 |
572 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase): | 830 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase): |
573 | 831 |
574 def IsBenchmarkDisabled(self, benchmark_class, trybot_name): | 832 def IsBenchmarkDisabled(self, benchmark_class, trybot_name): |
575 return trybot_command.Trybot.IsBenchmarkDisabledOnTrybotPlatform( | 833 return trybot_command.Trybot.IsBenchmarkDisabledOnTrybotPlatform( |
576 benchmark_class, trybot_name)[0] | 834 benchmark_class, trybot_name)[0] |
577 | 835 |
578 def testBenchmarkIsDisabledAll(self): | 836 def testBenchmarkIsDisabledAll(self): |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 @benchmark.Enabled('win', 'mac') | 868 @benchmark.Enabled('win', 'mac') |
611 class FooBenchmark(benchmark.Benchmark): | 869 class FooBenchmark(benchmark.Benchmark): |
612 pass | 870 pass |
613 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all')) | 871 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all')) |
614 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac')) | 872 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac')) |
615 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati')) | 873 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati')) |
616 | 874 |
617 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5')) | 875 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5')) |
618 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux')) | 876 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux')) |
619 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux')) | 877 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux')) |
OLD | NEW |