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

Side by Side Diff: testing/chromoting/browser_tests_launcher.py

Issue 1172183003: Retry Chromoting browser-test execution if test times-out without launching browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « testing/chromoting/browser_test_commands_linux.txt ('k') | 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 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 """Utility script to launch browser-tests on the Chromoting bot.""" 6 """Utility script to launch browser-tests on the Chromoting bot."""
7 import argparse 7 import argparse
8 import glob 8 import glob
9 import hashlib 9 import hashlib
10 import os 10 import os
11 from os.path import expanduser 11 from os.path import expanduser
12 import shutil 12 import shutil
13 import socket 13 import socket
14 import subprocess 14 import subprocess
15 15
16 import psutil 16 import psutil
17 17
18 BROWSER_TEST_ID = 'browser_tests' 18 BROWSER_TEST_ID = 'browser_tests'
19 PROD_DIR_ID = '#PROD_DIR#' 19 PROD_DIR_ID = '#PROD_DIR#'
20 HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest() 20 HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest()
21 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.' 21 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.'
22 NATIVE_MESSAGING_DIR = 'NativeMessagingHosts' 22 NATIVE_MESSAGING_DIR = 'NativeMessagingHosts'
23 CRD_ID = 'chrome-remote-desktop' # Used in a few file/folder names 23 CRD_ID = 'chrome-remote-desktop' # Used in a few file/folder names
24 CHROMOTING_HOST_PATH = '/opt/google/chrome-remote-desktop/chrome-remote-desktop' 24 CHROMOTING_HOST_PATH = '/opt/google/chrome-remote-desktop/chrome-remote-desktop'
25 TEST_FAILURE = False 25 TEST_FAILURE = False
26 FAILING_TESTS = '' 26 FAILING_TESTS = ''
27 HOST_READY_INDICATOR = 'Host ready to receive connections.' 27 HOST_READY_INDICATOR = 'Host ready to receive connections.'
28 BROWSER_NOT_STARTED_ERROR = (
29 'Still waiting for the following processes to finish')
30 TIME_OUT_INDICATOR = '(TIMED OUT)'
28 31
29 32
30 def LaunchBTCommand(command): 33 def LaunchBTCommand(args, command):
34 """Launches the specified browser-test command.
35
36 If the execution failed because a browser-instance was not launched, retry
37 once.
38 Args:
39 args: Command line args, used for test-case startup tasks.
40 command: Browser-test command line.
41 """
31 global TEST_FAILURE, FAILING_TESTS 42 global TEST_FAILURE, FAILING_TESTS
32 results = RunCommandInSubProcess(command) 43 results = RunCommandInSubProcess(command)
33 44
joedow 2015/06/09 23:59:32 I think you should move the TestCaseSetup() call f
anandc 2015/06/10 01:02:12 Done.
45 # Sometimes, during execution of browser-tests, a browser instance is
46 # not started and the test times out. See http://crbug/480025.
47 # To work around it, check if this execution failed owing to that
48 # problem and retry.
49 # There are 2 things to look for in the results:
50 # A line saying "Still waiting for the following processes to finish",
51 # and, because sometimes that line gets logged even if the test
52 # eventually passes, we'll also look for "(TIMED OUT)", before retrying.
joedow 2015/06/09 23:59:32 Just curious, is there an error code we can key of
anandc 2015/06/10 01:02:12 There doesn't seem to be a special error code for
53 if BROWSER_NOT_STARTED_ERROR in results and TIME_OUT_INDICATOR in results:
54 # Retry test execution once.
55 TestCaseSetup(args)
56 results = RunCommandInSubProcess(command)
57
34 # Check that the test passed. 58 # Check that the test passed.
35 if SUCCESS_INDICATOR not in results: 59 if SUCCESS_INDICATOR not in results:
36 TEST_FAILURE = True 60 TEST_FAILURE = True
37 # Add this command-line to list of tests that failed. 61 # Add this command-line to list of tests that failed.
38 FAILING_TESTS += command 62 FAILING_TESTS += command
39 63
40 64
41 def RunCommandInSubProcess(command): 65 def RunCommandInSubProcess(command):
42 """Creates a subprocess with command-line that is passed in. 66 """Creates a subprocess with command-line that is passed in.
43 67
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 190
167 def PrintRunningProcesses(): 191 def PrintRunningProcesses():
168 processes = psutil.get_process_list() 192 processes = psutil.get_process_list()
169 processes = sorted(processes, key=lambda process: process.name) 193 processes = sorted(processes, key=lambda process: process.name)
170 194
171 print 'List of running processes:\n' 195 print 'List of running processes:\n'
172 for process in processes: 196 for process in processes:
173 print process.name 197 print process.name
174 198
175 199
200 def TestCaseSetup(args):
201 # Stop+start me2me host process.
202 if not RestartMe2MeHost():
203 # Host restart failed. Don't run any more tests.
204 raise Exception('Host restart failed.')
205
206 # Reset the user profile directory to start each test with a clean slate.
207 SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file,
208 args.user_profile_dir)
209
210
176 def main(args): 211 def main(args):
177 212
178 InitialiseTestMachineForLinux(args.cfg_file) 213 InitialiseTestMachineForLinux(args.cfg_file)
179 214
180 with open(args.commands_file) as f: 215 with open(args.commands_file) as f:
181 for line in f: 216 for line in f:
182 # Reset the user profile directory to start each test with a clean slate. 217 TestCaseSetup(args)
183 SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file,
184 args.user_profile_dir)
185
186 # Replace the PROD_DIR value in the command-line with 218 # Replace the PROD_DIR value in the command-line with
187 # the passed in value. 219 # the passed in value.
188 line = line.replace(PROD_DIR_ID, args.prod_dir) 220 line = line.replace(PROD_DIR_ID, args.prod_dir)
189 # Launch specified command line for test. 221 # Launch specified command line for test.
190 LaunchBTCommand(line) 222 LaunchBTCommand(args, line)
191 # After each test, stop+start me2me host process.
192 if not RestartMe2MeHost():
193 # Host restart failed. Don't run any more tests.
194 raise Exception('Host restart failed.')
195
196 # Print list of currently running processes.
197 PrintRunningProcesses()
198 223
199 # All tests completed. Include host-logs in the test results. 224 # All tests completed. Include host-logs in the test results.
200 host_log_contents = '' 225 host_log_contents = ''
201 # There should be only 1 log file, as we delete logs on test completion. 226 # There should be only 1 log file, as we delete logs on test completion.
202 # Loop through matching files, just in case there are more. 227 # Loop through matching files, just in case there are more.
203 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'): 228 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'):
204 with open(log_file, 'r') as log: 229 with open(log_file, 'r') as log:
205 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % ( 230 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % (
206 log_file, log.read()) 231 log_file, log.read())
207 print host_log_contents 232 print host_log_contents
(...skipping 20 matching lines...) Expand all
228 help='path to it2me host manifest file.') 253 help='path to it2me host manifest file.')
229 parser.add_argument( 254 parser.add_argument(
230 '-u', '--user_profile_dir', 255 '-u', '--user_profile_dir',
231 help='path to user-profile-dir, used by connect-to-host tests.') 256 help='path to user-profile-dir, used by connect-to-host tests.')
232 command_line_args = parser.parse_args() 257 command_line_args = parser.parse_args()
233 try: 258 try:
234 main(command_line_args) 259 main(command_line_args)
235 finally: 260 finally:
236 # Stop host and cleanup user-profile-dir. 261 # Stop host and cleanup user-profile-dir.
237 TestMachineCleanup(command_line_args.user_profile_dir) 262 TestMachineCleanup(command_line_args.user_profile_dir)
OLDNEW
« no previous file with comments | « testing/chromoting/browser_test_commands_linux.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698