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

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
« no previous file with comments | « tools/perf/core/trybot_command.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 exist, '
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)
sullivan 2016/09/09 02:42:46 These 3 lines are copy-pasted through the whole fi
prasadv 2016/09/09 23:42:35 Done.
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',
sullivan 2016/09/09 02:42:46 Just curious if it's possible to give a more speci
prasadv 2016/09/09 23:42:35 Done.
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
620 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock())
621 @mock.patch('core.trybot_command.os.path.exists',
622 mock.MagicMock(return_value='True'))
623 @mock.patch('core.trybot_command.os.path.abspath',
624 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH))
493 def testAttemptTryjobForCrRepo(self): 625 def testAttemptTryjobForCrRepo(self):
494 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') 626 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release')
495 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux') 627 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux')
496 options = argparse.Namespace(trybot='linux', benchmark_name='sunspider') 628 options = argparse.Namespace(
629 trybot='linux', benchmark_name='sunspider',
630 repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None)
497 631
498 self._ExpectProcesses(( 632 self._ExpectProcesses((
499 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], 633 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'],
500 (0, '/root/path_to/repo/src\nbr\n', None)), 634 (0, '/root/path_to/repo/src\nbr\n', None)),
501 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), 635 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)),
502 (['git', 'diff-index', 'HEAD'], (0, '', None)), 636 (['git', 'diff-index', 'HEAD'], (0, '', None)),
503 (['git', 'footers', 'HEAD'], (0, '', None)), 637 (['git', 'footers', 'HEAD'], (0, '', None)),
504 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 638 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m',
505 ('CL for src perf tryjob to run sunspider benchmark on linux ' 639 ('CL for src perf tryjob to run sunspider benchmark on linux '
506 'platform(s)')], 640 'platform(s)')],
507 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), 641 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)),
508 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 642 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
509 '-p', test_args, '-b', 'linux_perf_bisect'], (0, None, None)) 643 '-p', test_args, '-b', 'linux_perf_bisect'], (0, '', None))
510 )) 644 ))
511 command._AttemptTryjob(trybot_command.CHROMIUM_SRC_PATH, options, []) 645 command._AttemptTryjob(options, [])
512 646
513 output = ('Uploaded try job to rietveld.\n' 647 output = ('Uploaded try job to rietveld.\n'
514 'view progress here https://codereview.chromium.org/12345.\n' 648 'view progress here https://codereview.chromium.org/12345.\n'
515 '\tRepo Name: src\n' 649 '\tRepo Name: src\n'
516 '\tPath: %s\n' 650 '\tPath: %s\n'
517 '\tBranch: br\n' 651 '\tBranch: br\n'
518 'Perf Try job sent to rietveld for linux platform.') % ( 652 'Perf Try job sent to rietveld for linux platform.') % (
519 trybot_command.CHROMIUM_SRC_PATH) 653 options.repo_path)
520 self.assertEquals(output, sys.stdout.getvalue().strip()) 654 self.assertEquals(output, sys.stdout.getvalue().strip())
521 655
656 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock())
657 @mock.patch('core.trybot_command.os.path.exists',
658 mock.MagicMock(return_value='True'))
659 @mock.patch('core.trybot_command.os.path.abspath',
660 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH))
522 def testAttemptTryjobAllForCrRepo(self): 661 def testAttemptTryjobAllForCrRepo(self):
523 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') 662 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release')
524 winx64_config = self._ExpectedGitTryTestArgs( 663 winx64_config = self._ExpectedGitTryTestArgs(
525 'sunspider', 'release_x64', 'x64') 664 'sunspider', 'release_x64', 'x64')
526 android_config = self._ExpectedGitTryTestArgs( 665 android_config = self._ExpectedGitTryTestArgs(
527 'sunspider', 'android-chromium', 'ia32') 666 'sunspider', 'android-chromium', 'ia32')
528 667
529 command = self._SetupTrybotCommand( 668 command = self._SetupTrybotCommand(
530 {'linux_perf_bisect': 'stuff', 669 {'linux_perf_bisect': 'stuff',
531 'win_perf_bisect': 'stuff', 670 'win_perf_bisect': 'stuff',
532 'winx64_perf_bisect': 'stuff', 671 'winx64_perf_bisect': 'stuff',
533 'android_perf_bisect': 'stuff', 672 'android_perf_bisect': 'stuff',
534 'mac_perf_bisect': 'stuff'}, 'all') 673 'mac_perf_bisect': 'stuff'}, 'all')
535 options = argparse.Namespace(trybot='all', benchmark_name='sunspider') 674 options = argparse.Namespace(
675 trybot='all', benchmark_name='sunspider',
676 repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None)
536 self._ExpectProcesses(( 677 self._ExpectProcesses((
537 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], 678 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'],
538 (0, '/root/path_to/repo/src\nbr\n', None)), 679 (0, '/root/path_to/repo/src\nbr\n', None)),
539 (['git', 'update-index', '--refresh', '-q'], (0, None, None,)), 680 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)),
540 (['git', 'diff-index', 'HEAD'], (0, '', None)), 681 (['git', 'diff-index', 'HEAD'], (0, '', None)),
541 (['git', 'footers', 'HEAD'], (0, '', None)), 682 (['git', 'footers', 'HEAD'], (0, '', None)),
542 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 683 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m',
543 ('CL for src perf tryjob to run sunspider benchmark on all ' 684 ('CL for src perf tryjob to run sunspider benchmark on all '
544 'platform(s)')], 685 'platform(s)')],
545 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), 686 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)),
546 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 687 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
547 '-p', default_config, '-b', 'win_perf_bisect'], (0, None, None)), 688 '-p', default_config, '-b', 'win_perf_bisect'], (0, '', None)),
548 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 689 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
549 '-p', android_config, '-b', 'android_perf_bisect'], (0, None, None)), 690 '-p', android_config, '-b', 'android_perf_bisect'], (0, '', None)),
550 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 691 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
551 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, None, None)), 692 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, '', None)),
552 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 693 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
553 '-p', default_config, '-b', 'mac_perf_bisect'], (0, None, None)), 694 '-p', default_config, '-b', 'mac_perf_bisect'], (0, '', None)),
554 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', 695 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
555 '-p', default_config, '-b', 'linux_perf_bisect'], (0, None, None)), 696 '-p', default_config, '-b', 'linux_perf_bisect'], (0, '', None)),
556 )) 697 ))
557 command._AttemptTryjob(trybot_command.CHROMIUM_SRC_PATH, options, []) 698 command._AttemptTryjob(options, [])
558 output = ('Uploaded try job to rietveld.\n' 699 output = ('Uploaded try job to rietveld.\n'
559 'view progress here https://codereview.chromium.org/12345.\n' 700 'view progress here https://codereview.chromium.org/12345.\n'
560 '\tRepo Name: src\n' 701 '\tRepo Name: src\n'
561 '\tPath: %s\n' 702 '\tPath: %s\n'
562 '\tBranch: br\n' 703 '\tBranch: br\n'
563 'Perf Try job sent to rietveld for win platform.\n' 704 'Perf Try job sent to rietveld for win platform.\n'
564 'Perf Try job sent to rietveld for android platform.\n' 705 'Perf Try job sent to rietveld for android platform.\n'
565 'Perf Try job sent to rietveld for win-x64 platform.\n' 706 'Perf Try job sent to rietveld for win-x64 platform.\n'
566 'Perf Try job sent to rietveld for mac platform.\n' 707 'Perf Try job sent to rietveld for mac platform.\n'
567 'Perf Try job sent to rietveld for linux platform.') % ( 708 'Perf Try job sent to rietveld for linux platform.') % (
568 trybot_command.CHROMIUM_SRC_PATH) 709 options.repo_path)
710 self.assertEquals(output, sys.stdout.getvalue().strip())
711
712 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock())
713 @mock.patch('core.trybot_command.os.path.exists',
714 mock.MagicMock(return_value='True'))
715 @mock.patch('core.trybot_command.os.path.abspath',
716 mock.MagicMock(return_value='root/path_to/repo/v8'))
717 def testAttemptTryjobForDepsRepo(self):
718 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release')
719 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}'
720 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux')
721 options = argparse.Namespace(
722 trybot='linux', benchmark_name='sunspider',
723 repo_path='root/path_to/repo/v8', deps_revision=None)
724
725 self._ExpectProcesses((
726 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'],
727 (0, 'root/path_to/repo/v8\nbr\n', None)),
728 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)),
729 (['git', 'diff-index', 'HEAD'], (0, '', None)),
730 (['git', 'footers', 'HEAD'], (0, '', None)),
731 (['git', 'config', 'branch.br.remote'], (0, '.', None)),
732 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'],
733 (0, 'br1', None,)),
734 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)),
735 (['git', 'config', 'remote.origin.url'],
736 (0, 'https://chromium.googlesource.com/v8/v8.git', None)),
737 (['git', 'rev-parse', 'br1@{upstream}'], (0, 'feedbeed', None)),
738 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m',
739 ('CL for v8 perf tryjob to run sunspider benchmark on linux '
740 'platform(s)')],
741 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)),
742 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
743 '-p', test_args, '-p', deps_override_arg,
744 '-b', 'linux_perf_bisect'], (0, '', None))
745 ))
746 command._AttemptTryjob(options, [])
747
748 output = ('Uploaded try job to rietveld.\n'
749 'view progress here https://codereview.chromium.org/12345.\n'
750 '\tRepo Name: v8\n'
751 '\tPath: root/path_to/repo/v8\n'
752 '\tBranch: br\n'
753 'Perf Try job sent to rietveld for linux platform.')
754 self.assertEquals(output, sys.stdout.getvalue().strip())
755
756 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock())
757 @mock.patch('core.trybot_command.os.path.exists',
758 mock.MagicMock(return_value='True'))
759 @mock.patch('core.trybot_command.os.path.abspath',
760 mock.MagicMock(return_value='root/path_to/repo/v8'))
761 def testAttemptTryjobAllForDepsRepo(self):
762 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release')
763 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}'
764 winx64_config = self._ExpectedGitTryTestArgs(
765 'sunspider', 'release_x64', 'x64')
766 android_config = self._ExpectedGitTryTestArgs(
767 'sunspider', 'android-chromium', 'ia32')
768 command = self._SetupTrybotCommand(
769 {'linux_perf_bisect': 'stuff',
770 'winx64_perf_bisect': 'stuff',
771 'android_perf_bisect': 'stuff'}, 'all')
772 options = argparse.Namespace(
773 trybot='linux', benchmark_name='sunspider',
774 repo_path='root/path_to/repo/v8', deps_revision=None)
775
776 self._ExpectProcesses((
777 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'],
778 (0, 'root/path_to/repo/v8\nbr\n', None)),
779 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)),
780 (['git', 'diff-index', 'HEAD'], (0, '', None)),
781 (['git', 'footers', 'HEAD'], (0, '', None)),
782 (['git', 'config', 'branch.br.remote'], (0, '.', None)),
783 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'],
784 (0, 'br1', None,)),
785 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)),
786 (['git', 'config', 'remote.origin.url'],
787 (0, 'https://chromium.googlesource.com/v8/v8.git', None)),
788 (['git', 'rev-parse', 'br1@{upstream}'],
789 (0, 'feedbeed', None)),
790 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m',
791 ('CL for v8 perf tryjob to run sunspider benchmark on linux '
792 'platform(s)')],
793 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)),
794 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
795 '-p', android_config, '-p', deps_override_arg,
796 '-b', 'android_perf_bisect'], (0, '', None)),
797 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
798 '-p', winx64_config, '-p', deps_override_arg,
799 '-b', 'winx64_perf_bisect'], (0, '', None)),
800 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
801 '-p', default_config, '-p', deps_override_arg,
802 '-b', 'linux_perf_bisect'], (0, '', None)),
803 ))
804 command._AttemptTryjob(options, [])
805 output = ('Uploaded try job to rietveld.\n'
806 'view progress here https://codereview.chromium.org/12345.\n'
807 '\tRepo Name: v8\n'
808 '\tPath: root/path_to/repo/v8\n'
809 '\tBranch: br\n'
810 'Perf Try job sent to rietveld for android platform.\n'
811 'Perf Try job sent to rietveld for win-x64 platform.\n'
812 'Perf Try job sent to rietveld for linux platform.')
813 self.assertEquals(output, sys.stdout.getvalue().strip())
814
815 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock())
816 @mock.patch('core.trybot_command.os.path.exists',
817 mock.MagicMock(return_value='True'))
818 @mock.patch('core.trybot_command.os.path.abspath',
819 mock.MagicMock(return_value='root/path_to/repo/v8'))
820 def testAttemptTryjobWithDepsRevisionArg(self):
821 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release')
822 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}'
823 command = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, 'linux')
824 options = argparse.Namespace(
825 trybot='linux', benchmark_name='sunspider',
826 repo_path='root/path_to/repo/v8', deps_revision='feedbeed')
827
828 self._ExpectProcesses((
829 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'],
830 (0, 'root/path_to/repo/v8\nbr\n', None)),
831 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)),
832 (['git', 'diff-index', 'HEAD'], (0, '', None)),
833 (['git', 'footers', 'HEAD'], (0, '', None)),
834 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m',
835 ('CL for v8 perf tryjob to run sunspider benchmark on linux '
836 'platform(s)')],
837 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)),
838 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf',
839 '-p', test_args, '-p', deps_override_arg,
840 '-b', 'linux_perf_bisect'], (0, '', None))
841 ))
842 command._AttemptTryjob(options, [])
843
844 output = ('Uploaded try job to rietveld.\n'
845 'view progress here https://codereview.chromium.org/12345.\n'
846 '\tRepo Name: v8\n'
847 '\tPath: root/path_to/repo/v8\n'
848 '\tBranch: br\n'
849 'Perf Try job sent to rietveld for linux platform.')
569 self.assertEquals(output, sys.stdout.getvalue().strip()) 850 self.assertEquals(output, sys.stdout.getvalue().strip())
570 851
571 852
572 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase): 853 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase):
573 854
574 def IsBenchmarkDisabled(self, benchmark_class, trybot_name): 855 def IsBenchmarkDisabled(self, benchmark_class, trybot_name):
575 return trybot_command.Trybot.IsBenchmarkDisabledOnTrybotPlatform( 856 return trybot_command.Trybot.IsBenchmarkDisabledOnTrybotPlatform(
576 benchmark_class, trybot_name)[0] 857 benchmark_class, trybot_name)[0]
577 858
578 def testBenchmarkIsDisabledAll(self): 859 def testBenchmarkIsDisabledAll(self):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 @benchmark.Enabled('win', 'mac') 891 @benchmark.Enabled('win', 'mac')
611 class FooBenchmark(benchmark.Benchmark): 892 class FooBenchmark(benchmark.Benchmark):
612 pass 893 pass
613 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all')) 894 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all'))
614 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac')) 895 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac'))
615 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati')) 896 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati'))
616 897
617 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5')) 898 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5'))
618 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux')) 899 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux'))
619 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux')) 900 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux'))
OLDNEW
« no previous file with comments | « tools/perf/core/trybot_command.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698