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

Side by Side Diff: chrome/test/functional/perf.py

Issue 10834239: Configuration file for Chrome perf and endure tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Configuration work for both perf.py and perf_endure.py Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Basic pyauto performance tests. 6 """Basic pyauto performance tests.
7 7
8 For tests that need to be run for multiple iterations (e.g., so that average 8 For tests that need to be run for multiple iterations (e.g., so that average
9 and standard deviation values can be reported), the default number of iterations 9 and standard deviation values can be reported), the default number of iterations
10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. 10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|.
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 self._num_iterations, elapsed_time) 590 self._num_iterations, elapsed_time)
591 self.assertTrue(self._timeout_count <= self._max_timeout_count, 591 self.assertTrue(self._timeout_count <= self._max_timeout_count,
592 msg='Test exceeded automation timeout threshold.') 592 msg='Test exceeded automation timeout threshold.')
593 self.assertEqual(1 + num_tabs, self.GetTabCount(), 593 self.assertEqual(1 + num_tabs, self.GetTabCount(),
594 msg='Did not open %d new tab(s).' % num_tabs) 594 msg='Did not open %d new tab(s).' % num_tabs)
595 for _ in range(num_tabs): 595 for _ in range(num_tabs):
596 self.CloseTab(tab_index=1) 596 self.CloseTab(tab_index=1)
597 597
598 self._PrintSummaryResults(description, timings, 'milliseconds', graph_name) 598 self._PrintSummaryResults(description, timings, 'milliseconds', graph_name)
599 599
600 def _GetConfig(self):
fdeng1 2012/08/11 00:11:27 I just moved the changes to perf.py so that the cr
dennis_jeffrey 2012/08/15 01:21:17 Good, now we can let the user change the login cre
601 """Load endure configuration file."""
dennis_jeffrey 2012/08/15 01:21:17 'endure' --> 'perf test'
dennis_jeffrey 2012/08/15 01:21:17 Add a "Returns:" section to this docstring to ment
fdeng1 2012/08/16 17:42:49 Done.
fdeng1 2012/08/16 17:42:49 Done.
602 config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg')
603 config = {'google_account_url': 'https://accounts.google.com/',
604 'gmail_url': 'https://www.gmail.com',
605 'plus_url': 'http://plus.google.com',
606 'docs_url': 'http://docs.google.com'}
607 if os.path.exists(config_file):
608 try:
609 config.update(pyauto.PyUITest.EvalDataFrom(config_file))
dennis_jeffrey 2012/08/15 01:21:17 If you address my comment from the .cfg file that
fdeng1 2012/08/16 17:42:49 Done.
610 except SyntaxError:
611 logging.info('Could not read %s', config_file)
dennis_jeffrey 2012/08/15 01:21:17 maybe you can also log the text that comes along w
fdeng1 2012/08/16 17:42:49 Done.
612 return config
613
600 def _LoginToGoogleAccount(self, account_key='test_google_account'): 614 def _LoginToGoogleAccount(self, account_key='test_google_account'):
601 """Logs in to a test Google account. 615 """Logs in to a test Google account.
602 616
617 Try to use the url and credential specified in perf.cfg.
618 If it fails to load valid information, try to login via public
619 google account url with credential in
620 src/data/pyauto_private/private_tests_info.txt.
dennis_jeffrey 2012/08/15 01:21:17 We can shorten this description to something like
fdeng1 2012/08/16 17:42:49 Done.
621
603 Args: 622 Args:
604 account_key: The string key associated with the test account login 623 account_key: The string key in private_tests_info.txt which is associated
605 credentials to use. 624 with the test account login credentials to use. It will only
625 be used when fail to load credential from perf.cfg
626
627 Raises:
628 RuntimeError: if could not get credential information.
606 """ 629 """
607 creds = self.GetPrivateInfo()[account_key] 630 config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg')
608 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) 631 config = self._GetConfig()
632 google_account_url = config.get('google_account_url')
633 username = config.get('username')
634 password = config.get('password')
635 if not username or not password:
636 private_file = os.path.join(pyauto.PyUITest.DataDir(), 'pyauto_private',
637 'private_tests_info.txt')
638 if os.path.exists(private_file):
639 google_account_url = 'https://accounts.google.com/'
640 creds = self.GetPrivateInfo()[account_key]
641 username = creds['username']
642 password = creds['password']
643 logging.info(
644 'Google account credential not defined in %s, using %s',
645 config_file, private_file)
646 else:
647 message = \
648 'Please sepecify credential information in %s.\n' \
649 'Format:\n\t{\n' \
650 '\t "username": "my_username",\n' \
651 '\t "password": "my_password",\n' \
652 '\t "google_account_url": "https://my-google-account-server/",\n' \
653 '\t "gmail_url: "https://my-gmail-server",\n' \
654 '\t "plus_url": "https://my-plus-server",\n' \
655 '\t "docs_url": "https://my-docs-server",\n\t}\n' \
656 % config_file
657 raise RuntimeError('Could not get credential information.\n' + message)
658 else:
dennis_jeffrey 2012/08/15 01:21:17 I think it would be simpler to re-arrange the logi
fdeng1 2012/08/16 17:42:49 Done.
659 logging.info(
660 'Using google account credential from %s',
661 os.path.join(os.path.dirname(__file__), 'perf.cfg'))
662 test_utils.GoogleAccountsLogin(
663 self, username, password, url=google_account_url)
609 self.NavigateToURL('about:blank') # Clear the existing tab. 664 self.NavigateToURL('about:blank') # Clear the existing tab.
610 665
611 def _GetCPUUsage(self): 666 def _GetCPUUsage(self):
612 """Returns machine's CPU usage. 667 """Returns machine's CPU usage.
613 668
614 This function uses /proc/stat to identify CPU usage, and therefore works 669 This function uses /proc/stat to identify CPU usage, and therefore works
615 only on Linux/ChromeOS. 670 only on Linux/ChromeOS.
616 671
617 Returns: 672 Returns:
618 A dictionary with 'user', 'nice', 'system' and 'idle' values. 673 A dictionary with 'user', 'nice', 'system' and 'idle' values.
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 """Identifies the port number to which the server is currently bound. 2667 """Identifies the port number to which the server is currently bound.
2613 2668
2614 Returns: 2669 Returns:
2615 The numeric port number to which the server is currently bound. 2670 The numeric port number to which the server is currently bound.
2616 """ 2671 """
2617 return self._server.server_address[1] 2672 return self._server.server_address[1]
2618 2673
2619 2674
2620 if __name__ == '__main__': 2675 if __name__ == '__main__':
2621 pyauto_functional.Main() 2676 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698