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

Side by Side Diff: chrome/test/functional/perf_endure.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 """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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 591
592 _WEBAPP_NAME = 'Gmail' 592 _WEBAPP_NAME = 'Gmail'
593 _TAB_TITLE_SUBSTRING = 'Gmail' 593 _TAB_TITLE_SUBSTRING = 'Gmail'
594 _FRAME_XPATH = 'id("canvas_frame")' 594 _FRAME_XPATH = 'id("canvas_frame")'
595 595
596 def setUp(self): 596 def setUp(self):
597 ChromeEndureBaseTest.setUp(self) 597 ChromeEndureBaseTest.setUp(self)
598 598
599 # Log into a test Google account and open up Gmail. 599 # Log into a test Google account and open up Gmail.
600 self._LoginToGoogleAccount(account_key='test_google_account_gmail') 600 self._LoginToGoogleAccount(account_key='test_google_account_gmail')
601 self.NavigateToURL('http://www.gmail.com') 601 self.NavigateToURL(self._GetConfig().get('gmail_url'))
602 loaded_tab_title = self.GetActiveTabTitle() 602 self.assertTrue(
603 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, 603 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in
604 msg='Loaded tab title does not contain "%s": "%s"' % 604 self.GetActiveTabTitle(),
605 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) 605 timeout=60, expect_retval=True, retry_sleep=1),
Nirnimesh 2012/08/21 00:54:43 why are you overriding the timeout?
606 msg='Timed out waiting for Gmail to load. Tab title is: %s' %
607 self.GetActiveTabTitle())
606 608
607 self._driver = self.NewWebDriver() 609 self._driver = self.NewWebDriver()
608 # Any call to wait.until() will raise an exception if the timeout is hit. 610 # Any call to wait.until() will raise an exception if the timeout is hit.
609 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new 611 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new
610 # DOM mutation observer mechanism. 612 # DOM mutation observer mechanism.
611 self._wait = WebDriverWait(self._driver, timeout=60) 613 self._wait = WebDriverWait(self._driver, timeout=60)
612 614
613 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present. 615 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present.
614 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better 616 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better
615 # way to tell when the webpage is ready for user interaction. 617 # way to tell when the webpage is ready for user interaction.
616 self._wait.until( 618 self._wait.until(
617 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit. 619 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit.
618 # Wait for the inbox to appear. 620 # Wait for the inbox to appear.
619 self.WaitForDomNode('//a[starts-with(@title, "Inbox")]', 621 self.WaitForDomNode('//a[starts-with(@title, "Inbox")]',
620 frame_xpath=self._FRAME_XPATH) 622 frame_xpath=self._FRAME_XPATH)
621 623
624 # Test whether latency dom element is available.
625 try:
626 self._GetLatencyDomElement(5000)
627 self._has_latency = True
628 except pyauto_errors.JSONInterfaceError:
629 logging.info('Skip recording latency as latency ' +
630 'dom element is not available.')
631 self._has_latency = False
632
622 def _SwitchToCanvasFrame(self, driver): 633 def _SwitchToCanvasFrame(self, driver):
623 """Switch the WebDriver to Gmail's 'canvas_frame', if it's available. 634 """Switch the WebDriver to Gmail's 'canvas_frame', if it's available.
624 635
625 Args: 636 Args:
626 driver: A selenium.webdriver.remote.webdriver.WebDriver object. 637 driver: A selenium.webdriver.remote.webdriver.WebDriver object.
627 638
628 Returns: 639 Returns:
629 True, if the switch to Gmail's 'canvas_frame' is successful, or 640 True, if the switch to Gmail's 'canvas_frame' is successful, or
630 False if not. 641 False if not.
631 """ 642 """
632 try: 643 try:
633 driver.switch_to_frame('canvas_frame') 644 driver.switch_to_frame('canvas_frame')
634 return True 645 return True
635 except selenium.common.exceptions.NoSuchFrameException: 646 except selenium.common.exceptions.NoSuchFrameException:
636 return False 647 return False
637 648
638 def _GetLatencyDomElement(self): 649 def _GetLatencyDomElement(self, timeout=-1):
639 """Returns a reference to the latency info element in the Gmail DOM.""" 650 """Returns a reference to the latency info element in the Gmail DOM.
651
652 Args:
653 timeout: The maximum amount of time (in milliseconds) to wait for
654 the latency dom element to appear, defaults to the
655 default automation timeout.
656 Returns:
657 A latency dom element.
658 """
640 latency_xpath = ( 659 latency_xpath = (
641 '//span[starts-with(text(), "Why was the last action slow?")]') 660 '//span[starts-with(text(), "Why was the last action slow?")]')
642 self.WaitForDomNode(latency_xpath, frame_xpath=self._FRAME_XPATH) 661 self.WaitForDomNode(latency_xpath, timeout=timeout,
662 frame_xpath=self._FRAME_XPATH)
643 return self._GetElement(self._driver.find_element_by_xpath, latency_xpath) 663 return self._GetElement(self._driver.find_element_by_xpath, latency_xpath)
644 664
645 def _WaitUntilDomElementRemoved(self, dom_element): 665 def _WaitUntilDomElementRemoved(self, dom_element):
646 """Waits until the given element is no longer attached to the DOM. 666 """Waits until the given element is no longer attached to the DOM.
647 667
648 Args: 668 Args:
649 dom_element: A selenium.webdriver.remote.WebElement object. 669 dom_element: A selenium.webdriver.remote.WebElement object.
650 """ 670 """
651 def _IsElementStale(): 671 def _IsElementStale():
652 try: 672 try:
(...skipping 12 matching lines...) Expand all
665 minute of test execution are not recorded. 685 minute of test execution are not recorded.
666 686
667 Args: 687 Args:
668 element: A selenium.webdriver.remote.WebElement object to click. 688 element: A selenium.webdriver.remote.WebElement object to click.
669 test_description: A string description of what the test does, used for 689 test_description: A string description of what the test does, used for
670 outputting results to be graphed. Should not contain spaces. For 690 outputting results to be graphed. Should not contain spaces. For
671 example, 'ComposeDiscard' for Gmail. 691 example, 'ComposeDiscard' for Gmail.
672 action_description: A string description of what action is being 692 action_description: A string description of what action is being
673 performed. Should not contain spaces. For example, 'Compose'. 693 performed. Should not contain spaces. For example, 'Compose'.
674 """ 694 """
695 if not self._has_latency:
696 element.click()
697 return
675 latency_dom_element = self._GetLatencyDomElement() 698 latency_dom_element = self._GetLatencyDomElement()
676 element.click() 699 element.click()
677 # Wait for the old latency value to be removed, before getting the new one. 700 # Wait for the old latency value to be removed, before getting the new one.
678 self._WaitUntilDomElementRemoved(latency_dom_element) 701 self._WaitUntilDomElementRemoved(latency_dom_element)
679 702
680 latency_dom_element = self._GetLatencyDomElement() 703 latency_dom_element = self._GetLatencyDomElement()
681 match = re.search(r'\[(\d+) ms\]', latency_dom_element.text) 704 match = re.search(r'\[(\d+) ms\]', latency_dom_element.text)
682 if match: 705 if match:
683 latency = int(match.group(1)) 706 latency = int(match.group(1))
684 elapsed_time = int(round(time.time() - self._test_start_time)) 707 elapsed_time = int(round(time.time() - self._test_start_time))
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 """Long-running performance tests for Chrome using Google Docs.""" 952 """Long-running performance tests for Chrome using Google Docs."""
930 953
931 _WEBAPP_NAME = 'Docs' 954 _WEBAPP_NAME = 'Docs'
932 _TAB_TITLE_SUBSTRING = 'Google Drive' 955 _TAB_TITLE_SUBSTRING = 'Google Drive'
933 956
934 def setUp(self): 957 def setUp(self):
935 ChromeEndureBaseTest.setUp(self) 958 ChromeEndureBaseTest.setUp(self)
936 959
937 # Log into a test Google account and open up Google Docs. 960 # Log into a test Google account and open up Google Docs.
938 self._LoginToGoogleAccount() 961 self._LoginToGoogleAccount()
939 self.NavigateToURL('http://docs.google.com') 962 self.NavigateToURL(self._GetConfig().get('docs_url'))
940 self.assertTrue( 963 self.assertTrue(
941 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in 964 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in
942 self.GetActiveTabTitle(), 965 self.GetActiveTabTitle(),
943 timeout=60, expect_retval=True, retry_sleep=1), 966 timeout=60, expect_retval=True, retry_sleep=1),
944 msg='Timed out waiting for Docs to load. Tab title is: %s' % 967 msg='Timed out waiting for Docs to load. Tab title is: %s' %
945 self.GetActiveTabTitle()) 968 self.GetActiveTabTitle())
946 969
947 self._driver = self.NewWebDriver() 970 self._driver = self.NewWebDriver()
948 971
949 def testDocsAlternatelyClickLists(self): 972 def testDocsAlternatelyClickLists(self):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 """Long-running performance tests for Chrome using Google Plus.""" 1024 """Long-running performance tests for Chrome using Google Plus."""
1002 1025
1003 _WEBAPP_NAME = 'Plus' 1026 _WEBAPP_NAME = 'Plus'
1004 _TAB_TITLE_SUBSTRING = 'Google+' 1027 _TAB_TITLE_SUBSTRING = 'Google+'
1005 1028
1006 def setUp(self): 1029 def setUp(self):
1007 ChromeEndureBaseTest.setUp(self) 1030 ChromeEndureBaseTest.setUp(self)
1008 1031
1009 # Log into a test Google account and open up Google Plus. 1032 # Log into a test Google account and open up Google Plus.
1010 self._LoginToGoogleAccount() 1033 self._LoginToGoogleAccount()
1011 self.NavigateToURL('http://plus.google.com') 1034 self.NavigateToURL(self._GetConfig().get('plus_url'))
1012 loaded_tab_title = self.GetActiveTabTitle() 1035 loaded_tab_title = self.GetActiveTabTitle()
1013 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, 1036 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title,
1014 msg='Loaded tab title does not contain "%s": "%s"' % 1037 msg='Loaded tab title does not contain "%s": "%s"' %
1015 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) 1038 (self._TAB_TITLE_SUBSTRING, loaded_tab_title))
1016 1039
1017 self._driver = self.NewWebDriver() 1040 self._driver = self.NewWebDriver()
1018 1041
1019 def testPlusAlternatelyClickStreams(self): 1042 def testPlusAlternatelyClickStreams(self):
1020 """Alternates between two different streams. 1043 """Alternates between two different streams.
1021 1044
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 self._num_errors += 1 1137 self._num_errors += 1
1115 1138
1116 time.sleep(1) 1139 time.sleep(1)
1117 1140
1118 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING, 1141 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
1119 test_description, scenario) 1142 test_description, scenario)
1120 1143
1121 1144
1122 if __name__ == '__main__': 1145 if __name__ == '__main__':
1123 pyauto_functional.Main() 1146 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698