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

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

Issue 2618863002: [Offline Pages] Rename page names saved by test harness to hostnames. (Closed)
Patch Set: Adding full path, removing GUID. Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ --user-requested -use-test-scheduler 18 # ~/offline_eval_short_output/ --user-requested -use-test-scheduler
19 # $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 re
24 import shutil 25 import shutil
25 import subprocess 26 import subprocess
26 import sys 27 import sys
28 import urlparse
27 29
28 DEFAULT_USER_REQUEST = True 30 DEFAULT_USER_REQUEST = True
29 DEFAULT_USE_TEST_SCHEDULER = True 31 DEFAULT_USE_TEST_SCHEDULER = True
30 # 0 means the batch would be the whole list of urls. 32 # 0 means the batch would be the whole list of urls.
31 DEFAULT_BATCH_SIZE = 0 33 DEFAULT_BATCH_SIZE = 0
32 DEFAULT_VERBOSE = False 34 DEFAULT_VERBOSE = False
33 CONFIG_FILENAME = 'test_config' 35 CONFIG_FILENAME = 'test_config'
34 CONFIG_TEMPLATE = """\ 36 CONFIG_TEMPLATE = """\
35 IsUserRequested = {is_user_requested} 37 IsUserRequested = {is_user_requested}
36 UseTestScheduler = {use_test_scheduler} 38 UseTestScheduler = {use_test_scheduler}
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 # Run test with timeout-scale as 20.0 and strict mode off. 150 # Run test with timeout-scale as 20.0 and strict mode off.
149 # This scale is only applied to timeouts which are defined as scalable ones 151 # This scale is only applied to timeouts which are defined as scalable ones
150 # in the test framework (like the timeout used to decide if Chrome doesn't 152 # in the test framework (like the timeout used to decide if Chrome doesn't
151 # start properly), on svelte devices we would hit the 'no tab selected' 153 # start properly), on svelte devices we would hit the 'no tab selected'
152 # assertion since the starting time is longer than expected by the framework. 154 # assertion since the starting time is longer than expected by the framework.
153 # So we're setting the scale to 20. It will not affect the annotation-based 155 # So we're setting the scale to 20. It will not affect the annotation-based
154 # timeouts. 156 # timeouts.
155 # Also turning off the strict mode so that we won't run into StrictMode 157 # Also turning off the strict mode so that we won't run into StrictMode
156 # violations when writing to files. 158 # violations when writing to files.
157 test_runner_cmd = [ 159 test_runner_cmd = [
158 test_runner_path, '-f', 160 test_runner_path,
161 '-f',
159 'OfflinePageSavePageLaterEvaluationTest.testFailureRate', 162 'OfflinePageSavePageLaterEvaluationTest.testFailureRate',
160 '--timeout-scale', '20.0', '--strict-mode', 'off', 163 '--timeout-scale',
164 '20.0',
165 '--strict-mode',
166 'off',
161 ] 167 ]
162 if options.verbose: 168 if options.verbose:
163 test_runner_cmd += ['-v'] 169 test_runner_cmd += ['-v']
164 if options.device_id != None: 170 if options.device_id != None:
165 test_runner_cmd += ['-d', options.device_id] 171 test_runner_cmd += ['-d', options.device_id]
166 subprocess.call(test_runner_cmd) 172 subprocess.call(test_runner_cmd)
167 173
168 print 'Fetching results from device...' 174 print 'Fetching results from device...'
169 archive_dir = os.path.join(options.output_dir, 'archives/') 175 archive_dir = os.path.join(options.output_dir, 'archives/')
170 if os.path.exists(archive_dir): 176 if os.path.exists(archive_dir):
171 shutil.rmtree(archive_dir) 177 shutil.rmtree(archive_dir)
172 subprocess.call( 178 subprocess.call(
173 get_adb_command(['pull', external_dir + '/paquete/archives', archive_dir 179 get_adb_command(['pull', external_dir + '/paquete/archives', archive_dir
174 ])) 180 ]))
175 subprocess.call( 181 subprocess.call(
176 get_adb_command([ 182 get_adb_command([
177 'pull', external_dir + '/paquete/offline_eval_results.txt', 183 'pull', external_dir + '/paquete/offline_eval_results.txt',
178 options.output_dir 184 options.output_dir
179 ])) 185 ]))
180 subprocess.call( 186 subprocess.call(
181 get_adb_command([ 187 get_adb_command([
182 'pull', external_dir + '/paquete/offline_eval_logs.txt', 188 'pull', external_dir + '/paquete/offline_eval_logs.txt',
183 options.output_dir 189 options.output_dir
184 ])) 190 ]))
185 print 'Test finished!' 191 print 'Test finished!'
186 192
193 print 'Renaming archive files with host names.'
194 pattern = 'Content-Location: (.*)'
195 for filename in os.listdir(archive_dir):
196 path = os.path.join(archive_dir, filename)
197 with open(path) as f:
198 content = f.read()
199 result = re.search(pattern, content)
200 if (result == None):
201 continue
202 url = result.group(1)
203 url_parse = urlparse.urlparse(url)
204 hostname = url_parse[1].replace('.', '_')
205 url_path = re.sub('[^0-9a-zA-Z]+', '_', url_parse[2][1:])
206
207 if (len(hostname) == 0):
208 hostname = 'error_parsing_hostname'
209 continue
210 newname = hostname + '-' + url_path
211 newpath = os.path.join(archive_dir, newname + '.mhtml')
212 os.rename(path, newpath)
213 print 'Renaming finished.'
214
187 215
188 if __name__ == '__main__': 216 if __name__ == '__main__':
189 sys.exit(main(sys.argv[1:])) 217 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698