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

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: 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 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 56a9992cce70439a6744d7bf92f21e3ce4962d25..3d055c383fa9de6a31e06aa1c4930d06b370a791 100755
--- a/chrome/test/functional/perf.py
+++ b/chrome/test/functional/perf.py
@@ -597,15 +597,77 @@ class BasePerfTest(pyauto.PyUITest):
self._PrintSummaryResults(description, timings, 'milliseconds', graph_name)
+ def _GetConfig(self):
+ """Load perf test configuration file.
+
+ Returns:
+ 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.
+ """
+ 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',
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
+ 'plus_url': 'http://plus.google.com',
+ 'docs_url': 'http://docs.google.com'}
+ if os.path.exists(config_file):
+ try:
+ new_config = pyauto.PyUITest.EvalDataFrom(config_file)
+ for key in new_config:
+ if new_config.get(key) is not None:
+ 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')
+ 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'))
+ elif os.path.exists(private_file):
+ 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
+ creds = self.GetPrivateInfo()[account_key]
+ username = creds['username']
+ password = creds['password']
+ logging.info(
+ '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.
+ config_file, private_file)
+ else:
+ message = \
+ '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.
+ 'Format:\n\t{\n' \
+ '\t "username": "my_username",\n' \
+ '\t "password": "my_password",\n' \
+ '\t "google_account_url": "https://my-google-account-server",\n' \
+ '\t "gmail_url: "https://my-gmail-server",\n' \
+ '\t "plus_url": "https://my-plus-server",\n' \
+ '\t "docs_url": "https://my-docs-server",\n\t}\n' \
+ % 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.
+ raise RuntimeError('Could not get credential information.\n' + 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