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

Unified Diff: chrome/test/functional/record_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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/record_endure.py
diff --git a/chrome/test/functional/record_endure.py b/chrome/test/functional/record_endure.py
new file mode 100755
index 0000000000000000000000000000000000000000..6edb4df3a0aa565ed5f709ca0dcd1dbc1a810c23
--- /dev/null
+++ b/chrome/test/functional/record_endure.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Record webapp interactions using Web Page Replay for Endure test.
+
+Usage:
+ ./record_endure.py [options] test_or_suite_1 [test_or_suite_2] ...
Nirnimesh 2012/08/06 21:36:45 remove ./ prefix python (so that it works on win)
+ Please make sure that perf_endure.py is in the current working directory.
+Examples:
+ 1) ./record_endure.py perf.ChromeEndureGmailTest
+
+ The above command runs each test in perf.ChromeEndureGmailTest. By default,
+ it runs each test for 30 secs and saves the archive file to 'archive.wpr' in
+ the current working directory.
+
+ 2) ./record_endure.py --test-length=40 \\
dennis_jeffrey 2012/08/06 21:33:46 just put a single \ at the end of this line, not 2
+ --archive-file="/home/user/ChromeEndureGmailTest.wpr" \\
dennis_jeffrey 2012/08/06 21:33:46 just put a single \ at the end of this line, not 2
+ perf.ChromeEndureGmailTest
+
+ The above command runs each test for 40 seconds and saves the archive to
+ /home/user/ChromeEndureGmailTest.wpr
+"""
+
+import optparse
+import os
+import subprocess
+import sys
+
+import perf
+import webpagereplay
+
+
+class PlainHelpFormatter(optparse.IndentedHelpFormatter):
+ """Format the help message of this script."""
+
+ def format_description(self, description):
+ if description:
+ return description + '\n'
+ else:
+ return ''
+
+
+class Recorder(object):
+ """Record webapp interactions of Endure tests via Web Page Replay."""
+
+ @classmethod
+ def _ParseArgs(cls):
+ parser = optparse.OptionParser(
+ usage='%prog [options] test_or_suite_1 [test_or_suite_2] ...',
+ formatter=PlainHelpFormatter(),
+ description=__doc__)
+ message = 'Length of each test in seconds. Default value is 30 secs.'
+ parser.add_option('--test-length', type='int', default=30,
+ help=message)
+ message = 'Path and name of the archive file. Default value is ' \
+ '<CURRENT_WORKING_DIR>/archive.wpr'
+ parser.add_option('--archive-file', type='string', default='archive.wpr',
+ help=message)
+ options, args = parser.parse_args()
+ if len(args) < 1:
+ parser.error('Invalid arguments. Use --help to see usage.')
+ return options, args
+
+ @classmethod
+ def Main(cls):
+ """Set up Web Page Replay and run Endure tests."""
+ options, args = cls._ParseArgs()
+ test_length = options.test_length
+ # Use a greater value than test length to disable stats.
+ perf_stats_interval = test_length + 60
+ archive_path = os.path.abspath(options.archive_file)
+ tests = args[0:]
+ script_path = 'src/chrome/test/data/chrome_endure/' \
+ 'webpagereplay/wpr_deterministic.js'
slamm_google 2012/08/06 20:58:44 It is redundant to have this path here. Is there a
dennis_jeffrey 2012/08/06 21:33:46 We need to be able to start WPR in record mode, ru
+ replay_options = [
+ '--record',
+ '--inject_scripts', perf.FormatChromePath(script_path),
+ ]
+ with webpagereplay.ReplayServer(archive_path, replay_options):
+ env = os.environ.copy()
+ env.update({
+ 'TEST_LENGTH': str(test_length),
+ 'PERF_STATS_INTERVAL': str(perf_stats_interval),
+ 'WPR_RECORD': '1',
+ 'DO_NOT_RESTART_PYTHON_FOR_PYAUTO': '1',
+ })
+
+ cmd = ['python', 'perf_endure.py']
+ cmd.extend(tests)
+ print cmd
+ code = subprocess.call(cmd, env=env)
+ print 'Shutting down server.'
+ if (code == 0 and os.path.exists(archive_path) and
+ os.path.isfile(archive_path)):
+ print 'Archive is saved to %s' % archive_path
+ return 0
+ else:
+ print ('Error in recording. The output archive might be invalid. ' +
+ 'See log: %s' % webpagereplay.LOG_PATH)
+ return 1
+
+
+if __name__ == '__main__':
+ sys.exit(Recorder().Main())
« chrome/test/functional/perf_endure.py ('K') | « chrome/test/functional/perf_endure.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698