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

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