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

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: Address comments 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):
601 """Load perf test configuration file.
602
603 Returns:
604 A dictionary is returned that represents the config information.
dennis_jeffrey 2012/08/16 18:49:58 remove 'is returned'
fdeng1 2012/08/17 06:39:34 Done.
605 """
606 config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg')
607 config = {'username': None,
608 'password': None,
609 'google_account_url': 'https://accounts.google.com/',
610 'gmail_url': 'https://www.gmail.com',
dennis_jeffrey 2012/08/16 18:49:58 why is the URL here https whereas the two below ar
fdeng1 2012/08/17 06:39:34 Oh, they are meant to be all https. I think in the
dennis_jeffrey 2012/08/17 17:35:44 Previously the tests navigated to the http site, b
fdeng1 2012/08/17 23:19:37 Ok, I just leave them to be https. On 2012/08/17
611 'plus_url': 'http://plus.google.com',
612 'docs_url': 'http://docs.google.com'}
613 if os.path.exists(config_file):
614 try:
615 new_config = pyauto.PyUITest.EvalDataFrom(config_file)
616 for key in new_config:
617 if new_config.get(key) is not None:
618 config[key] = new_config.get(key)
619 except SyntaxError, e:
620 logging.info('Could not read %s: %s', config_file, str(e))
621 return config
622
600 def _LoginToGoogleAccount(self, account_key='test_google_account'): 623 def _LoginToGoogleAccount(self, account_key='test_google_account'):
601 """Logs in to a test Google account. 624 """Logs in to a test Google account.
602 625
626 Login with user-defined credentials if they exist.
627 Else login with private test credentials if they exist.
628 Else fail.
629
603 Args: 630 Args:
604 account_key: The string key associated with the test account login 631 account_key: The string key in private_tests_info.txt which is associated
605 credentials to use. 632 with the test account login credentials to use. It will only
633 be used when fail to load user-defined credentials.
634
635 Raises:
636 RuntimeError: if could not get credential information.
606 """ 637 """
607 creds = self.GetPrivateInfo()[account_key] 638 private_file = os.path.join(pyauto.PyUITest.DataDir(), 'pyauto_private',
608 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) 639 'private_tests_info.txt')
640 config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg')
641 config = self._GetConfig()
642 google_account_url = config.get('google_account_url')
643 username = config.get('username')
644 password = config.get('password')
645 if username and password:
646 logging.info(
647 'Using google account credential from %s',
648 os.path.join(os.path.dirname(__file__), 'perf.cfg'))
649 elif os.path.exists(private_file):
650 google_account_url = 'https://accounts.google.com/'
dennis_jeffrey 2012/08/16 18:49:58 this should probably use the login URL from the co
fdeng1 2012/08/17 06:39:34 I was thinking those accounts in private_tests_inf
651 creds = self.GetPrivateInfo()[account_key]
652 username = creds['username']
653 password = creds['password']
654 logging.info(
655 'Google account credential not defined in %s, using %s',
dennis_jeffrey 2012/08/16 18:49:58 probably don't need to say the config file name or
fdeng1 2012/08/17 06:39:34 Done.
656 config_file, private_file)
657 else:
658 message = \
659 'Please sepecify credential information in %s.\n' \
dennis_jeffrey 2012/08/16 18:49:58 sepecify --> specify
dennis_jeffrey 2012/08/16 18:49:58 Right before this, say in the log message that no
fdeng1 2012/08/17 06:39:34 Done.
fdeng1 2012/08/17 06:39:34 Done.
660 'Format:\n\t{\n' \
661 '\t "username": "my_username",\n' \
662 '\t "password": "my_password",\n' \
663 '\t "google_account_url": "https://my-google-account-server",\n' \
664 '\t "gmail_url: "https://my-gmail-server",\n' \
665 '\t "plus_url": "https://my-plus-server",\n' \
666 '\t "docs_url": "https://my-docs-server",\n\t}\n' \
667 % config_file
dennis_jeffrey 2012/08/16 18:49:58 I think we don't need to print the format in this
fdeng1 2012/08/17 06:39:34 Done.
668 raise RuntimeError('Could not get credential information.\n' + message)
669 test_utils.GoogleAccountsLogin(
670 self, username, password, url=google_account_url)
609 self.NavigateToURL('about:blank') # Clear the existing tab. 671 self.NavigateToURL('about:blank') # Clear the existing tab.
610 672
611 def _GetCPUUsage(self): 673 def _GetCPUUsage(self):
612 """Returns machine's CPU usage. 674 """Returns machine's CPU usage.
613 675
614 This function uses /proc/stat to identify CPU usage, and therefore works 676 This function uses /proc/stat to identify CPU usage, and therefore works
615 only on Linux/ChromeOS. 677 only on Linux/ChromeOS.
616 678
617 Returns: 679 Returns:
618 A dictionary with 'user', 'nice', 'system' and 'idle' values. 680 A dictionary with 'user', 'nice', 'system' and 'idle' values.
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 """Identifies the port number to which the server is currently bound. 2673 """Identifies the port number to which the server is currently bound.
2612 2674
2613 Returns: 2675 Returns:
2614 The numeric port number to which the server is currently bound. 2676 The numeric port number to which the server is currently bound.
2615 """ 2677 """
2616 return self._server.server_address[1] 2678 return self._server.server_address[1]
2617 2679
2618 2680
2619 if __name__ == '__main__': 2681 if __name__ == '__main__':
2620 pyauto_functional.Main() 2682 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698