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

Side by Side Diff: chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py

Issue 2518733002: [Offline Pages] Remove timeout in test harness. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2016 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 # 6 #
7 # 7 #
8 # This script is used to run OfflinePageSavePageLaterEvaluationTests. 8 # This script is used to run OfflinePageSavePageLaterEvaluationTests.
9 # The test will try to call SavePageLater on the list provided as the input, 9 # The test will try to call SavePageLater on the list provided as the input,
10 # and generate results of the background offlining. Then it will pull the 10 # and generate results of the background offlining. Then it will pull the
11 # results to the output directory. 11 # results to the output directory.
12 # 12 #
13 # Example Steps: 13 # Example Steps:
14 # 1. Build chrome_public_test_apk 14 # 1. Build chrome_public_test_apk
15 # 2. Prepare a list of urls. 15 # 2. Prepare a list of urls.
16 # 3. Run the script (use -d when you have more than one device connected.) 16 # 3. Run the script (use -d when you have more than one device connected.)
17 # run_offline_page_evaluation_test.py --output-directory 17 # run_offline_page_evaluation_test.py --output-directory
18 # ~/offline_eval_short_output/ --url-timeout 150 --user-requested=true 18 # ~/offline_eval_short_output/ --user-requested=true -use-test-scheduler=true
19 # --use-test-scheduler=true $CHROME_SRC/out/Default ~/offline_eval_urls.txt 19 # $CHROME_SRC/out/Default ~/offline_eval_urls.txt
20 # 4. Check the results in the output directory. 20 # 4. Check the results in the output directory.
21 21
22 import argparse 22 import argparse
23 import os 23 import os
24 import shutil 24 import shutil
25 import subprocess 25 import subprocess
26 import sys 26 import sys
27 27
28 DEFAULT_URL_TIMEOUT = 60 * 8
29 DEFAULT_USER_REQUEST = True 28 DEFAULT_USER_REQUEST = True
30 DEFAULT_USE_TEST_SCHEDULER = False 29 DEFAULT_USE_TEST_SCHEDULER = False
31 DEFAULT_VERBOSE = False 30 DEFAULT_VERBOSE = False
32 CONFIG_FILENAME = 'test_config' 31 CONFIG_FILENAME = 'test_config'
33 CONFIG_TEMPLATE = """\ 32 CONFIG_TEMPLATE = """\
34 TimeoutPerUrlInSeconds = {timeout_per_url_in_seconds}
35 IsUserRequested = {is_user_requested} 33 IsUserRequested = {is_user_requested}
36 UseTestScheduler = {use_test_scheduler} 34 UseTestScheduler = {use_test_scheduler}
37 """ 35 """
38 36
39 37
40 def main(args): 38 def main(args):
41 # Setting up the argument parser. 39 # Setting up the argument parser.
42 parser = argparse.ArgumentParser() 40 parser = argparse.ArgumentParser()
43 parser.add_argument( 41 parser.add_argument(
44 '--output-directory', 42 '--output-directory',
45 dest='output_dir', 43 dest='output_dir',
46 help='Directory for output. Default is ~/offline_eval_output/') 44 help='Directory for output. Default is ~/offline_eval_output/')
47 parser.add_argument( 45 parser.add_argument(
48 '--url-timeout',
49 type=int,
50 dest='url_timeout',
51 help='Time out per url, in seconds. Default is 480 seconds.')
52 parser.add_argument(
53 '--user-requested', 46 '--user-requested',
54 dest='user_request', 47 dest='user_request',
55 action='store_true', 48 action='store_true',
56 help='Testing as user-requested urls. Default option.') 49 help='Testing as user-requested urls. Default option.')
57 parser.add_argument( 50 parser.add_argument(
58 '--not-user-requested', 51 '--not-user-requested',
59 dest='user_request', 52 dest='user_request',
60 action='store_false', 53 action='store_false',
61 help='Testing as not user-requested urls.') 54 help='Testing as not user-requested urls.')
62 parser.add_argument( 55 parser.add_argument(
(...skipping 16 matching lines...) Expand all
79 '-d', 72 '-d',
80 '--device', 73 '--device',
81 type=str, 74 type=str,
82 dest='device_id', 75 dest='device_id',
83 help='Specify which device to be used. See \'adb devices\'.') 76 help='Specify which device to be used. See \'adb devices\'.')
84 parser.add_argument('build_output_dir', help='Path to build directory.') 77 parser.add_argument('build_output_dir', help='Path to build directory.')
85 parser.add_argument( 78 parser.add_argument(
86 'test_urls_file', help='Path to input file with urls to be tested.') 79 'test_urls_file', help='Path to input file with urls to be tested.')
87 parser.set_defaults( 80 parser.set_defaults(
88 output_dir=os.path.expanduser('~/offline_eval_output'), 81 output_dir=os.path.expanduser('~/offline_eval_output'),
89 url_timeout=DEFAULT_URL_TIMEOUT,
90 user_request=DEFAULT_USER_REQUEST, 82 user_request=DEFAULT_USER_REQUEST,
91 user_test_scheduler=DEFAULT_USE_TEST_SCHEDULER, 83 user_test_scheduler=DEFAULT_USE_TEST_SCHEDULER,
92 verbose=DEFAULT_VERBOSE) 84 verbose=DEFAULT_VERBOSE)
93 85
94 def get_adb_command(args): 86 def get_adb_command(args):
95 if options.device_id != None: 87 if options.device_id != None:
96 return ['adb', '-s', options.device_id] + args 88 return ['adb', '-s', options.device_id] + args
97 return ['adb'] + args 89 return ['adb'] + args
98 90
99 # Get the arguments and several paths. 91 # Get the arguments and several paths.
(...skipping 13 matching lines...) Expand all
113 get_adb_command(['shell', 'echo', '$EXTERNAL_STORAGE'])).strip() 105 get_adb_command(['shell', 'echo', '$EXTERNAL_STORAGE'])).strip()
114 106
115 # Create the output directory for results, and have a copy of test config 107 # Create the output directory for results, and have a copy of test config
116 # there. 108 # there.
117 if not os.path.exists(options.output_dir): 109 if not os.path.exists(options.output_dir):
118 print 'Creating output directory for results... ' + options.output_dir 110 print 'Creating output directory for results... ' + options.output_dir
119 os.makedirs(options.output_dir) 111 os.makedirs(options.output_dir)
120 with open(config_output_path, 'w') as config: 112 with open(config_output_path, 'w') as config:
121 config.write( 113 config.write(
122 CONFIG_TEMPLATE.format( 114 CONFIG_TEMPLATE.format(
123 timeout_per_url_in_seconds=options.url_timeout,
124 is_user_requested=options.user_request, 115 is_user_requested=options.user_request,
125 use_test_scheduler=options.use_test_scheduler)) 116 use_test_scheduler=options.use_test_scheduler))
126 117
127 print 'Uploading config file and input file onto the device.' 118 print 'Uploading config file and input file onto the device.'
128 subprocess.call( 119 subprocess.call(
129 get_adb_command( 120 get_adb_command(
130 ['push', config_output_path, external_dir + '/paquete/test_config'])) 121 ['push', config_output_path, external_dir + '/paquete/test_config']))
131 subprocess.call( 122 subprocess.call(
132 get_adb_command([ 123 get_adb_command([
133 'push', options.test_urls_file, 124 'push', options.test_urls_file,
134 '/sdcard/paquete/offline_eval_urls.txt' 125 '/sdcard/paquete/offline_eval_urls.txt'
135 ])) 126 ]))
136 print 'Start running test...' 127 print 'Start running test...'
137 128
138 # Run test 129 # Run test
139 test_runner_cmd = [ 130 test_runner_cmd = [
140 test_runner_path, '-f', 131 test_runner_path, '-f',
141 'OfflinePageSavePageLaterEvaluationTest.testFailureRateWithTimeout' 132 'OfflinePageSavePageLaterEvaluationTest.testFailureRate'
142 ] 133 ]
143 if options.verbose: 134 if options.verbose:
144 test_runner_cmd += ['-v'] 135 test_runner_cmd += ['-v']
145 subprocess.call(test_runner_cmd) 136 subprocess.call(test_runner_cmd)
146 137
147 print 'Fetching results from device...' 138 print 'Fetching results from device...'
148 archive_dir = os.path.join(options.output_dir, 'archives/') 139 archive_dir = os.path.join(options.output_dir, 'archives/')
149 if os.path.exists(archive_dir): 140 if os.path.exists(archive_dir):
150 shutil.rmtree(archive_dir) 141 shutil.rmtree(archive_dir)
151 subprocess.call( 142 subprocess.call(
152 get_adb_command( 143 get_adb_command(
153 ['pull', external_dir + '/paquete/archives', archive_dir])) 144 ['pull', external_dir + '/paquete/archives', archive_dir]))
154 subprocess.call( 145 subprocess.call(
155 get_adb_command([ 146 get_adb_command([
156 'pull', external_dir + '/paquete/offline_eval_results.txt', 147 'pull', external_dir + '/paquete/offline_eval_results.txt',
157 options.output_dir 148 options.output_dir
158 ])) 149 ]))
159 subprocess.call( 150 subprocess.call(
160 get_adb_command([ 151 get_adb_command([
161 'pull', external_dir + '/paquete/offline_eval_logs.txt', 152 'pull', external_dir + '/paquete/offline_eval_logs.txt',
162 options.output_dir 153 options.output_dir
163 ])) 154 ]))
164 print 'Test finished!' 155 print 'Test finished!'
165 156
166 157
167 if __name__ == '__main__': 158 if __name__ == '__main__':
168 sys.exit(main(sys.argv[1:])) 159 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698