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

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

Issue 9687001: Adding another control test for Chrome Endure that uses WebDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjusted indentation of several lines. 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_webdriver.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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return False 243 return False
244 return True 244 return True
245 245
246 246
247 class ChromeEndureControlTest(ChromeEndureBaseTest): 247 class ChromeEndureControlTest(ChromeEndureBaseTest):
248 """Control tests for Chrome Endure.""" 248 """Control tests for Chrome Endure."""
249 249
250 _webapp_name = 'Control' 250 _webapp_name = 'Control'
251 _tab_title_substring = 'Chrome Endure Control Test' 251 _tab_title_substring = 'Chrome Endure Control Test'
252 252
253 def testControlAttachDetachDOMTree(self): 253 # TODO(dennisjeffrey): Make this function available to the other Chrome Endure
254 """Continually attach and detach a DOM tree from a basic document.""" 254 # tests so that we can remove duplicated code in those other tests as well.
255 test_description = 'AttachDetachDOMTree' 255 # Ideally, tests shouldn't have knowledge about the details of how the test
256 256 # harness runs; the only main difference between the tests is that they
257 url = self.GetHttpURLForDataPath('chrome_endure', 'endurance_control.html') 257 # navigate to different URLs, and perform different scenarios on them.
258 self.NavigateToURL(url) 258 def _RunControlTest(self, test_description, data_file_url, do_scenario):
259 """Runs a general control test."""
260 self.NavigateToURL(data_file_url)
259 loaded_tab_title = self.GetActiveTabTitle() 261 loaded_tab_title = self.GetActiveTabTitle()
260 self.assertTrue(self._tab_title_substring in loaded_tab_title, 262 self.assertTrue(self._tab_title_substring in loaded_tab_title,
261 msg='Loaded tab title does not contain "%s": "%s"' % 263 msg='Loaded tab title does not contain "%s": "%s"' %
262 (self._tab_title_substring, loaded_tab_title)) 264 (self._tab_title_substring, loaded_tab_title))
263 265
264 # This test performs no interaction with the webpage. It simply sleeps
265 # and periodically checks to see whether it's time to take performance
266 # measurements.
267 self._test_start_time = time.time() 266 self._test_start_time = time.time()
268 last_perf_stats_time = time.time() 267 last_perf_stats_time = time.time()
269 self._GetPerformanceStats(self._webapp_name, test_description, 268 self._GetPerformanceStats(self._webapp_name, test_description,
270 self._tab_title_substring) 269 self._tab_title_substring)
271 iteration_num = 0 270 iteration_num = 0
272 while time.time() - self._test_start_time < self._test_length_sec: 271 while time.time() - self._test_start_time < self._test_length_sec:
273 iteration_num += 1 272 iteration_num += 1
274 273
275 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 274 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
276 last_perf_stats_time = time.time() 275 last_perf_stats_time = time.time()
277 self._GetPerformanceStats(self._webapp_name, test_description, 276 self._GetPerformanceStats(self._webapp_name, test_description,
278 self._tab_title_substring) 277 self._tab_title_substring)
279 278
280 if iteration_num % 10 == 0: 279 if iteration_num % 10 == 0:
281 remaining_time = self._test_length_sec - ( 280 remaining_time = self._test_length_sec - (time.time() -
282 time.time() - self._test_start_time) 281 self._test_start_time)
283 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 282 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
284 (iteration_num, remaining_time)) 283 (iteration_num, remaining_time))
285 284
286 time.sleep(5) 285 do_scenario()
287 286
288 self._GetPerformanceStats(self._webapp_name, test_description, 287 self._GetPerformanceStats(self._webapp_name, test_description,
289 self._tab_title_substring) 288 self._tab_title_substring)
290 289
290 def testControlAttachDetachDOMTree(self):
291 """Continually attach and detach a DOM tree from a basic document."""
292 test_description = 'AttachDetachDOMTree'
293 url = self.GetHttpURLForDataPath('chrome_endure', 'endurance_control.html')
294
295 def scenario():
296 # This test performs no interaction with the webpage. It simply sleeps
297 # and periodically checks to see whether it's time to take performance
298 # measurements.
299 time.sleep(5)
300
301 self._RunControlTest(test_description, url, scenario)
302
303
304 def testControlAttachDetachDOMTreeWebDriver(self):
305 """Use WebDriver to attach and detach a DOM tree from a basic document."""
306 test_description = 'AttachDetachDOMTreeWebDriver'
307 url = self.GetHttpURLForDataPath('chrome_endure',
308 'endurance_control_webdriver.html')
309
310 driver = self.NewWebDriver()
311 wait = WebDriverWait(driver, timeout=60)
312
313 def scenario(driver, wait):
314 # Interact with the control test webpage for the duration of the test.
315 # Here, we repeat the following sequence of interactions: click the
316 # "attach" button to attach a large DOM tree (with event listeners) to the
317 # document, wait half a second, click "detach" to detach the DOM tree from
318 # the document, wait half a second.
319 self._ClickElementByXpath(driver, wait, 'id("attach")')
320 time.sleep(0.5)
321 self._ClickElementByXpath(driver, wait, 'id("detach")')
322 time.sleep(0.5)
323
324 self._RunControlTest(test_description, url, lambda: scenario(driver, wait))
325
291 326
292 class ChromeEndureGmailTest(ChromeEndureBaseTest): 327 class ChromeEndureGmailTest(ChromeEndureBaseTest):
293 """Long-running performance tests for Chrome using Gmail.""" 328 """Long-running performance tests for Chrome using Gmail."""
294 329
295 _webapp_name = 'Gmail' 330 _webapp_name = 'Gmail'
296 _tab_title_substring = 'Gmail' 331 _tab_title_substring = 'Gmail'
297 332
298 def setUp(self): 333 def setUp(self):
299 ChromeEndureBaseTest.setUp(self) 334 ChromeEndureBaseTest.setUp(self)
300 335
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 iteration_num = 0 390 iteration_num = 0
356 while time.time() - self._test_start_time < self._test_length_sec: 391 while time.time() - self._test_start_time < self._test_length_sec:
357 iteration_num += 1 392 iteration_num += 1
358 393
359 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 394 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
360 last_perf_stats_time = time.time() 395 last_perf_stats_time = time.time()
361 self._GetPerformanceStats(self._webapp_name, test_description, 396 self._GetPerformanceStats(self._webapp_name, test_description,
362 self._tab_title_substring) 397 self._tab_title_substring)
363 398
364 if iteration_num % 10 == 0: 399 if iteration_num % 10 == 0:
365 remaining_time = self._test_length_sec - ( 400 remaining_time = self._test_length_sec - (time.time() -
366 time.time() - self._test_start_time) 401 self._test_start_time)
367 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 402 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
368 (iteration_num, remaining_time)) 403 (iteration_num, remaining_time))
369 404
370 compose_button = self._wait.until(lambda _: self._GetElement( 405 compose_button = self._wait.until(lambda _: self._GetElement(
371 self._driver.find_element_by_xpath, 406 self._driver.find_element_by_xpath,
372 '//div[text()="COMPOSE"]')) 407 '//div[text()="COMPOSE"]'))
373 compose_button.click() 408 compose_button.click()
374 409
375 to_field = self._wait.until(lambda _: self._GetElement( 410 to_field = self._wait.until(lambda _: self._GetElement(
376 self._driver.find_element_by_name, 'to')) 411 self._driver.find_element_by_name, 'to'))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 iteration_num = 0 450 iteration_num = 0
416 while time.time() - self._test_start_time < self._test_length_sec: 451 while time.time() - self._test_start_time < self._test_length_sec:
417 iteration_num += 1 452 iteration_num += 1
418 453
419 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 454 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
420 last_perf_stats_time = time.time() 455 last_perf_stats_time = time.time()
421 self._GetPerformanceStats(self._webapp_name, test_description, 456 self._GetPerformanceStats(self._webapp_name, test_description,
422 self._tab_title_substring) 457 self._tab_title_substring)
423 458
424 if iteration_num % 10 == 0: 459 if iteration_num % 10 == 0:
425 remaining_time = self._test_length_sec - ( 460 remaining_time = self._test_length_sec - (time.time() -
426 time.time() - self._test_start_time) 461 self._test_start_time)
427 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 462 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
428 (iteration_num, remaining_time)) 463 (iteration_num, remaining_time))
429 464
430 compose_button = self._wait.until(lambda _: self._GetElement( 465 compose_button = self._wait.until(lambda _: self._GetElement(
431 self._driver.find_element_by_xpath, 466 self._driver.find_element_by_xpath,
432 '//div[text()="COMPOSE"]')) 467 '//div[text()="COMPOSE"]'))
433 compose_button.click() 468 compose_button.click()
434 469
435 to_field = self._wait.until(lambda _: self._GetElement( 470 to_field = self._wait.until(lambda _: self._GetElement(
436 self._driver.find_element_by_name, 'to')) 471 self._driver.find_element_by_name, 'to'))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 iteration_num = 0 511 iteration_num = 0
477 while time.time() - self._test_start_time < self._test_length_sec: 512 while time.time() - self._test_start_time < self._test_length_sec:
478 iteration_num += 1 513 iteration_num += 1
479 514
480 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 515 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
481 last_perf_stats_time = time.time() 516 last_perf_stats_time = time.time()
482 self._GetPerformanceStats(self._webapp_name, test_description, 517 self._GetPerformanceStats(self._webapp_name, test_description,
483 self._tab_title_substring) 518 self._tab_title_substring)
484 519
485 if iteration_num % 10 == 0: 520 if iteration_num % 10 == 0:
486 remaining_time = self._test_length_sec - ( 521 remaining_time = self._test_length_sec - (time.time() -
487 time.time() - self._test_start_time) 522 self._test_start_time)
488 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 523 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
489 (iteration_num, remaining_time)) 524 (iteration_num, remaining_time))
490 525
491 # Find the first thread (e-mail) identified by a "span" tag that contains 526 # Find the first thread (e-mail) identified by a "span" tag that contains
492 # an "email" attribute. Then click it and wait for the conversation view 527 # an "email" attribute. Then click it and wait for the conversation view
493 # to appear (assumed to be visible when a particular div exists on the 528 # to appear (assumed to be visible when a particular div exists on the
494 # page). 529 # page).
495 thread = self._wait.until( 530 thread = self._wait.until(
496 lambda _: self._GetElement(self._driver.find_element_by_xpath, 531 lambda _: self._GetElement(self._driver.find_element_by_xpath,
497 '//span[@email]')) 532 '//span[@email]'))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 iteration_num = 0 569 iteration_num = 0
535 while time.time() - self._test_start_time < self._test_length_sec: 570 while time.time() - self._test_start_time < self._test_length_sec:
536 iteration_num += 1 571 iteration_num += 1
537 572
538 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 573 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
539 last_perf_stats_time = time.time() 574 last_perf_stats_time = time.time()
540 self._GetPerformanceStats(self._webapp_name, test_description, 575 self._GetPerformanceStats(self._webapp_name, test_description,
541 self._tab_title_substring) 576 self._tab_title_substring)
542 577
543 if iteration_num % 10 == 0: 578 if iteration_num % 10 == 0:
544 remaining_time = self._test_length_sec - ( 579 remaining_time = self._test_length_sec - (time.time() -
545 time.time() - self._test_start_time) 580 self._test_start_time)
546 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 581 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
547 (iteration_num, remaining_time)) 582 (iteration_num, remaining_time))
548 583
549 # Click the "Sent Mail" label, then wait for the tab title to be updated 584 # Click the "Sent Mail" label, then wait for the tab title to be updated
550 # with the substring "sent". 585 # with the substring "sent".
551 sent = self._wait.until( 586 sent = self._wait.until(
552 lambda _: self._GetElement(self._driver.find_element_by_xpath, 587 lambda _: self._GetElement(self._driver.find_element_by_xpath,
553 '//a[starts-with(text(), "Sent Mail")]')) 588 '//a[starts-with(text(), "Sent Mail")]'))
554 sent.click() 589 sent.click()
555 self.assertTrue( 590 self.assertTrue(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 iteration_num = 0 636 iteration_num = 0
602 while time.time() - self._test_start_time < self._test_length_sec: 637 while time.time() - self._test_start_time < self._test_length_sec:
603 iteration_num += 1 638 iteration_num += 1
604 639
605 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 640 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
606 last_perf_stats_time = time.time() 641 last_perf_stats_time = time.time()
607 self._GetPerformanceStats(self._webapp_name, test_description, 642 self._GetPerformanceStats(self._webapp_name, test_description,
608 self._tab_title_substring) 643 self._tab_title_substring)
609 644
610 if iteration_num % 10 == 0: 645 if iteration_num % 10 == 0:
611 remaining_time = self._test_length_sec - ( 646 remaining_time = self._test_length_sec - (time.time() -
612 time.time() - self._test_start_time) 647 self._test_start_time)
613 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 648 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
614 (iteration_num, remaining_time)) 649 (iteration_num, remaining_time))
615 650
616 # Click the "Expand all" icon, then wait for that icon to be removed from 651 # Click the "Expand all" icon, then wait for that icon to be removed from
617 # the page. 652 # the page.
618 expand = self._wait.until( 653 expand = self._wait.until(
619 lambda _: self._GetElement(self._driver.find_element_by_xpath, 654 lambda _: self._GetElement(self._driver.find_element_by_xpath,
620 '//img[@alt="Expand all"]')) 655 '//img[@alt="Expand all"]'))
621 expand.click() 656 expand.click()
622 self._wait.until( 657 self._wait.until(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 logging.error('Error count threshold (%d) reached. Terminating test ' 723 logging.error('Error count threshold (%d) reached. Terminating test '
689 'early.' % self._ERROR_COUNT_THRESHOLD) 724 'early.' % self._ERROR_COUNT_THRESHOLD)
690 break 725 break
691 726
692 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 727 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
693 last_perf_stats_time = time.time() 728 last_perf_stats_time = time.time()
694 self._GetPerformanceStats(self._webapp_name, test_description, 729 self._GetPerformanceStats(self._webapp_name, test_description,
695 self._tab_title_substring) 730 self._tab_title_substring)
696 731
697 if iteration_num % 10 == 0: 732 if iteration_num % 10 == 0:
698 remaining_time = self._test_length_sec - ( 733 remaining_time = self._test_length_sec - (time.time() -
699 time.time() - self._test_start_time) 734 self._test_start_time)
700 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 735 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
701 (iteration_num, remaining_time)) 736 (iteration_num, remaining_time))
702 737
703 # Click the "Owned by me" button and wait for a resulting div to appear. 738 # Click the "Owned by me" button and wait for a resulting div to appear.
704 if not self._ClickElementByXpath( 739 if not self._ClickElementByXpath(
705 driver, wait, '//div[text()="Owned by me"]'): 740 driver, wait, '//div[text()="Owned by me"]'):
706 num_errors += 1 741 num_errors += 1
707 if not self._WaitForElementByXpath( 742 if not self._WaitForElementByXpath(
708 driver, wait, 743 driver, wait,
709 '//div[@title="Owned by me filter. Use backspace or delete to ' 744 '//div[@title="Owned by me filter. Use backspace or delete to '
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 logging.error('Error count threshold (%d) reached. Terminating test ' 802 logging.error('Error count threshold (%d) reached. Terminating test '
768 'early.' % self._ERROR_COUNT_THRESHOLD) 803 'early.' % self._ERROR_COUNT_THRESHOLD)
769 break 804 break
770 805
771 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: 806 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval:
772 last_perf_stats_time = time.time() 807 last_perf_stats_time = time.time()
773 self._GetPerformanceStats(self._webapp_name, test_description, 808 self._GetPerformanceStats(self._webapp_name, test_description,
774 self._tab_title_substring) 809 self._tab_title_substring)
775 810
776 if iteration_num % 10 == 0: 811 if iteration_num % 10 == 0:
777 remaining_time = self._test_length_sec - ( 812 remaining_time = self._test_length_sec - (time.time() -
778 time.time() - self._test_start_time) 813 self._test_start_time)
779 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % 814 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
780 (iteration_num, remaining_time)) 815 (iteration_num, remaining_time))
781 816
782 # Click the "Friends" button and wait for a resulting div to appear. 817 # Click the "Friends" button and wait for a resulting div to appear.
783 if not self._ClickElementByXpath( 818 if not self._ClickElementByXpath(
784 driver, wait, 819 driver, wait,
785 '//a[text()="Friends" and starts-with(@href, "stream/circles")]'): 820 '//a[text()="Friends" and starts-with(@href, "stream/circles")]'):
786 num_errors += 1 821 num_errors += 1
787 if not self._WaitForElementByXpath( 822 if not self._WaitForElementByXpath(
788 driver, wait, '//div[text()="Friends"]'): 823 driver, wait, '//div[text()="Friends"]'):
(...skipping 10 matching lines...) Expand all
799 driver, wait, '//div[text()="Acquaintances"]'): 834 driver, wait, '//div[text()="Acquaintances"]'):
800 num_errors += 1 835 num_errors += 1
801 time.sleep(1) 836 time.sleep(1)
802 837
803 self._GetPerformanceStats(self._webapp_name, test_description, 838 self._GetPerformanceStats(self._webapp_name, test_description,
804 self._tab_title_substring) 839 self._tab_title_substring)
805 840
806 841
807 if __name__ == '__main__': 842 if __name__ == '__main__':
808 pyauto_functional.Main() 843 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/data/chrome_endure/endurance_control_webdriver.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698