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

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

Issue 1279823004: Custom install me2me host on Linux Swarming bots. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary global. Created 5 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 unified diff | Download patch
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 = './remoting/host/linux/linux_me2me_host.py'
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 = ( 28 BROWSER_NOT_STARTED_ERROR = (
29 'Still waiting for the following processes to finish') 29 'Still waiting for the following processes to finish')
30 TIME_OUT_INDICATOR = '(TIMED OUT)' 30 TIME_OUT_INDICATOR = '(TIMED OUT)'
31 MAX_RETRIES = 1 31 MAX_RETRIES = 1
32 # On a Swarming bot where these tests are executed, a temp folder is created
33 # under which the files specified in an .isolate are copied. This temp folder
34 # has a random name, which we'll store here for use later.
35 # Note that the test-execution always starts from the testing/chromoting folder
36 # under the temp folder.
37 ISOLATE_TEMP_FOLDER = os.path.abspath(os.path.join(os.getcwd(), '../..'))
32 38
33 39
34 def LaunchBTCommand(args, command): 40 def LaunchBTCommand(args, command):
35 """Launches the specified browser-test command. 41 """Launches the specified browser-test command.
36 42
37 If the execution failed because a browser-instance was not launched, retry 43 If the execution failed because a browser-instance was not launched, retry
38 once. 44 once.
39 Args: 45 Args:
40 args: Command line args, used for test-case startup tasks. 46 args: Command line args, used for test-case startup tasks.
41 command: Browser-test command line. 47 command: Browser-test command line.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 def RestartMe2MeHost(): 155 def RestartMe2MeHost():
150 """Stops and starts the Me2Me host on the test machine. 156 """Stops and starts the Me2Me host on the test machine.
151 157
152 Waits to confirm that host is ready to receive connections before returning. 158 Waits to confirm that host is ready to receive connections before returning.
153 159
154 Returns: 160 Returns:
155 True: if HOST_READY_INDICATOR is found in stdout, indicating host is ready. 161 True: if HOST_READY_INDICATOR is found in stdout, indicating host is ready.
156 False: if HOST_READY_INDICATOR not found in stdout. 162 False: if HOST_READY_INDICATOR not found in stdout.
157 """ 163 """
158 164
165 # To start the host, we want to be in the temp-folder for this test execution.
166 # Store the current folder to return back to it later.
167 previous_directory = os.getcwd()
168 os.chdir(ISOLATE_TEMP_FOLDER)
169
159 # Stop chromoting host. 170 # Stop chromoting host.
160 RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop') 171 RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop')
161 # Start chromoting host. 172 # Start chromoting host.
162 results = RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start') 173 results = RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start')
174
175 os.chdir(previous_directory)
163 # Confirm that the start process completed, and we got: 176 # Confirm that the start process completed, and we got:
164 # "Host ready to receive connections." in the log. 177 # "Host ready to receive connections." in the log.
165 if HOST_READY_INDICATOR not in results: 178 if HOST_READY_INDICATOR not in results:
166 return False 179 return False
167 return True 180 return True
168 181
169 182
170 def SetupUserProfileDir(me2me_manifest_file, it2me_manifest_file, 183 def SetupUserProfileDir(me2me_manifest_file, it2me_manifest_file,
171 user_profile_dir): 184 user_profile_dir):
172 """Sets up the Google Chrome user profile directory. 185 """Sets up the Google Chrome user profile directory.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 with open(args.commands_file) as f: 238 with open(args.commands_file) as f:
226 for line in f: 239 for line in f:
227 # Replace the PROD_DIR value in the command-line with 240 # Replace the PROD_DIR value in the command-line with
228 # the passed in value. 241 # the passed in value.
229 line = line.replace(PROD_DIR_ID, args.prod_dir) 242 line = line.replace(PROD_DIR_ID, args.prod_dir)
230 # Launch specified command line for test. 243 # Launch specified command line for test.
231 LaunchBTCommand(args, line) 244 LaunchBTCommand(args, line)
232 245
233 # All tests completed. Include host-logs in the test results. 246 # All tests completed. Include host-logs in the test results.
234 host_log_contents = '' 247 host_log_contents = ''
235 # There should be only 1 log file, as we delete logs on test completion.
236 # Loop through matching files, just in case there are more.
237 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'): 248 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'):
238 with open(log_file, 'r') as log: 249 with open(log_file, 'r') as log:
239 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % ( 250 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % (
240 log_file, log.read()) 251 log_file, log.read())
241 print host_log_contents 252 print host_log_contents
242 253
243 # Was there any test failure?
244 if TEST_FAILURE: 254 if TEST_FAILURE:
245 print '++++++++++AT LEAST 1 TEST FAILED++++++++++' 255 print '++++++++++AT LEAST 1 TEST FAILED++++++++++'
246 print FAILING_TESTS.rstrip('\n') 256 print FAILING_TESTS.rstrip('\n')
247 print '++++++++++++++++++++++++++++++++++++++++++' 257 print '++++++++++++++++++++++++++++++++++++++++++'
248 raise Exception('At least one test failed.') 258 raise Exception('At least one test failed.')
249 259
250 if __name__ == '__main__': 260 if __name__ == '__main__':
251 261
252 parser = argparse.ArgumentParser() 262 parser = argparse.ArgumentParser()
253 parser.add_argument('-f', '--commands_file', 263 parser.add_argument('-f', '--commands_file',
254 help='path to file listing commands to be launched.') 264 help='path to file listing commands to be launched.')
255 parser.add_argument('-p', '--prod_dir', 265 parser.add_argument('-p', '--prod_dir',
256 help='path to folder having product and test binaries.') 266 help='path to folder having product and test binaries.')
257 parser.add_argument('-c', '--cfg_file', 267 parser.add_argument('-c', '--cfg_file',
258 help='path to test host config file.') 268 help='path to test host config file.')
259 parser.add_argument('--me2me_manifest_file', 269 parser.add_argument('--me2me_manifest_file',
260 help='path to me2me host manifest file.') 270 help='path to me2me host manifest file.')
261 parser.add_argument('--it2me_manifest_file', 271 parser.add_argument('--it2me_manifest_file',
262 help='path to it2me host manifest file.') 272 help='path to it2me host manifest file.')
263 parser.add_argument( 273 parser.add_argument(
264 '-u', '--user_profile_dir', 274 '-u', '--user_profile_dir',
265 help='path to user-profile-dir, used by connect-to-host tests.') 275 help='path to user-profile-dir, used by connect-to-host tests.')
266 command_line_args = parser.parse_args() 276 command_line_args = parser.parse_args()
267 try: 277 try:
268 main(command_line_args) 278 main(command_line_args)
269 finally: 279 finally:
270 # Stop host and cleanup user-profile-dir. 280 # Stop host and cleanup user-profile-dir.
271 TestMachineCleanup(command_line_args.user_profile_dir) 281 TestMachineCleanup(command_line_args.user_profile_dir)
OLDNEW
« no previous file with comments | « testing/chromoting/browser_test_commands_linux.txt ('k') | testing/chromoting/chromoting_integration_tests.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698