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

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

Issue 9561010: Add a control test for Chrome Endure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « chrome/test/data/chrome_endure/endurance_control.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Performance tests for Chrome Endure (long-running perf tests on Chrome). 6 """Performance tests for Chrome Endure (long-running perf tests on Chrome).
7 7
8 This module accepts the following environment variable inputs: 8 This module accepts the following environment variable inputs:
9 TEST_LENGTH: The number of seconds in which to run each test. 9 TEST_LENGTH: The number of seconds in which to run each test.
10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling 10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 """ 206 """
207 try: 207 try:
208 wait.until(lambda _: self._GetElement(driver.find_element_by_xpath, 208 wait.until(lambda _: self._GetElement(driver.find_element_by_xpath,
209 xpath)) 209 xpath))
210 except selenium.common.exceptions.TimeoutException, e: 210 except selenium.common.exceptions.TimeoutException, e:
211 logging.exception('WebDriver exception: %s' % str(e)) 211 logging.exception('WebDriver exception: %s' % str(e))
212 return False 212 return False
213 return True 213 return True
214 214
215 215
216 class ChromeEndureControlTest(ChromeEndureBaseTest):
217 """Control tests for Chrome Endure."""
218
219 _webapp_name = 'Control'
220 _tab_title_substring = 'Chrome Endure Control Test'
221
222 def testControlAttachDetachDOMTree(self):
223 """Continually attach and detach a DOM tree from a basic document."""
224 test_description = 'AttachDetachDOMTree'
225
226 url = self.GetHttpURLForDataPath('chrome_endure', 'endurance_control.html')
227 self.NavigateToURL(url)
228 loaded_tab_title = self.GetActiveTabTitle()
229 self.assertTrue(self._tab_title_substring in loaded_tab_title,
230 msg='Loaded tab title does not contain "%s": "%s"' %
231 (self._tab_title_substring, loaded_tab_title))
232
233 # This test performs no interaction with the webpage. It simply sleeps
234 # and periodically checks to see whether it's time to take performance
235 # measurements.
236 self._test_start_time = time.time()
237 last_perf_stats_time = time.time()
238 self._GetPerformanceStats(self._webapp_name, test_description,
239 self._tab_title_substring)
240 iteration_num = 0
241 while time.time() - self._test_start_time < self._test_length_sec:
242 iteration_num += 1
243
244 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
245 last_perf_stats_time = time.time()
246 self._GetPerformanceStats(self._webapp_name, test_description,
247 self._tab_title_substring)
248
249 if iteration_num % 10 == 0:
250 remaining_time = self._test_length_sec - (
251 time.time() - self._test_start_time)
252 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
253 (iteration_num, remaining_time))
254
255 time.sleep(5)
256
257 self._GetPerformanceStats(self._webapp_name, test_description,
258 self._tab_title_substring)
259
260
216 class ChromeEndureGmailTest(ChromeEndureBaseTest): 261 class ChromeEndureGmailTest(ChromeEndureBaseTest):
217 """Long-running performance tests for Chrome using Gmail.""" 262 """Long-running performance tests for Chrome using Gmail."""
218 263
219 _webapp_name = 'Gmail' 264 _webapp_name = 'Gmail'
220 _tab_title_substring = 'Gmail' 265 _tab_title_substring = 'Gmail'
221 266
222 def setUp(self): 267 def setUp(self):
223 ChromeEndureBaseTest.setUp(self) 268 ChromeEndureBaseTest.setUp(self)
224 269
225 # Log into a test Google account and open up Gmail. 270 # Log into a test Google account and open up Gmail.
226 self._LoginToGoogleAccount(account_key='test_google_account_gmail') 271 self._LoginToGoogleAccount(account_key='test_google_account_gmail')
227 self.NavigateToURL('http://www.gmail.com') 272 self.NavigateToURL('http://www.gmail.com')
228 loaded_tab_title = self.GetActiveTabTitle() 273 loaded_tab_title = self.GetActiveTabTitle()
229 self.assertTrue(self._tab_title_substring in loaded_tab_title, 274 self.assertTrue(self._tab_title_substring in loaded_tab_title,
230 msg='Loaded tab title does not contain "Gmail": "%s"' % 275 msg='Loaded tab title does not contain "%s": "%s"' %
231 loaded_tab_title) 276 (self._tab_title_substring, loaded_tab_title))
232 277
233 self._driver = self.NewWebDriver() 278 self._driver = self.NewWebDriver()
234 # Any call to wait.until() will raise an exception if the timeout is hit. 279 # Any call to wait.until() will raise an exception if the timeout is hit.
235 self._wait = WebDriverWait(self._driver, timeout=60) 280 self._wait = WebDriverWait(self._driver, timeout=60)
236 281
237 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present. 282 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present.
238 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better 283 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better
239 # way to tell when the webpage is ready for user interaction. 284 # way to tell when the webpage is ready for user interaction.
240 self._wait.until( 285 self._wait.until(
241 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit. 286 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 710
666 driver = self.NewWebDriver() 711 driver = self.NewWebDriver()
667 # Any call to wait.until() will raise an exception if the timeout is hit. 712 # Any call to wait.until() will raise an exception if the timeout is hit.
668 wait = WebDriverWait(driver, timeout=60) 713 wait = WebDriverWait(driver, timeout=60)
669 714
670 # Log into a test Google account and open up Google Plus. 715 # Log into a test Google account and open up Google Plus.
671 self._LoginToGoogleAccount() 716 self._LoginToGoogleAccount()
672 self.NavigateToURL('http://plus.google.com') 717 self.NavigateToURL('http://plus.google.com')
673 loaded_tab_title = self.GetActiveTabTitle() 718 loaded_tab_title = self.GetActiveTabTitle()
674 self.assertTrue(self._tab_title_substring in loaded_tab_title, 719 self.assertTrue(self._tab_title_substring in loaded_tab_title,
675 msg='Loaded tab title does not contain "Google+": "%s"' % 720 msg='Loaded tab title does not contain "%s": "%s"' %
676 loaded_tab_title) 721 (self._tab_title_substring, loaded_tab_title))
677 722
678 # Interact with Google Plus for the duration of the test. Here, we repeat 723 # Interact with Google Plus for the duration of the test. Here, we repeat
679 # the following sequence of interactions: click the "Friends" button, then 724 # the following sequence of interactions: click the "Friends" button, then
680 # click the "Acquaintances" button. 725 # click the "Acquaintances" button.
681 num_errors = 0 726 num_errors = 0
682 self._test_start_time = time.time() 727 self._test_start_time = time.time()
683 last_perf_stats_time = time.time() 728 last_perf_stats_time = time.time()
684 self._GetPerformanceStats(self._webapp_name, test_description, 729 self._GetPerformanceStats(self._webapp_name, test_description,
685 self._tab_title_substring) 730 self._tab_title_substring)
686 iteration_num = 0 731 iteration_num = 0
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 driver, wait, '//div[text()="Acquaintances"]'): 768 driver, wait, '//div[text()="Acquaintances"]'):
724 num_errors += 1 769 num_errors += 1
725 time.sleep(1) 770 time.sleep(1)
726 771
727 self._GetPerformanceStats(self._webapp_name, test_description, 772 self._GetPerformanceStats(self._webapp_name, test_description,
728 self._tab_title_substring) 773 self._tab_title_substring)
729 774
730 775
731 if __name__ == '__main__': 776 if __name__ == '__main__':
732 pyauto_functional.Main() 777 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/data/chrome_endure/endurance_control.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698