summaryrefslogtreecommitdiffstats
path: root/testing/chromoting
diff options
context:
space:
mode:
authortonychun <tonychun@google.com>2015-08-10 18:03:48 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-11 01:04:33 +0000
commit4a18f7fd54124950086edbb264fb968f8cb86d74 (patch)
tree171eadcbb8fe1a623e66a926ec199c8bd1129935 /testing/chromoting
parentb5b87ccc3a47a4e28d91dad7eaa5701f5b488311 (diff)
downloadchromium_src-4a18f7fd54124950086edbb264fb968f8cb86d74.zip
chromium_src-4a18f7fd54124950086edbb264fb968f8cb86d74.tar.gz
chromium_src-4a18f7fd54124950086edbb264fb968f8cb86d74.tar.bz2
Using chromoting_integration_tests.isolate for chromoting test driver.
Added my own launcher and renamed chromoting_integration_tests.isolate to browser_integration_tests.isolate. I've added chromoting_test_driver_commands_linux.txt to make it easy to add tests and run them for different hosts. Note: These changes should land after the changes to internal have been made. Some of the files specified in the isolate require those files. BUG= Review URL: https://codereview.chromium.org/1272713006 Cr-Commit-Position: refs/heads/master@{#342762}
Diffstat (limited to 'testing/chromoting')
-rw-r--r--testing/chromoting/browser_tests_launcher.py187
-rw-r--r--testing/chromoting/chromoting_browser_tests.isolate129
-rw-r--r--testing/chromoting/chromoting_integration_tests.isolate92
-rw-r--r--testing/chromoting/chromoting_test_driver_commands_linux.txt1
-rw-r--r--testing/chromoting/chromoting_test_driver_launcher.py98
-rw-r--r--testing/chromoting/chromoting_test_utilities.py190
-rw-r--r--testing/chromoting/dependencies.gypi1
-rw-r--r--testing/chromoting/integration_tests.gyp15
-rw-r--r--testing/chromoting/multi_machine_example/example_task.isolate2
-rwxr-xr-xtesting/chromoting/multi_machine_example/example_test_controller.py4
10 files changed, 451 insertions, 268 deletions
diff --git a/testing/chromoting/browser_tests_launcher.py b/testing/chromoting/browser_tests_launcher.py
index 47e7411..a5a2ff3 100644
--- a/testing/chromoting/browser_tests_launcher.py
+++ b/testing/chromoting/browser_tests_launcher.py
@@ -5,36 +5,21 @@
"""Utility script to launch browser-tests on the Chromoting bot."""
import argparse
-import glob
-import hashlib
-import os
-from os.path import expanduser
-import shutil
-import socket
-import subprocess
-import psutil
+from chromoting_test_utilities import InitialiseTestMachineForLinux
+from chromoting_test_utilities import PrintHostLogContents
+from chromoting_test_utilities import PROD_DIR_ID
+from chromoting_test_utilities import RunCommandInSubProcess
+from chromoting_test_utilities import TestCaseSetup
+from chromoting_test_utilities import TestMachineCleanup
-BROWSER_TEST_ID = 'browser_tests'
-PROD_DIR_ID = '#PROD_DIR#'
-HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest()
SUCCESS_INDICATOR = 'SUCCESS: all tests passed.'
-NATIVE_MESSAGING_DIR = 'NativeMessagingHosts'
-CRD_ID = 'chrome-remote-desktop' # Used in a few file/folder names
-CHROMOTING_HOST_PATH = './remoting/host/linux/linux_me2me_host.py'
TEST_FAILURE = False
FAILING_TESTS = ''
-HOST_READY_INDICATOR = 'Host ready to receive connections.'
BROWSER_NOT_STARTED_ERROR = (
'Still waiting for the following processes to finish')
TIME_OUT_INDICATOR = '(TIMED OUT)'
MAX_RETRIES = 1
-# On a Swarming bot where these tests are executed, a temp folder is created
-# under which the files specified in an .isolate are copied. This temp folder
-# has a random name, which we'll store here for use later.
-# Note that the test-execution always starts from the testing/chromoting folder
-# under the temp folder.
-ISOLATE_TEMP_FOLDER = os.path.abspath(os.path.join(os.getcwd(), '../..'))
def LaunchBTCommand(args, command):
@@ -78,159 +63,6 @@ def LaunchBTCommand(args, command):
FAILING_TESTS += command
-def RunCommandInSubProcess(command):
- """Creates a subprocess with command-line that is passed in.
-
- Args:
- command: The text of command to be executed.
- Returns:
- results: stdout contents of executing the command.
- """
-
- cmd_line = [command]
- try:
- results = subprocess.check_output(cmd_line, stderr=subprocess.STDOUT,
- shell=True)
- except subprocess.CalledProcessError, e:
- results = e.output
- finally:
- print results
- return results
-
-
-def TestMachineCleanup(user_profile_dir):
- """Cleans up test machine so as not to impact other tests.
-
- Args:
- user_profile_dir: the user-profile folder used by Chromoting tests.
-
- """
- # Stop the host service.
- RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop')
-
- # Cleanup any host logs.
- RunCommandInSubProcess('rm /tmp/chrome_remote_desktop_*')
-
- # Remove the user-profile dir
- if os.path.exists(user_profile_dir):
- shutil.rmtree(user_profile_dir)
-
-
-def InitialiseTestMachineForLinux(cfg_file):
- """Sets up a Linux machine for connect-to-host browser-tests.
-
- Copy over me2me host-config to expected locations.
- By default, the Linux me2me host expects the host-config file to be under
- $HOME/.config/chrome-remote-desktop
- Its name is expected to have a hash that is specific to a machine.
-
- Args:
- cfg_file: location of test account's host-config file.
-
- Raises:
- Exception: if host did not start properly.
- """
-
- # First get home directory on current machine.
- home_dir = expanduser('~')
- default_config_file_location = os.path.join(home_dir, '.config', CRD_ID)
- if os.path.exists(default_config_file_location):
- shutil.rmtree(default_config_file_location)
- os.makedirs(default_config_file_location)
-
- # Copy over test host-config to expected location, with expected file-name.
- # The file-name should contain a hash-value that is machine-specific.
- default_config_file_name = 'host#%s.json' % HOST_HASH_VALUE
- config_file_src = os.path.join(os.getcwd(), cfg_file)
- shutil.copyfile(
- config_file_src,
- os.path.join(default_config_file_location, default_config_file_name))
-
- # Make sure chromoting host is running.
- if not RestartMe2MeHost():
- # Host start failed. Don't run any tests.
- raise Exception('Host restart failed.')
-
-
-def RestartMe2MeHost():
- """Stops and starts the Me2Me host on the test machine.
-
- Waits to confirm that host is ready to receive connections before returning.
-
- Returns:
- True: if HOST_READY_INDICATOR is found in stdout, indicating host is ready.
- False: if HOST_READY_INDICATOR not found in stdout.
- """
-
- # To start the host, we want to be in the temp-folder for this test execution.
- # Store the current folder to return back to it later.
- previous_directory = os.getcwd()
- os.chdir(ISOLATE_TEMP_FOLDER)
-
- # Stop chromoting host.
- RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop')
- # Start chromoting host.
- results = RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start')
-
- os.chdir(previous_directory)
- # Confirm that the start process completed, and we got:
- # "Host ready to receive connections." in the log.
- if HOST_READY_INDICATOR not in results:
- return False
- return True
-
-
-def SetupUserProfileDir(me2me_manifest_file, it2me_manifest_file,
- user_profile_dir):
- """Sets up the Google Chrome user profile directory.
-
- Delete the previous user profile directory if exists and create a new one.
- This invalidates any state changes by the previous test so each test can start
- with the same environment.
-
- When a user launches the remoting web-app, the native messaging host process
- is started. For this to work, this function places the me2me and it2me native
- messaging host manifest files in a specific folder under the user-profile dir.
-
- Args:
- me2me_manifest_file: location of me2me native messaging host manifest file.
- it2me_manifest_file: location of it2me native messaging host manifest file.
- user_profile_dir: Chrome user-profile-directory.
- """
- native_messaging_folder = os.path.join(user_profile_dir, NATIVE_MESSAGING_DIR)
-
- if os.path.exists(user_profile_dir):
- shutil.rmtree(user_profile_dir)
- os.makedirs(native_messaging_folder)
-
- manifest_files = [me2me_manifest_file, it2me_manifest_file]
- for manifest_file in manifest_files:
- manifest_file_src = os.path.join(os.getcwd(), manifest_file)
- manifest_file_dest = (
- os.path.join(native_messaging_folder, os.path.basename(manifest_file)))
- shutil.copyfile(manifest_file_src, manifest_file_dest)
-
-
-def PrintRunningProcesses():
- processes = psutil.get_process_list()
- processes = sorted(processes, key=lambda process: process.name)
-
- print 'List of running processes:\n'
- for process in processes:
- print process.name
-
-
-def TestCaseSetup(args):
- # Stop+start me2me host process.
- if not RestartMe2MeHost():
- # Host restart failed. Don't run any more tests.
- raise Exception('Host restart failed.')
-
- # Reset the user profile directory to start each test with a clean slate.
- SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file,
- args.user_profile_dir)
-
-
def main(args):
InitialiseTestMachineForLinux(args.cfg_file)
@@ -244,12 +76,7 @@ def main(args):
LaunchBTCommand(args, line)
# All tests completed. Include host-logs in the test results.
- host_log_contents = ''
- for log_file in glob.glob('/tmp/chrome_remote_desktop_*'):
- with open(log_file, 'r') as log:
- host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % (
- log_file, log.read())
- print host_log_contents
+ PrintHostLogContents()
if TEST_FAILURE:
print '++++++++++AT LEAST 1 TEST FAILED++++++++++'
diff --git a/testing/chromoting/chromoting_browser_tests.isolate b/testing/chromoting/chromoting_browser_tests.isolate
new file mode 100644
index 0000000..e2f7d1d
--- /dev/null
+++ b/testing/chromoting/chromoting_browser_tests.isolate
@@ -0,0 +1,129 @@
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+ 'conditions': [
+ ['OS=="linux"', {
+ 'variables': {
+ 'command': [
+ './browser_tests_launcher.py',
+ '--commands_file',
+ './browser_test_commands_linux.txt',
+ '--prod_dir',
+ '<(PRODUCT_DIR)',
+ '--cfg_file',
+ '../../remoting/tools/internal/test-account-host-config.json',
+ '--me2me_manifest_file',
+ '<(PRODUCT_DIR)/remoting/com.google.chrome.remote_desktop.json',
+ '--it2me_manifest_file',
+ '<(PRODUCT_DIR)/remoting/com.google.chrome.remote_assistance.json',
+ '--user_profile_dir',
+ '/tmp/chromoting_test_profile',
+ ],
+ 'files': [
+ '../xvfb.py',
+ './browser_tests_launcher.py',
+ './browser_test_commands_linux.txt',
+ './chromoting_test_utilities.py',
+ '<(PRODUCT_DIR)/remoting_me2me_host',
+ '<(PRODUCT_DIR)/libosmesa.so',
+ '<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
+ '../../remoting/tools/internal/test-account-host-config.json',
+ '../../remoting/host/linux/linux_me2me_host.py',
+ '<(PRODUCT_DIR)/remoting/com.google.chrome.remote_desktop.json',
+ '<(PRODUCT_DIR)/remoting/com.google.chrome.remote_assistance.json',
+ '<(PRODUCT_DIR)/remoting-me2me-host.deb',
+ '<(PRODUCT_DIR)/nacl_helper',
+ '<(PRODUCT_DIR)/nacl_helper_bootstrap',
+ '<(PRODUCT_DIR)/pnacl/',
+ '<(PRODUCT_DIR)/remoting_locales/',
+ '../../remoting/internal/config/',
+ ],
+ },
+ }],
+ ['OS=="linux" and use_ozone==0', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/xdisplaycheck<(EXECUTABLE_SUFFIX)',
+ ],
+ },
+ }],
+ ['OS=="linux" or OS=="mac" or OS=="win"', {
+ 'variables': {
+ 'files': [
+ '../test_env.py',
+ '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
+ '<(PRODUCT_DIR)/remoting/remoting.webapp.v2/',
+ '<(PRODUCT_DIR)/remoting/browser_test_resources/',
+ '<(PRODUCT_DIR)/resources.pak',
+ '../../remoting/tools/internal/test_accounts.json',
+ ],
+ },
+ }],
+ ['OS=="linux" or OS=="win"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/chrome_100_percent.pak',
+ '<(PRODUCT_DIR)/locales/en-US.pak',
+ ],
+ },
+ }],
+ ['OS=="win"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/chrome_elf.dll',
+ '<(PRODUCT_DIR)/libglesv2.dll',
+ ],
+ },
+ }],
+ ['OS=="mac"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/<(mac_product_name).app/',
+ '<(PRODUCT_DIR)/exif.so',
+ ],
+ },
+ }],
+ ['OS=="win"', {
+ 'variables': {
+ 'command': [
+ '../test_env.py',
+ '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
+ '--gtest_filter=RemoteDesktopBrowserTest.MANUAL_Launch:RemoteDesktopBrowserTest.MANUAL_Auth',
+ '--run-manual',
+ '--ui-test-action-timeout=100000',
+ '--webapp-unpacked=<(PRODUCT_DIR)/remoting/remoting.webapp.v2',
+ '--extension-name=Chromoting',
+ '--accounts-file=../../remoting/tools/internal/test_accounts.json',
+ '--account-type=gmail',
+ ],
+ },
+ }],
+ ['OS=="mac"', {
+ 'variables': {
+ 'command': [
+ '../test_env.py',
+ '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
+ '--gtest_filter=RemoteDesktopBrowserTest.MANUAL_Launch',
+ '--run-manual',
+ '--ui-test-action-timeout=100000',
+ '--webapp-unpacked=<(PRODUCT_DIR)/remoting/remoting.webapp.v2',
+ '--extension-name=Chromoting',
+ '--accounts-file=../../remoting/tools/internal/test_accounts.json',
+ '--account-type=gmail',
+ ],
+ },
+ }],
+ ['OS=="win" and kasko==1', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/kasko.dll',
+ ],
+ },
+ }],
+ ],
+ 'includes': [
+ '../../base/base.isolate',
+ '../../gin/v8.isolate',
+ ],
+}
diff --git a/testing/chromoting/chromoting_integration_tests.isolate b/testing/chromoting/chromoting_integration_tests.isolate
index da6b5f4..92ec17d 100644
--- a/testing/chromoting/chromoting_integration_tests.isolate
+++ b/testing/chromoting/chromoting_integration_tests.isolate
@@ -6,13 +6,13 @@
['OS=="linux"', {
'variables': {
'command': [
- './browser_tests_launcher.py',
+ './chromoting_test_driver_launcher.py',
'--commands_file',
- './browser_test_commands_linux.txt',
+ './chromoting_test_driver_commands_linux.txt',
'--prod_dir',
'<(PRODUCT_DIR)',
'--cfg_file',
- '../../remoting/tools/internal/test-account-host-config.json',
+ '../../remoting/tools/internal/ctd-test-account-host-config.json',
'--me2me_manifest_file',
'<(PRODUCT_DIR)/remoting/com.google.chrome.remote_desktop.json',
'--it2me_manifest_file',
@@ -21,22 +21,23 @@
'/tmp/chromoting_test_profile',
],
'files': [
- '../xvfb.py',
- './browser_tests_launcher.py',
- './browser_test_commands_linux.txt',
- '<(PRODUCT_DIR)/remoting_me2me_host',
+ './chromoting_test_driver_launcher.py',
+ './chromoting_test_driver_commands_linux.txt',
+ './chromoting_test_utilities.py',
+ '<(PRODUCT_DIR)/chromoting_test_driver',
'<(PRODUCT_DIR)/libosmesa.so',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
- '../../remoting/tools/internal/test-account-host-config.json',
+ '../../remoting/tools/internal/refresh_tokens.json',
+ '../../remoting/tools/internal/ctd-test-account-host-config.json',
'../../remoting/host/linux/linux_me2me_host.py',
'<(PRODUCT_DIR)/remoting/com.google.chrome.remote_desktop.json',
'<(PRODUCT_DIR)/remoting/com.google.chrome.remote_assistance.json',
+ '<(PRODUCT_DIR)/remoting_me2me_host',
'<(PRODUCT_DIR)/remoting-me2me-host.deb',
'<(PRODUCT_DIR)/nacl_helper',
'<(PRODUCT_DIR)/nacl_helper_bootstrap',
'<(PRODUCT_DIR)/pnacl/',
'<(PRODUCT_DIR)/remoting_locales/',
- '../../remoting/internal/config/',
],
},
}],
@@ -47,79 +48,6 @@
],
},
}],
- ['OS=="linux" or OS=="mac" or OS=="win"', {
- 'variables': {
- 'files': [
- '../test_env.py',
- '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
- '<(PRODUCT_DIR)/remoting/remoting.webapp.v2/',
- '<(PRODUCT_DIR)/remoting/browser_test_resources/',
- '<(PRODUCT_DIR)/resources.pak',
- '../../remoting/tools/internal/test_accounts.json',
- ],
- },
- }],
- ['OS=="linux" or OS=="win"', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/chrome_100_percent.pak',
- '<(PRODUCT_DIR)/locales/en-US.pak',
- ],
- },
- }],
- ['OS=="win"', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/chrome_elf.dll',
- '<(PRODUCT_DIR)/libglesv2.dll',
- ],
- },
- }],
- ['OS=="mac"', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/<(mac_product_name).app/',
- '<(PRODUCT_DIR)/exif.so',
- ],
- },
- }],
- ['OS=="win"', {
- 'variables': {
- 'command': [
- '../test_env.py',
- '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
- '--gtest_filter=RemoteDesktopBrowserTest.MANUAL_Launch:RemoteDesktopBrowserTest.MANUAL_Auth',
- '--run-manual',
- '--ui-test-action-timeout=100000',
- '--webapp-unpacked=<(PRODUCT_DIR)/remoting/remoting.webapp.v2',
- '--extension-name=Chromoting',
- '--accounts-file=../../remoting/tools/internal/test_accounts.json',
- '--account-type=gmail',
- ],
- },
- }],
- ['OS=="mac"', {
- 'variables': {
- 'command': [
- '../test_env.py',
- '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
- '--gtest_filter=RemoteDesktopBrowserTest.MANUAL_Launch',
- '--run-manual',
- '--ui-test-action-timeout=100000',
- '--webapp-unpacked=<(PRODUCT_DIR)/remoting/remoting.webapp.v2',
- '--extension-name=Chromoting',
- '--accounts-file=../../remoting/tools/internal/test_accounts.json',
- '--account-type=gmail',
- ],
- },
- }],
- ['OS=="win" and kasko==1', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/kasko.dll',
- ],
- },
- }],
],
'includes': [
'../../base/base.isolate',
diff --git a/testing/chromoting/chromoting_test_driver_commands_linux.txt b/testing/chromoting/chromoting_test_driver_commands_linux.txt
new file mode 100644
index 0000000..0f398fa
--- /dev/null
+++ b/testing/chromoting/chromoting_test_driver_commands_linux.txt
@@ -0,0 +1 @@
+#PROD_DIR#/chromoting_test_driver --username=chromoting.swarming@gmail.com --refresh-token-path=../../remoting/tools/internal/refresh_tokens.json --hostname=chromoting-test-driver-host --verbosity=2 --pin=123456
diff --git a/testing/chromoting/chromoting_test_driver_launcher.py b/testing/chromoting/chromoting_test_driver_launcher.py
new file mode 100644
index 0000000..c982279
--- /dev/null
+++ b/testing/chromoting/chromoting_test_driver_launcher.py
@@ -0,0 +1,98 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility script to run chromoting test driver tests on the Chromoting bot."""
+
+import argparse
+
+from chromoting_test_utilities import InitialiseTestMachineForLinux
+from chromoting_test_utilities import PrintHostLogContents
+from chromoting_test_utilities import PROD_DIR_ID
+from chromoting_test_utilities import RunCommandInSubProcess
+from chromoting_test_utilities import TestCaseSetup
+from chromoting_test_utilities import TestMachineCleanup
+
+TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR = 'Global test environment tear-down'
+FAILED_INDICATOR = '[ FAILED ]'
+
+
+def LaunchCTDCommand(args, command):
+ """Launches the specified chromoting test driver command.
+
+ Args:
+ args: Command line args, used for test-case startup tasks.
+ command: Chromoting Test Driver command line.
+ Returns:
+ "command" if there was a test environment failure, otherwise a string of the
+ names of failed tests.
+ """
+
+ TestCaseSetup(args)
+ results = RunCommandInSubProcess(command)
+
+ tear_down_index = results.find(TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR)
+ if tear_down_index == -1:
+ # The test environment did not tear down. Something went horribly wrong.
+ return '[Command failed]: ' + command
+
+ end_results_list = results[tear_down_index:].split('\n')
+ failed_tests_list = []
+ for result in end_results_list:
+ if result.startswith(FAILED_INDICATOR):
+ failed_tests_list.append(result)
+
+ if failed_tests_list:
+ test_result = '[Command]: ' + command
+ # Note: Skipping the first one is intentional.
+ for i in range(1, len(failed_tests_list)):
+ test_result += ' ' + failed_tests_list[i]
+ return test_result
+
+ # All tests passed!
+ return ''
+
+
+def main(args):
+ InitialiseTestMachineForLinux(args.cfg_file)
+
+ failed_tests = ''
+
+ with open(args.commands_file) as f:
+ for line in f:
+ # Replace the PROD_DIR value in the command-line with
+ # the passed in value.
+ line = line.replace(PROD_DIR_ID, args.prod_dir)
+ # Launch specified command line for test.
+ failed_tests += LaunchCTDCommand(args, line)
+
+ # All tests completed. Include host-logs in the test results.
+ PrintHostLogContents()
+
+ if failed_tests:
+ print '++++++++++FAILED TESTS++++++++++'
+ print failed_tests.rstrip('\n')
+ print '++++++++++++++++++++++++++++++++'
+ raise Exception('At least one test failed.')
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-f', '--commands_file',
+ help='path to file listing commands to be launched.')
+ parser.add_argument('-p', '--prod_dir',
+ help='path to folder having product and test binaries.')
+ parser.add_argument('-c', '--cfg_file',
+ help='path to test host config file.')
+ parser.add_argument('--me2me_manifest_file',
+ help='path to me2me host manifest file.')
+ parser.add_argument('--it2me_manifest_file',
+ help='path to it2me host manifest file.')
+ parser.add_argument(
+ '-u', '--user_profile_dir',
+ help='path to user-profile-dir, used by connect-to-host tests.')
+ command_line_args = parser.parse_args()
+ try:
+ main(command_line_args)
+ finally:
+ # Stop host and cleanup user-profile-dir.
+ TestMachineCleanup(command_line_args.user_profile_dir)
diff --git a/testing/chromoting/chromoting_test_utilities.py b/testing/chromoting/chromoting_test_utilities.py
new file mode 100644
index 0000000..ea183f1
--- /dev/null
+++ b/testing/chromoting/chromoting_test_utilities.py
@@ -0,0 +1,190 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility script to run tests on the Chromoting bot."""
+
+import glob
+import hashlib
+import os
+from os.path import expanduser
+import shutil
+import socket
+import subprocess
+
+import psutil
+
+PROD_DIR_ID = '#PROD_DIR#'
+CRD_ID = 'chrome-remote-desktop' # Used in a few file/folder names
+CHROMOTING_HOST_PATH = './remoting/host/linux/linux_me2me_host.py'
+HOST_READY_INDICATOR = 'Host ready to receive connections.'
+BROWSER_TEST_ID = 'browser_tests'
+HOST_HASH_VALUE = hashlib.md5(socket.gethostname()).hexdigest()
+NATIVE_MESSAGING_DIR = 'NativeMessagingHosts'
+# On a Swarming bot where these tests are executed, a temp folder is created
+# under which the files specified in an .isolate are copied. This temp folder
+# has a random name, which we'll store here for use later.
+# Note that the test-execution always starts from the testing/chromoting folder
+# under the temp folder.
+ISOLATE_TEMP_FOLDER = os.path.abspath(os.path.join(os.getcwd(), '../..'))
+
+
+def RunCommandInSubProcess(command):
+ """Creates a subprocess with command-line that is passed in.
+
+ Args:
+ command: The text of command to be executed.
+ Returns:
+ results: stdout contents of executing the command.
+ """
+
+ cmd_line = [command]
+ try:
+ results = subprocess.check_output(cmd_line, stderr=subprocess.STDOUT,
+ shell=True)
+ except subprocess.CalledProcessError, e:
+ results = e.output
+ finally:
+ print results
+ return results
+
+
+def TestMachineCleanup(user_profile_dir):
+ """Cleans up test machine so as not to impact other tests.
+
+ Args:
+ user_profile_dir: the user-profile folder used by Chromoting tests.
+ """
+ # Stop the host service.
+ RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop')
+
+ # Cleanup any host logs.
+ RunCommandInSubProcess('rm /tmp/chrome_remote_desktop_*')
+
+ # Remove the user-profile dir
+ if os.path.exists(user_profile_dir):
+ shutil.rmtree(user_profile_dir)
+
+
+def InitialiseTestMachineForLinux(cfg_file):
+ """Sets up a Linux machine for connect-to-host chromoting tests.
+
+ Copy over me2me host-config to expected locations.
+ By default, the Linux me2me host expects the host-config file to be under
+ $HOME/.config/chrome-remote-desktop
+ Its name is expected to have a hash that is specific to a machine.
+
+ Args:
+ cfg_file: location of test account's host-config file.
+
+ Raises:
+ Exception: if host did not start properly.
+ """
+
+ # First get home directory on current machine.
+ home_dir = expanduser('~')
+ default_config_file_location = os.path.join(home_dir, '.config', CRD_ID)
+ if os.path.exists(default_config_file_location):
+ shutil.rmtree(default_config_file_location)
+ os.makedirs(default_config_file_location)
+
+ # Copy over test host-config to expected location, with expected file-name.
+ # The file-name should contain a hash-value that is machine-specific.
+ default_config_file_name = 'host#%s.json' % HOST_HASH_VALUE
+ config_file_src = os.path.join(os.getcwd(), cfg_file)
+ shutil.copyfile(
+ config_file_src,
+ os.path.join(default_config_file_location, default_config_file_name))
+
+ # Make sure chromoting host is running.
+ if not RestartMe2MeHost():
+ # Host start failed. Don't run any tests.
+ raise Exception('Host restart failed.')
+
+
+def RestartMe2MeHost():
+ """Stops and starts the Me2Me host on the test machine.
+
+ Waits to confirm that host is ready to receive connections before returning.
+
+ Returns:
+ True: if HOST_READY_INDICATOR is found in stdout, indicating host is ready.
+ False: if HOST_READY_INDICATOR not found in stdout.
+ """
+
+ # To start the host, we want to be in the temp-folder for this test execution.
+ # Store the current folder to return back to it later.
+ previous_directory = os.getcwd()
+ os.chdir(ISOLATE_TEMP_FOLDER)
+
+ # Stop chromoting host.
+ RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --stop')
+ # Start chromoting host.
+ results = RunCommandInSubProcess(CHROMOTING_HOST_PATH + ' --start')
+
+ os.chdir(previous_directory)
+ # Confirm that the start process completed, and we got:
+ # "Host ready to receive connections." in the log.
+ if HOST_READY_INDICATOR not in results:
+ return False
+ return True
+
+
+def SetupUserProfileDir(me2me_manifest_file, it2me_manifest_file,
+ user_profile_dir):
+ """Sets up the Google Chrome user profile directory.
+
+ Delete the previous user profile directory if exists and create a new one.
+ This invalidates any state changes by the previous test so each test can start
+ with the same environment.
+
+ When a user launches the remoting web-app, the native messaging host process
+ is started. For this to work, this function places the me2me and it2me native
+ messaging host manifest files in a specific folder under the user-profile dir.
+
+ Args:
+ me2me_manifest_file: location of me2me native messaging host manifest file.
+ it2me_manifest_file: location of it2me native messaging host manifest file.
+ user_profile_dir: Chrome user-profile-directory.
+ """
+ native_messaging_folder = os.path.join(user_profile_dir, NATIVE_MESSAGING_DIR)
+
+ if os.path.exists(user_profile_dir):
+ shutil.rmtree(user_profile_dir)
+ os.makedirs(native_messaging_folder)
+
+ manifest_files = [me2me_manifest_file, it2me_manifest_file]
+ for manifest_file in manifest_files:
+ manifest_file_src = os.path.join(os.getcwd(), manifest_file)
+ manifest_file_dest = (
+ os.path.join(native_messaging_folder, os.path.basename(manifest_file)))
+ shutil.copyfile(manifest_file_src, manifest_file_dest)
+
+
+def PrintRunningProcesses():
+ processes = psutil.get_process_list()
+ processes = sorted(processes, key=lambda process: process.name)
+
+ print 'List of running processes:\n'
+ for process in processes:
+ print process.name
+
+
+def PrintHostLogContents():
+ host_log_contents = ''
+ for log_file in sorted(glob.glob('/tmp/chrome_remote_desktop_*')):
+ with open(log_file, 'r') as log:
+ host_log_contents += '\nHOST LOG %s\n CONTENTS:\n%s' % (
+ log_file, log.read())
+ print host_log_contents
+
+
+def TestCaseSetup(args):
+ # Stop+start me2me host process.
+ if not RestartMe2MeHost():
+ # Host restart failed. Don't run any more tests.
+ raise Exception('Host restart failed.')
+
+ # Reset the user profile directory to start each test with a clean slate.
+ SetupUserProfileDir(args.me2me_manifest_file, args.it2me_manifest_file,
+ args.user_profile_dir)
diff --git a/testing/chromoting/dependencies.gypi b/testing/chromoting/dependencies.gypi
index fd74e3a..84d70dc 100644
--- a/testing/chromoting/dependencies.gypi
+++ b/testing/chromoting/dependencies.gypi
@@ -16,6 +16,7 @@
'conditions': [
['OS=="linux"', {
'dependencies': [
+ '../../remoting/remoting.gyp:chromoting_test_driver',
'../../remoting/remoting.gyp:remoting_me2me_host_archive',
'../../remoting/internal/app_remoting_all.gyp:app_remoting_all_apps',
'../../remoting/internal/app_remoting_all.gyp:ar_test_driver',
diff --git a/testing/chromoting/integration_tests.gyp b/testing/chromoting/integration_tests.gyp
index ba80a8c..38d4609 100644
--- a/testing/chromoting/integration_tests.gyp
+++ b/testing/chromoting/integration_tests.gyp
@@ -21,6 +21,15 @@
'app_remoting_integration_tests.isolate',
],
}, # target_name: 'app_remoting_integration_tests_run'
+ {
+ 'target_name': 'chromoting_integration_tests_run',
+ 'includes': [
+ './dependencies.gypi',
+ ],
+ 'sources': [
+ 'chromoting_integration_tests.isolate',
+ ],
+ }, # target_name: 'chromoting_integration_tests_run'
],
}],
['run_multi_machine_tests==1', {
@@ -40,12 +49,12 @@
],
'targets': [
{
- 'target_name': 'chromoting_integration_tests_run',
+ 'target_name': 'chromoting_browser_tests_run',
'includes': [
'./dependencies.gypi',
],
'sources': [
- 'chromoting_integration_tests.isolate',
+ 'chromoting_browser_tests.isolate',
],
'conditions': [
['OS=="linux"', {
@@ -76,7 +85,7 @@
],
}],
],
- }, # target_name: 'chromoting_integration_tests_run'
+ }, # target_name: 'chromoting_browser_integration_tests_run'
],
}],
],
diff --git a/testing/chromoting/multi_machine_example/example_task.isolate b/testing/chromoting/multi_machine_example/example_task.isolate
index 710e6da..87869f3 100644
--- a/testing/chromoting/multi_machine_example/example_task.isolate
+++ b/testing/chromoting/multi_machine_example/example_task.isolate
@@ -4,7 +4,7 @@
{
'includes': [
- '../chromoting_integration_tests.isolate',
+ '../chromoting_browser_tests.isolate',
'../../legion/legion.isolate',
'../../../chrome/chrome.isolate',
'../../../remoting/tools/remote_test_helper/remote_test_helper.isolate',
diff --git a/testing/chromoting/multi_machine_example/example_test_controller.py b/testing/chromoting/multi_machine_example/example_test_controller.py
index 2ba2024..f38150c 100755
--- a/testing/chromoting/multi_machine_example/example_test_controller.py
+++ b/testing/chromoting/multi_machine_example/example_test_controller.py
@@ -6,8 +6,8 @@
"""The test controller for the chromoting localhost browser_tests.
This test uses the legion framework to setup this controller which will run
-the chromoting_integration_tests on a task machine. This is intended to be an
-example Legion-based test for the chromoting team.
+the chromoting_browser_tests on a task machine. This is intended to
+be an example Legion-based test for the chromoting team.
The controller will start a task machine to run browser_tests_launcher on. The
output of these tests are streamed back to the test controller to be output