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

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