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

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: merge with original/master 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 that represents the config information.
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',
611 'plus_url': 'https://plus.google.com',
612 'docs_url': 'https://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:
Nirnimesh 2012/08/21 00:54:43 this whole block is equivalent to: config.update(
617 if new_config.get(key) is not None:
Nirnimesh 2012/08/21 00:54:43 'is not None' is redundant
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')
Nirnimesh 2012/08/21 00:54:43 this var is used in several locations. Make it a p
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'))
Nirnimesh 2012/08/21 00:54:43 use the var
649 elif os.path.exists(private_file):
650 creds = self.GetPrivateInfo()[account_key]
651 username = creds['username']
652 password = creds['password']
653 logging.info(
654 'User-defined credentials not found,' +
655 ' using private test credentials instead.')
656 else:
657 message = 'No user-defined or private test ' \
658 'credentials could be found. ' \
659 'Please specify credential information in %s.' \
660 % config_file
661 raise RuntimeError(message)
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 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 """Identifies the port number to which the server is currently bound. 2650 """Identifies the port number to which the server is currently bound.
2596 2651
2597 Returns: 2652 Returns:
2598 The numeric port number to which the server is currently bound. 2653 The numeric port number to which the server is currently bound.
2599 """ 2654 """
2600 return self._server.server_address[1] 2655 return self._server.server_address[1]
2601 2656
2602 2657
2603 if __name__ == '__main__': 2658 if __name__ == '__main__':
2604 pyauto_functional.Main() 2659 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698