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

Side by Side Diff: tools/perf/core/trybot_command_unittest.py

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

Powered by Google App Engine
This is Rietveld 408576698