OLD | NEW |
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 |
| 17 |
16 BROWSER_TEST_ID = 'browser_tests' | 18 BROWSER_TEST_ID = 'browser_tests' |
17 PROD_DIR_ID = '#PROD_DIR#' | 19 PROD_DIR_ID = '#PROD_DIR#' |
18 HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest() | 20 HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest() |
19 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.' | 21 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.' |
20 NATIVE_MESSAGING_DIR = 'NativeMessagingHosts' | 22 NATIVE_MESSAGING_DIR = 'NativeMessagingHosts' |
21 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 |
22 CHROMOTING_HOST_PATH = '/opt/google/chrome-remote-desktop/chrome-remote-desktop' | 24 CHROMOTING_HOST_PATH = '/opt/google/chrome-remote-desktop/chrome-remote-desktop' |
23 TEST_FAILURE = False | 25 TEST_FAILURE = False |
24 FAILING_TESTS = '' | 26 FAILING_TESTS = '' |
25 HOST_READY_INDICATOR = 'Host ready to receive connections.' | 27 HOST_READY_INDICATOR = 'Host ready to receive connections.' |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 os.makedirs(native_messaging_folder) | 157 os.makedirs(native_messaging_folder) |
156 | 158 |
157 manifest_files = [me2me_manifest_file, it2me_manifest_file] | 159 manifest_files = [me2me_manifest_file, it2me_manifest_file] |
158 for manifest_file in manifest_files: | 160 for manifest_file in manifest_files: |
159 manifest_file_src = os.path.join(os.getcwd(), manifest_file) | 161 manifest_file_src = os.path.join(os.getcwd(), manifest_file) |
160 manifest_file_dest = ( | 162 manifest_file_dest = ( |
161 os.path.join(native_messaging_folder, os.path.basename(manifest_file))) | 163 os.path.join(native_messaging_folder, os.path.basename(manifest_file))) |
162 shutil.copyfile(manifest_file_src, manifest_file_dest) | 164 shutil.copyfile(manifest_file_src, manifest_file_dest) |
163 | 165 |
164 | 166 |
| 167 def PrintRunningProcesses(): |
| 168 processes = psutil.get_process_list() |
| 169 processes = sorted(processes, key=lambda process: process.name) |
| 170 |
| 171 print 'List of running processes:\n' |
| 172 for process in processes: |
| 173 print process.name |
| 174 |
| 175 |
165 def main(args): | 176 def main(args): |
166 | 177 |
167 InitialiseTestMachineForLinux(args.cfg_file) | 178 InitialiseTestMachineForLinux(args.cfg_file) |
168 | 179 |
169 with open(args.commands_file) as f: | 180 with open(args.commands_file) as f: |
170 for line in f: | 181 for line in f: |
171 # Reset the user profile directory to start each test with a clean slate. | 182 # Reset the user profile directory to start each test with a clean slate. |
172 SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file, | 183 SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file, |
173 args.user_profile_dir) | 184 args.user_profile_dir) |
174 | 185 |
175 # Replace the PROD_DIR value in the command-line with | 186 # Replace the PROD_DIR value in the command-line with |
176 # the passed in value. | 187 # the passed in value. |
177 line = line.replace(PROD_DIR_ID, args.prod_dir) | 188 line = line.replace(PROD_DIR_ID, args.prod_dir) |
178 # Launch specified command line for test. | 189 # Launch specified command line for test. |
179 LaunchBTCommand(line) | 190 LaunchBTCommand(line) |
180 # After each test, stop+start me2me host process. | 191 # After each test, stop+start me2me host process. |
181 if not RestartMe2MeHost(): | 192 if not RestartMe2MeHost(): |
182 # Host restart failed. Don't run any more tests. | 193 # Host restart failed. Don't run any more tests. |
183 raise Exception('Host restart failed.') | 194 raise Exception('Host restart failed.') |
184 | 195 |
| 196 # Print list of currently running processes. |
| 197 PrintRunningProcesses() |
| 198 |
185 # All tests completed. Include host-logs in the test results. | 199 # All tests completed. Include host-logs in the test results. |
186 host_log_contents = '' | 200 host_log_contents = '' |
187 # There should be only 1 log file, as we delete logs on test completion. | 201 # There should be only 1 log file, as we delete logs on test completion. |
188 # Loop through matching files, just in case there are more. | 202 # Loop through matching files, just in case there are more. |
189 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'): | 203 for log_file in glob.glob('/tmp/chrome_remote_desktop_*'): |
190 with open(log_file, 'r') as log: | 204 with open(log_file, 'r') as log: |
191 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % ( | 205 host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % ( |
192 log_file, log.read()) | 206 log_file, log.read()) |
193 print host_log_contents | 207 print host_log_contents |
194 | 208 |
(...skipping 19 matching lines...) Expand all Loading... |
214 help='path to it2me host manifest file.') | 228 help='path to it2me host manifest file.') |
215 parser.add_argument( | 229 parser.add_argument( |
216 '-u', '--user_profile_dir', | 230 '-u', '--user_profile_dir', |
217 help='path to user-profile-dir, used by connect-to-host tests.') | 231 help='path to user-profile-dir, used by connect-to-host tests.') |
218 command_line_args = parser.parse_args() | 232 command_line_args = parser.parse_args() |
219 try: | 233 try: |
220 main(command_line_args) | 234 main(command_line_args) |
221 finally: | 235 finally: |
222 # Stop host and cleanup user-profile-dir. | 236 # Stop host and cleanup user-profile-dir. |
223 TestMachineCleanup(command_line_args.user_profile_dir) | 237 TestMachineCleanup(command_line_args.user_profile_dir) |
OLD | NEW |