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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/perf.py
diff --git a/chrome/test/functional/perf.py b/chrome/test/functional/perf.py
index 177349265fdc82a5bc227ab85aea118dfcf64472..bf5bbd8ae4124dc2aa5ed440ade8bc63e5c1f952 100755
--- a/chrome/test/functional/perf.py
+++ b/chrome/test/functional/perf.py
@@ -597,15 +597,70 @@ class BasePerfTest(pyauto.PyUITest):
self._PrintSummaryResults(description, timings, 'milliseconds', graph_name)
+ def _GetConfig(self):
+ """Load perf test configuration file.
+
+ Returns:
+ A dictionary that represents the config information.
+ """
+ config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg')
+ config = {'username': None,
+ 'password': None,
+ 'google_account_url': 'https://accounts.google.com/',
+ 'gmail_url': 'https://www.gmail.com',
+ 'plus_url': 'https://plus.google.com',
+ 'docs_url': 'https://docs.google.com'}
+ if os.path.exists(config_file):
+ try:
+ new_config = pyauto.PyUITest.EvalDataFrom(config_file)
+ for key in new_config:
Nirnimesh 2012/08/21 00:54:43 this whole block is equivalent to: config.update(
+ if new_config.get(key) is not None:
Nirnimesh 2012/08/21 00:54:43 'is not None' is redundant
+ config[key] = new_config.get(key)
+ except SyntaxError, e:
+ logging.info('Could not read %s: %s', config_file, str(e))
+ return config
+
def _LoginToGoogleAccount(self, account_key='test_google_account'):
"""Logs in to a test Google account.
+ Login with user-defined credentials if they exist.
+ Else login with private test credentials if they exist.
+ Else fail.
+
Args:
- account_key: The string key associated with the test account login
- credentials to use.
- """
- creds = self.GetPrivateInfo()[account_key]
- test_utils.GoogleAccountsLogin(self, creds['username'], creds['password'])
+ account_key: The string key in private_tests_info.txt which is associated
+ with the test account login credentials to use. It will only
+ be used when fail to load user-defined credentials.
+
+ Raises:
+ RuntimeError: if could not get credential information.
+ """
+ private_file = os.path.join(pyauto.PyUITest.DataDir(), 'pyauto_private',
+ 'private_tests_info.txt')
+ 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
+ config = self._GetConfig()
+ google_account_url = config.get('google_account_url')
+ username = config.get('username')
+ password = config.get('password')
+ if username and password:
+ logging.info(
+ 'Using google account credential from %s',
+ os.path.join(os.path.dirname(__file__), 'perf.cfg'))
Nirnimesh 2012/08/21 00:54:43 use the var
+ elif os.path.exists(private_file):
+ creds = self.GetPrivateInfo()[account_key]
+ username = creds['username']
+ password = creds['password']
+ logging.info(
+ 'User-defined credentials not found,' +
+ ' using private test credentials instead.')
+ else:
+ message = 'No user-defined or private test ' \
+ 'credentials could be found. ' \
+ 'Please specify credential information in %s.' \
+ % config_file
+ raise RuntimeError(message)
+ test_utils.GoogleAccountsLogin(
+ self, username, password, url=google_account_url)
self.NavigateToURL('about:blank') # Clear the existing tab.
def _GetCPUUsage(self):

Powered by Google App Engine
This is Rietveld 408576698