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

Unified 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 side-by-side diff with in-line comments
Download patch
« chrome/test/functional/perf.py ('K') | « chrome/test/functional/perf.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/perf_endure.py
diff --git a/chrome/test/functional/perf_endure.py b/chrome/test/functional/perf_endure.py
index 134c9dfdd13c3b82b20b82cdbd9a1453acb11c41..6e25e760ecbedfb577df721041868ce11faf89fa 100755
--- a/chrome/test/functional/perf_endure.py
+++ b/chrome/test/functional/perf_endure.py
@@ -33,6 +33,7 @@ import pyauto_utils
import remote_inspector_client
import selenium.common.exceptions
from selenium.webdriver.support.ui import WebDriverWait
+import webpagereplay
class NotSupportedEnvironmentError(RuntimeError):
@@ -180,6 +181,11 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
extra_flags = ['--remote-debugging-port=9222']
if deep_memory_profile:
extra_flags.append('--no-sandbox')
+
+ # Add flags for the Web Page Replay server if necessary.
+ 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.
+ extra_flags.extend(ChromeEndureWebPageReplay().chrome_flags)
+
return (perf.BasePerfTest.ExtraChromeFlags(self) + extra_flags)
def _OnTimelineEvent(self, event_info):
@@ -540,6 +546,37 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
return True
+ def _StartReplayServerIfNecessary(self, test_name):
+ """Start the Web Page Replay server if DO_NOT_USE_WPR_FOR_ENDURE is not set.
+
+ 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.
+ to go through the Web Page Replay server) occurs.
+
+ Args:
+ test_name: name of the test.
+ """
+ if 'DO_NOT_USE_WPR_FOR_ENDURE' not in os.environ:
+ mode = 'Record' if 'WPR_RECORD' in os.environ else 'Replay'
+ logging.info('Starting the Web Page Replay server: in %s mode', mode)
+
+ self.wpr_server = ChromeEndureWebPageReplay().GetReplayServer(test_name)
+ self.wpr_server.StartServer()
+ logging.info('The Web Page Replay server started.')
+
+ def _StopReplayServerIfNecessary(self):
+ """Stop the Web Page Replay server if DO_NOT_USE_WPR_FOR_ENDURE is not set.
+
+ This method has to be called AFTER all network connections which go
+ through Web Page Replay server have shut down. Otherwise the
+ Web Page Replay server will hang to wait for them. A good
+ place is to call it at the end of the teardown process.
+ """
+
dennis_jeffrey 2012/07/24 00:39:35 remove this blank line
fdeng1 2012/07/24 04:30:05 Done.
+ if 'DO_NOT_USE_WPR_FOR_ENDURE' not in os.environ:
+ logging.info('Stopping The Web Page Replay server.')
+ self.wpr_server.StopServer()
+ logging.info('The Web Page Replay server stopped.')
+
class ChromeEndureControlTest(ChromeEndureBaseTest):
"""Control tests for Chrome Endure."""
@@ -597,8 +634,11 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
_TAB_TITLE_SUBSTRING = 'Gmail'
_FRAME_XPATH = 'id("canvas_frame")'
- def setUp(self):
- ChromeEndureBaseTest.setUp(self)
+ def _GmailSetUp(self, test_name):
+ """Set up before each test runs."""
+
+ # Start the Web Page Replay server.
+ self._StartReplayServerIfNecessary(test_name)
# Log into a test Google account and open up Gmail.
self._LoginToGoogleAccount(account_key='test_google_account_gmail')
@@ -623,6 +663,11 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
self.WaitForDomNode('//a[starts-with(@title, "Inbox")]',
frame_xpath=self._FRAME_XPATH)
+ def tearDown(self):
+ super(ChromeEndureGmailTest, self).tearDown()
+ # Stop the Web Page Replay server after all connections to WPR closed.
+ self._StopReplayServerIfNecessary()
+
def _SwitchToCanvasFrame(self, driver):
"""Switch the WebDriver to Gmail's 'canvas_frame', if it's available.
@@ -702,6 +747,7 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
periodically gathers performance stats that may reveal memory bloat.
"""
test_description = 'ComposeDiscard'
+ self._GmailSetUp(test_description)
# TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
# fixed.
@@ -753,6 +799,7 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
results from testGmailComposeDiscard above.
"""
test_description = 'ComposeDiscardSleep'
+ self._GmailSetUp(test_description)
# TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
# fixed.
@@ -808,6 +855,7 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
performance stats that may reveal memory bloat.
"""
test_description = 'ThreadConversation'
+ self._GmailSetUp(test_description)
def scenario():
# Click an e-mail to see the conversation view, wait 1 second, click the
@@ -851,6 +899,7 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
and periodically gathers performance stats that may reveal memory bloat.
"""
test_description = 'AlternateLabels'
+ self._GmailSetUp(test_description)
def scenario():
# Click the "Sent Mail" label, wait for 1 second, click the "Inbox" label,
@@ -893,6 +942,7 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest):
bloat.
"""
test_description = 'ExpandCollapse'
+ self._GmailSetUp(test_description)
# Enter conversation view for a particular thread.
thread_xpath = '//span[@email]'
@@ -943,8 +993,11 @@ class ChromeEndureDocsTest(ChromeEndureBaseTest):
_WEBAPP_NAME = 'Docs'
_TAB_TITLE_SUBSTRING = 'Google Drive'
- def setUp(self):
- ChromeEndureBaseTest.setUp(self)
+ def _DocsSetUp(self, test_name):
+ """Set up before each test runs."""
+
+ # Start the Web Page Replay server.
+ self._StartReplayServerIfNecessary(test_name)
# Log into a test Google account and open up Google Docs.
self._LoginToGoogleAccount()
@@ -958,6 +1011,11 @@ class ChromeEndureDocsTest(ChromeEndureBaseTest):
self._driver = self.NewWebDriver()
+ def tearDown(self):
+ super(ChromeEndureDocsTest, self).tearDown()
+ # Stop the Web Page Replay server after all connections to it closed.
+ self._StopReplayServerIfNecessary()
+
def testDocsAlternatelyClickLists(self):
"""Alternates between two different document lists.
@@ -966,6 +1024,7 @@ class ChromeEndureDocsTest(ChromeEndureBaseTest):
memory bloat.
"""
test_description = 'AlternateLists'
+ self._DocsSetUp(test_description)
def scenario():
# Click the "Shared with me" button, wait for 1 second, click the
@@ -1004,8 +1063,11 @@ class ChromeEndurePlusTest(ChromeEndureBaseTest):
_WEBAPP_NAME = 'Plus'
_TAB_TITLE_SUBSTRING = 'Google+'
- def setUp(self):
- ChromeEndureBaseTest.setUp(self)
+ def _PlusSetUp(self, test_name):
+ """Set up before each test runs."""
+
+ # Start the Web Page Replay server.
+ self._StartReplayServerIfNecessary(test_name)
# Log into a test Google account and open up Google Plus.
self._LoginToGoogleAccount()
@@ -1017,6 +1079,11 @@ class ChromeEndurePlusTest(ChromeEndureBaseTest):
self._driver = self.NewWebDriver()
+ def tearDown(self):
+ super(ChromeEndurePlusTest, self).tearDown()
+ # Stop the Web Page Replay server after all connections to it closed.
+ self._StopReplayServerIfNecessary()
+
def testPlusAlternatelyClickStreams(self):
"""Alternates between two different streams.
@@ -1025,6 +1092,7 @@ class ChromeEndurePlusTest(ChromeEndureBaseTest):
memory bloat.
"""
test_description = 'AlternateStreams'
+ self._PlusSetUp(test_description)
# TODO(dennisjeffrey): Remove following line once crosbug.com/32357 is
# fixed.
@@ -1124,5 +1192,32 @@ class IndexedDBOfflineTest(ChromeEndureBaseTest):
test_description, scenario)
+class ChromeEndureWebPageReplay(perf.BaseWebPageReplay):
+ """Set up Web Page Replay server for Endure tests.
+
+ This class inherits from perf.BaseWebPageReplay to allow different settings
+ for the Web Page Replay server.
+
dennis_jeffrey 2012/07/24 00:39:35 remove this blank line
fdeng1 2012/07/24 04:30:05 Done.
+ """
+
+ def __init__(self):
+ # 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.
+ super(ChromeEndureWebPageReplay, self).__init__()
+
+ # 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.
+ extra_paths = {
+ 'archive':
+ 'src/chrome/test/data/chrome_endure/webpagereplay/{test_name}.wpr',
+ 'scripts': 'src/chrome/test/data/chrome_endure/deterministic.js',
+ }
+ self._paths.update(extra_paths)
+
+ # 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.
+ assert os.path.exists(self.Path('scripts')), (
+ 'The scripts to be injected do not exist: %s' %
+ self.Path('scripts'))
+ self._replay_flags.append('--inject_scripts=%s' % self.Path('scripts'))
+
+
if __name__ == '__main__':
pyauto_functional.Main()
« 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