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

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

Issue 10803002: Run Chrome Endure tests with network simulation via Web Page Replay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Env var to control usage of WPR Created 8 years, 5 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 15 matching lines...) Expand all
26 import time 26 import time
27 27
28 import perf 28 import perf
29 import pyauto_functional # Must be imported before pyauto. 29 import pyauto_functional # Must be imported before pyauto.
30 import pyauto 30 import pyauto
31 import pyauto_errors 31 import pyauto_errors
32 import pyauto_utils 32 import pyauto_utils
33 import remote_inspector_client 33 import remote_inspector_client
34 import selenium.common.exceptions 34 import selenium.common.exceptions
35 from selenium.webdriver.support.ui import WebDriverWait 35 from selenium.webdriver.support.ui import WebDriverWait
36 import webpagereplay
36 37
37 38
38 class NotSupportedEnvironmentError(RuntimeError): 39 class NotSupportedEnvironmentError(RuntimeError):
39 """Represent an error raised since the environment (OS) is not supported.""" 40 """Represent an error raised since the environment (OS) is not supported."""
40 pass 41 pass
41 42
42 class ChromeEndureBaseTest(perf.BasePerfTest): 43 class ChromeEndureBaseTest(perf.BasePerfTest):
43 """Implements common functionality for all Chrome Endure tests. 44 """Implements common functionality for all Chrome Endure tests.
44 45
45 All Chrome Endure test classes should inherit from this class. 46 All Chrome Endure test classes should inherit from this class.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 # The same with setUp, but need to fetch the environment variable since 174 # The same with setUp, but need to fetch the environment variable since
174 # ExtraChromeFlags is called before setUp. 175 # ExtraChromeFlags is called before setUp.
175 deep_memory_profile = self._GetDeepMemoryProfileEnv( 176 deep_memory_profile = self._GetDeepMemoryProfileEnv(
176 'DEEP_MEMORY_PROFILE', bool, self._DEEP_MEMORY_PROFILE) 177 'DEEP_MEMORY_PROFILE', bool, self._DEEP_MEMORY_PROFILE)
177 178
178 # Ensure Chrome enables remote debugging on port 9222. This is required to 179 # Ensure Chrome enables remote debugging on port 9222. This is required to
179 # interact with Chrome's remote inspector. 180 # interact with Chrome's remote inspector.
180 extra_flags = ['--remote-debugging-port=9222'] 181 extra_flags = ['--remote-debugging-port=9222']
181 if deep_memory_profile: 182 if deep_memory_profile:
182 extra_flags.append('--no-sandbox') 183 extra_flags.append('--no-sandbox')
184
185 # Add flags for the Web Page Replay server if necessary.
186 if 'DO_NOT_USE_WPR_FOR_ENDURE' not in os.environ:
dennis_jeffrey 2012/07/24 00:39:35 there are multiple places where we check whether t
fdeng1 2012/07/24 04:30:05 Done.
187 extra_flags.extend(ChromeEndureWebPageReplay().chrome_flags)
188
183 return (perf.BasePerfTest.ExtraChromeFlags(self) + extra_flags) 189 return (perf.BasePerfTest.ExtraChromeFlags(self) + extra_flags)
184 190
185 def _OnTimelineEvent(self, event_info): 191 def _OnTimelineEvent(self, event_info):
186 """Invoked by the Remote Inspector Client when a timeline event occurs. 192 """Invoked by the Remote Inspector Client when a timeline event occurs.
187 193
188 Args: 194 Args:
189 event_info: A dictionary containing raw information associated with a 195 event_info: A dictionary containing raw information associated with a
190 timeline event received from Chrome's remote inspector. Refer to 196 timeline event received from Chrome's remote inspector. Refer to
191 chrome/src/third_party/WebKit/Source/WebCore/inspector/Inspector.json 197 chrome/src/third_party/WebKit/Source/WebCore/inspector/Inspector.json
192 for the format of this dictionary. 198 for the format of this dictionary.
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 try: 539 try:
534 element = self._GetElement(driver.find_element_by_xpath, xpath) 540 element = self._GetElement(driver.find_element_by_xpath, xpath)
535 element.click() 541 element.click()
536 except (selenium.common.exceptions.StaleElementReferenceException, 542 except (selenium.common.exceptions.StaleElementReferenceException,
537 selenium.common.exceptions.TimeoutException) as e: 543 selenium.common.exceptions.TimeoutException) as e:
538 logging.exception('WebDriver exception: %s' % e) 544 logging.exception('WebDriver exception: %s' % e)
539 return False 545 return False
540 546
541 return True 547 return True
542 548
549 def _StartReplayServerIfNecessary(self, test_name):
550 """Start the Web Page Replay server if DO_NOT_USE_WPR_FOR_ENDURE is not set.
551
552 This method need to be called BEFORE any connection (which are supposed
dennis_jeffrey 2012/07/24 00:39:35 'need' --> 'needs'
fdeng1 2012/07/24 04:30:05 Done.
553 to go through the Web Page Replay server) occurs.
554
555 Args:
556 test_name: name of the test.
557 """
558 if 'DO_NOT_USE_WPR_FOR_ENDURE' not in os.environ:
559 mode = 'Record' if 'WPR_RECORD' in os.environ else 'Replay'
560 logging.info('Starting the Web Page Replay server: in %s mode', mode)
561
562 self.wpr_server = ChromeEndureWebPageReplay().GetReplayServer(test_name)
563 self.wpr_server.StartServer()
564 logging.info('The Web Page Replay server started.')
565
566 def _StopReplayServerIfNecessary(self):
567 """Stop the Web Page Replay server if DO_NOT_USE_WPR_FOR_ENDURE is not set.
568
569 This method has to be called AFTER all network connections which go
570 through Web Page Replay server have shut down. Otherwise the
571 Web Page Replay server will hang to wait for them. A good
572 place is to call it at the end of the teardown process.
573 """
574
dennis_jeffrey 2012/07/24 00:39:35 remove this blank line
fdeng1 2012/07/24 04:30:05 Done.
575 if 'DO_NOT_USE_WPR_FOR_ENDURE' not in os.environ:
576 logging.info('Stopping The Web Page Replay server.')
577 self.wpr_server.StopServer()
578 logging.info('The Web Page Replay server stopped.')
579
543 580
544 class ChromeEndureControlTest(ChromeEndureBaseTest): 581 class ChromeEndureControlTest(ChromeEndureBaseTest):
545 """Control tests for Chrome Endure.""" 582 """Control tests for Chrome Endure."""
546 583
547 _WEBAPP_NAME = 'Control' 584 _WEBAPP_NAME = 'Control'
548 _TAB_TITLE_SUBSTRING = 'Chrome Endure Control Test' 585 _TAB_TITLE_SUBSTRING = 'Chrome Endure Control Test'
549 586
550 def testControlAttachDetachDOMTree(self): 587 def testControlAttachDetachDOMTree(self):
551 """Continually attach and detach a DOM tree from a basic document.""" 588 """Continually attach and detach a DOM tree from a basic document."""
552 test_description = 'AttachDetachDOMTree' 589 test_description = 'AttachDetachDOMTree'
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 test_description, lambda: scenario(driver)) 627 test_description, lambda: scenario(driver))
591 628
592 629
593 class ChromeEndureGmailTest(ChromeEndureBaseTest): 630 class ChromeEndureGmailTest(ChromeEndureBaseTest):
594 """Long-running performance tests for Chrome using Gmail.""" 631 """Long-running performance tests for Chrome using Gmail."""
595 632
596 _WEBAPP_NAME = 'Gmail' 633 _WEBAPP_NAME = 'Gmail'
597 _TAB_TITLE_SUBSTRING = 'Gmail' 634 _TAB_TITLE_SUBSTRING = 'Gmail'
598 _FRAME_XPATH = 'id("canvas_frame")' 635 _FRAME_XPATH = 'id("canvas_frame")'
599 636
600 def setUp(self): 637 def _GmailSetUp(self, test_name):
601 ChromeEndureBaseTest.setUp(self) 638 """Set up before each test runs."""
639
640 # Start the Web Page Replay server.
641 self._StartReplayServerIfNecessary(test_name)
602 642
603 # Log into a test Google account and open up Gmail. 643 # Log into a test Google account and open up Gmail.
604 self._LoginToGoogleAccount(account_key='test_google_account_gmail') 644 self._LoginToGoogleAccount(account_key='test_google_account_gmail')
605 self.NavigateToURL('http://www.gmail.com') 645 self.NavigateToURL('http://www.gmail.com')
606 loaded_tab_title = self.GetActiveTabTitle() 646 loaded_tab_title = self.GetActiveTabTitle()
607 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, 647 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title,
608 msg='Loaded tab title does not contain "%s": "%s"' % 648 msg='Loaded tab title does not contain "%s": "%s"' %
609 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) 649 (self._TAB_TITLE_SUBSTRING, loaded_tab_title))
610 650
611 self._driver = self.NewWebDriver() 651 self._driver = self.NewWebDriver()
612 # Any call to wait.until() will raise an exception if the timeout is hit. 652 # Any call to wait.until() will raise an exception if the timeout is hit.
613 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new 653 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new
614 # DOM mutation observer mechanism. 654 # DOM mutation observer mechanism.
615 self._wait = WebDriverWait(self._driver, timeout=60) 655 self._wait = WebDriverWait(self._driver, timeout=60)
616 656
617 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present. 657 # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present.
618 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better 658 # TODO(dennisjeffrey): Check with the Gmail team to see if there's a better
619 # way to tell when the webpage is ready for user interaction. 659 # way to tell when the webpage is ready for user interaction.
620 self._wait.until( 660 self._wait.until(
621 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit. 661 self._SwitchToCanvasFrame) # Raises exception if the timeout is hit.
622 # Wait for the inbox to appear. 662 # Wait for the inbox to appear.
623 self.WaitForDomNode('//a[starts-with(@title, "Inbox")]', 663 self.WaitForDomNode('//a[starts-with(@title, "Inbox")]',
624 frame_xpath=self._FRAME_XPATH) 664 frame_xpath=self._FRAME_XPATH)
625 665
666 def tearDown(self):
667 super(ChromeEndureGmailTest, self).tearDown()
668 # Stop the Web Page Replay server after all connections to WPR closed.
669 self._StopReplayServerIfNecessary()
670
626 def _SwitchToCanvasFrame(self, driver): 671 def _SwitchToCanvasFrame(self, driver):
627 """Switch the WebDriver to Gmail's 'canvas_frame', if it's available. 672 """Switch the WebDriver to Gmail's 'canvas_frame', if it's available.
628 673
629 Args: 674 Args:
630 driver: A selenium.webdriver.remote.webdriver.WebDriver object. 675 driver: A selenium.webdriver.remote.webdriver.WebDriver object.
631 676
632 Returns: 677 Returns:
633 True, if the switch to Gmail's 'canvas_frame' is successful, or 678 True, if the switch to Gmail's 'canvas_frame' is successful, or
634 False if not. 679 False if not.
635 """ 680 """
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 else: 740 else:
696 logging.warning('Could not identify latency value.') 741 logging.warning('Could not identify latency value.')
697 742
698 def testGmailComposeDiscard(self): 743 def testGmailComposeDiscard(self):
699 """Continuously composes/discards an e-mail before sending. 744 """Continuously composes/discards an e-mail before sending.
700 745
701 This test continually composes/discards an e-mail using Gmail, and 746 This test continually composes/discards an e-mail using Gmail, and
702 periodically gathers performance stats that may reveal memory bloat. 747 periodically gathers performance stats that may reveal memory bloat.
703 """ 748 """
704 test_description = 'ComposeDiscard' 749 test_description = 'ComposeDiscard'
750 self._GmailSetUp(test_description)
705 751
706 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is 752 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
707 # fixed. 753 # fixed.
708 self._test_length_sec = 60 * 60 * 5 # Run test for 5 hours. 754 self._test_length_sec = 60 * 60 * 5 # Run test for 5 hours.
709 755
710 def scenario(): 756 def scenario():
711 # Click the "Compose" button, enter some text into the "To" field, enter 757 # Click the "Compose" button, enter some text into the "To" field, enter
712 # some text into the "Subject" field, then click the "Discard" button to 758 # some text into the "Subject" field, then click the "Discard" button to
713 # discard the message. 759 # discard the message.
714 compose_xpath = '//div[text()="COMPOSE"]' 760 compose_xpath = '//div[text()="COMPOSE"]'
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 792
747 # TODO(dennisjeffrey): Remove this test once the Gmail team is done analyzing 793 # TODO(dennisjeffrey): Remove this test once the Gmail team is done analyzing
748 # the results after the test runs for a period of time. 794 # the results after the test runs for a period of time.
749 def testGmailComposeDiscardSleep(self): 795 def testGmailComposeDiscardSleep(self):
750 """Like testGmailComposeDiscard, but sleeps for 30s between iterations. 796 """Like testGmailComposeDiscard, but sleeps for 30s between iterations.
751 797
752 This is a temporary test requested by the Gmail team to compare against the 798 This is a temporary test requested by the Gmail team to compare against the
753 results from testGmailComposeDiscard above. 799 results from testGmailComposeDiscard above.
754 """ 800 """
755 test_description = 'ComposeDiscardSleep' 801 test_description = 'ComposeDiscardSleep'
802 self._GmailSetUp(test_description)
756 803
757 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is 804 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
758 # fixed. 805 # fixed.
759 self._test_length_sec = 60 * 60 * 5 # Run test for 5 hours. 806 self._test_length_sec = 60 * 60 * 5 # Run test for 5 hours.
760 807
761 def scenario(): 808 def scenario():
762 # Click the "Compose" button, enter some text into the "To" field, enter 809 # Click the "Compose" button, enter some text into the "To" field, enter
763 # some text into the "Subject" field, then click the "Discard" button to 810 # some text into the "Subject" field, then click the "Discard" button to
764 # discard the message. Finally, sleep for 30 seconds. 811 # discard the message. Finally, sleep for 30 seconds.
765 compose_xpath = '//div[text()="COMPOSE"]' 812 compose_xpath = '//div[text()="COMPOSE"]'
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 frame_xpath=self._FRAME_XPATH) 848 frame_xpath=self._FRAME_XPATH)
802 849
803 def testGmailAlternateThreadlistConversation(self): 850 def testGmailAlternateThreadlistConversation(self):
804 """Alternates between threadlist view and conversation view. 851 """Alternates between threadlist view and conversation view.
805 852
806 This test continually clicks between the threadlist (Inbox) and the 853 This test continually clicks between the threadlist (Inbox) and the
807 conversation view (e-mail message view), and periodically gathers 854 conversation view (e-mail message view), and periodically gathers
808 performance stats that may reveal memory bloat. 855 performance stats that may reveal memory bloat.
809 """ 856 """
810 test_description = 'ThreadConversation' 857 test_description = 'ThreadConversation'
858 self._GmailSetUp(test_description)
811 859
812 def scenario(): 860 def scenario():
813 # Click an e-mail to see the conversation view, wait 1 second, click the 861 # Click an e-mail to see the conversation view, wait 1 second, click the
814 # "Inbox" link to see the threadlist, wait 1 second. 862 # "Inbox" link to see the threadlist, wait 1 second.
815 863
816 # Find the first thread (e-mail) identified by a "span" tag that contains 864 # Find the first thread (e-mail) identified by a "span" tag that contains
817 # an "email" attribute. Then click it and wait for the conversation view 865 # an "email" attribute. Then click it and wait for the conversation view
818 # to appear (assumed to be visible when a particular div exists on the 866 # to appear (assumed to be visible when a particular div exists on the
819 # page). 867 # page).
820 thread_xpath = '//span[@email]' 868 thread_xpath = '//span[@email]'
(...skipping 23 matching lines...) Expand all
844 test_description, scenario, 892 test_description, scenario,
845 frame_xpath=self._FRAME_XPATH) 893 frame_xpath=self._FRAME_XPATH)
846 894
847 def testGmailAlternateTwoLabels(self): 895 def testGmailAlternateTwoLabels(self):
848 """Continuously alternates between two labels. 896 """Continuously alternates between two labels.
849 897
850 This test continually clicks between the "Inbox" and "Sent Mail" labels, 898 This test continually clicks between the "Inbox" and "Sent Mail" labels,
851 and periodically gathers performance stats that may reveal memory bloat. 899 and periodically gathers performance stats that may reveal memory bloat.
852 """ 900 """
853 test_description = 'AlternateLabels' 901 test_description = 'AlternateLabels'
902 self._GmailSetUp(test_description)
854 903
855 def scenario(): 904 def scenario():
856 # Click the "Sent Mail" label, wait for 1 second, click the "Inbox" label, 905 # Click the "Sent Mail" label, wait for 1 second, click the "Inbox" label,
857 # wait for 1 second. 906 # wait for 1 second.
858 907
859 # Click the "Sent Mail" label, then wait for the tab title to be updated 908 # Click the "Sent Mail" label, then wait for the tab title to be updated
860 # with the substring "sent". 909 # with the substring "sent".
861 sent_xpath = '//a[starts-with(text(), "Sent Mail")]' 910 sent_xpath = '//a[starts-with(text(), "Sent Mail")]'
862 self.WaitForDomNode(sent_xpath, frame_xpath=self._FRAME_XPATH) 911 self.WaitForDomNode(sent_xpath, frame_xpath=self._FRAME_XPATH)
863 sent = self._GetElement(self._driver.find_element_by_xpath, sent_xpath) 912 sent = self._GetElement(self._driver.find_element_by_xpath, sent_xpath)
(...skipping 22 matching lines...) Expand all
886 935
887 def testGmailExpandCollapseConversation(self): 936 def testGmailExpandCollapseConversation(self):
888 """Continuously expands/collapses all messages in a conversation. 937 """Continuously expands/collapses all messages in a conversation.
889 938
890 This test opens up a conversation (e-mail thread) with several messages, 939 This test opens up a conversation (e-mail thread) with several messages,
891 then continually alternates between the "Expand all" and "Collapse all" 940 then continually alternates between the "Expand all" and "Collapse all"
892 views, while periodically gathering performance stats that may reveal memory 941 views, while periodically gathering performance stats that may reveal memory
893 bloat. 942 bloat.
894 """ 943 """
895 test_description = 'ExpandCollapse' 944 test_description = 'ExpandCollapse'
945 self._GmailSetUp(test_description)
896 946
897 # Enter conversation view for a particular thread. 947 # Enter conversation view for a particular thread.
898 thread_xpath = '//span[@email]' 948 thread_xpath = '//span[@email]'
899 self.WaitForDomNode(thread_xpath, frame_xpath=self._FRAME_XPATH) 949 self.WaitForDomNode(thread_xpath, frame_xpath=self._FRAME_XPATH)
900 thread = self._GetElement(self._driver.find_element_by_xpath, thread_xpath) 950 thread = self._GetElement(self._driver.find_element_by_xpath, thread_xpath)
901 thread.click() 951 thread.click()
902 self.WaitForDomNode('//div[text()="Click here to "]', 952 self.WaitForDomNode('//div[text()="Click here to "]',
903 frame_xpath=self._FRAME_XPATH) 953 frame_xpath=self._FRAME_XPATH)
904 954
905 def scenario(): 955 def scenario():
(...skipping 30 matching lines...) Expand all
936 test_description, scenario, 986 test_description, scenario,
937 frame_xpath=self._FRAME_XPATH) 987 frame_xpath=self._FRAME_XPATH)
938 988
939 989
940 class ChromeEndureDocsTest(ChromeEndureBaseTest): 990 class ChromeEndureDocsTest(ChromeEndureBaseTest):
941 """Long-running performance tests for Chrome using Google Docs.""" 991 """Long-running performance tests for Chrome using Google Docs."""
942 992
943 _WEBAPP_NAME = 'Docs' 993 _WEBAPP_NAME = 'Docs'
944 _TAB_TITLE_SUBSTRING = 'Google Drive' 994 _TAB_TITLE_SUBSTRING = 'Google Drive'
945 995
946 def setUp(self): 996 def _DocsSetUp(self, test_name):
947 ChromeEndureBaseTest.setUp(self) 997 """Set up before each test runs."""
998
999 # Start the Web Page Replay server.
1000 self._StartReplayServerIfNecessary(test_name)
948 1001
949 # Log into a test Google account and open up Google Docs. 1002 # Log into a test Google account and open up Google Docs.
950 self._LoginToGoogleAccount() 1003 self._LoginToGoogleAccount()
951 self.NavigateToURL('http://docs.google.com') 1004 self.NavigateToURL('http://docs.google.com')
952 self.assertTrue( 1005 self.assertTrue(
953 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in 1006 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in
954 self.GetActiveTabTitle(), 1007 self.GetActiveTabTitle(),
955 timeout=60, expect_retval=True, retry_sleep=1), 1008 timeout=60, expect_retval=True, retry_sleep=1),
956 msg='Timed out waiting for Docs to load. Tab title is: %s' % 1009 msg='Timed out waiting for Docs to load. Tab title is: %s' %
957 self.GetActiveTabTitle()) 1010 self.GetActiveTabTitle())
958 1011
959 self._driver = self.NewWebDriver() 1012 self._driver = self.NewWebDriver()
960 1013
1014 def tearDown(self):
1015 super(ChromeEndureDocsTest, self).tearDown()
1016 # Stop the Web Page Replay server after all connections to it closed.
1017 self._StopReplayServerIfNecessary()
1018
961 def testDocsAlternatelyClickLists(self): 1019 def testDocsAlternatelyClickLists(self):
962 """Alternates between two different document lists. 1020 """Alternates between two different document lists.
963 1021
964 This test alternately clicks the "Shared with me" and "My Drive" buttons in 1022 This test alternately clicks the "Shared with me" and "My Drive" buttons in
965 Google Docs, and periodically gathers performance stats that may reveal 1023 Google Docs, and periodically gathers performance stats that may reveal
966 memory bloat. 1024 memory bloat.
967 """ 1025 """
968 test_description = 'AlternateLists' 1026 test_description = 'AlternateLists'
1027 self._DocsSetUp(test_description)
969 1028
970 def scenario(): 1029 def scenario():
971 # Click the "Shared with me" button, wait for 1 second, click the 1030 # Click the "Shared with me" button, wait for 1 second, click the
972 # "My Drive" button, wait for 1 second. 1031 # "My Drive" button, wait for 1 second.
973 1032
974 # Click the "Shared with me" button and wait for a div to appear. 1033 # Click the "Shared with me" button and wait for a div to appear.
975 if not self._ClickElementByXpath( 1034 if not self._ClickElementByXpath(
976 self._driver, '//span[starts-with(text(), "Shared with me")]'): 1035 self._driver, '//span[starts-with(text(), "Shared with me")]'):
977 self._num_errors += 1 1036 self._num_errors += 1
978 self.WaitForDomNode('//div[text()="Share date"]') 1037 self.WaitForDomNode('//div[text()="Share date"]')
(...skipping 18 matching lines...) Expand all
997 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING, 1056 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
998 test_description, scenario) 1057 test_description, scenario)
999 1058
1000 1059
1001 class ChromeEndurePlusTest(ChromeEndureBaseTest): 1060 class ChromeEndurePlusTest(ChromeEndureBaseTest):
1002 """Long-running performance tests for Chrome using Google Plus.""" 1061 """Long-running performance tests for Chrome using Google Plus."""
1003 1062
1004 _WEBAPP_NAME = 'Plus' 1063 _WEBAPP_NAME = 'Plus'
1005 _TAB_TITLE_SUBSTRING = 'Google+' 1064 _TAB_TITLE_SUBSTRING = 'Google+'
1006 1065
1007 def setUp(self): 1066 def _PlusSetUp(self, test_name):
1008 ChromeEndureBaseTest.setUp(self) 1067 """Set up before each test runs."""
1068
1069 # Start the Web Page Replay server.
1070 self._StartReplayServerIfNecessary(test_name)
1009 1071
1010 # Log into a test Google account and open up Google Plus. 1072 # Log into a test Google account and open up Google Plus.
1011 self._LoginToGoogleAccount() 1073 self._LoginToGoogleAccount()
1012 self.NavigateToURL('http://plus.google.com') 1074 self.NavigateToURL('http://plus.google.com')
1013 loaded_tab_title = self.GetActiveTabTitle() 1075 loaded_tab_title = self.GetActiveTabTitle()
1014 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, 1076 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title,
1015 msg='Loaded tab title does not contain "%s": "%s"' % 1077 msg='Loaded tab title does not contain "%s": "%s"' %
1016 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) 1078 (self._TAB_TITLE_SUBSTRING, loaded_tab_title))
1017 1079
1018 self._driver = self.NewWebDriver() 1080 self._driver = self.NewWebDriver()
1019 1081
1082 def tearDown(self):
1083 super(ChromeEndurePlusTest, self).tearDown()
1084 # Stop the Web Page Replay server after all connections to it closed.
1085 self._StopReplayServerIfNecessary()
1086
1020 def testPlusAlternatelyClickStreams(self): 1087 def testPlusAlternatelyClickStreams(self):
1021 """Alternates between two different streams. 1088 """Alternates between two different streams.
1022 1089
1023 This test alternately clicks the "Friends" and "Family" buttons using 1090 This test alternately clicks the "Friends" and "Family" buttons using
1024 Google Plus, and periodically gathers performance stats that may reveal 1091 Google Plus, and periodically gathers performance stats that may reveal
1025 memory bloat. 1092 memory bloat.
1026 """ 1093 """
1027 test_description = 'AlternateStreams' 1094 test_description = 'AlternateStreams'
1095 self._PlusSetUp(test_description)
1028 1096
1029 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is 1097 # TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
1030 # fixed. 1098 # fixed.
1031 self._test_length_sec = 60 * 60 * 3 # Run test for 3 hours. 1099 self._test_length_sec = 60 * 60 * 3 # Run test for 3 hours.
1032 1100
1033 def scenario(): 1101 def scenario():
1034 # Click the "Friends" button, wait for 1 second, click the "Family" 1102 # Click the "Friends" button, wait for 1 second, click the "Family"
1035 # button, wait for 1 second. 1103 # button, wait for 1 second.
1036 1104
1037 # Click the "Friends" button and wait for a resulting div to appear. 1105 # Click the "Friends" button and wait for a resulting div to appear.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 except (pyauto_errors.JSONInterfaceError, 1185 except (pyauto_errors.JSONInterfaceError,
1118 pyauto_errors.JavascriptRuntimeError): 1186 pyauto_errors.JavascriptRuntimeError):
1119 self._num_errors += 1 1187 self._num_errors += 1
1120 1188
1121 time.sleep(1) 1189 time.sleep(1)
1122 1190
1123 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING, 1191 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
1124 test_description, scenario) 1192 test_description, scenario)
1125 1193
1126 1194
1195 class ChromeEndureWebPageReplay(perf.BaseWebPageReplay):
1196 """Set up Web Page Replay server for Endure tests.
1197
1198 This class inherits from perf.BaseWebPageReplay to allow different settings
1199 for the Web Page Replay server.
1200
dennis_jeffrey 2012/07/24 00:39:35 remove this blank line
fdeng1 2012/07/24 04:30:05 Done.
1201 """
1202
1203 def __init__(self):
1204 # Call parent __init__
dennis_jeffrey 2012/07/24 00:39:35 probably don't need this comment. it's easy to se
fdeng1 2012/07/24 04:30:05 Done.
1205 super(ChromeEndureWebPageReplay, self).__init__()
1206
1207 # Extra paths for Web Page Replay
dennis_jeffrey 2012/07/24 00:39:35 add period at end of sentence
fdeng1 2012/07/24 04:30:05 Done.
1208 extra_paths = {
1209 'archive':
1210 'src/chrome/test/data/chrome_endure/webpagereplay/{test_name}.wpr',
1211 'scripts': 'src/chrome/test/data/chrome_endure/deterministic.js',
1212 }
1213 self._paths.update(extra_paths)
1214
1215 # Add custumized injected_scripts for Endure tests.
dennis_jeffrey 2012/07/24 00:39:35 'custumized' --> 'customized'
fdeng1 2012/07/24 04:30:05 Done.
1216 assert os.path.exists(self.Path('scripts')), (
1217 'The scripts to be injected do not exist: %s' %
1218 self.Path('scripts'))
1219 self._replay_flags.append('--inject_scripts=%s' % self.Path('scripts'))
1220
1221
1127 if __name__ == '__main__': 1222 if __name__ == '__main__':
1128 pyauto_functional.Main() 1223 pyauto_functional.Main()
OLDNEW
« chrome/test/functional/perf.py ('K') | « chrome/test/functional/perf.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698