Deploy a locally built browser when running telemetry tests in cros VMs.

This adds a --deploy option to the vm test runner and binds it to true
every time we build the cros_vm_launcher. This assumes that everything
that uses that target also builds chrome and also wants it deployed to
the VM (which is true atm).

Also rebalance telemetry unit test shard count on the FYI bot.

Bug: 836447
Change-Id: I012932edac7bf40c369f69378e3ad365dd9e1ab6
Reviewed-on: https://chromium-review.googlesource.com/1155833
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Reviewed-by: John Budorick <jbudorick@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#580969}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 22d25c856a70980c251952e873d923d9a3516b52
This commit is contained in:
Ben Pastene 2018-08-06 20:18:34 +00:00 коммит произвёл Commit Bot
Родитель 7d6c95721f
Коммит ce3ea9594f
3 изменённых файлов: 51 добавлений и 10 удалений

Просмотреть файл

@ -41,6 +41,7 @@ if __name__ == '__main__':
sys.exit(main())
"""
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument('--script-output-path')
@ -49,9 +50,9 @@ def main(args):
parser.add_argument('--runtime-deps-path')
parser.add_argument('--cros-cache')
parser.add_argument('--board')
parser.add_argument('--deploy-chrome', action='store_true')
args = parser.parse_args(args)
def RelativizePathToScript(path):
return os.path.relpath(path, os.path.dirname(args.script_output_path))
@ -62,6 +63,7 @@ def main(args):
'--board', args.board,
'-v',
]
if args.test_exe:
vm_test_args.extend([
'vm-test',
@ -70,6 +72,8 @@ def main(args):
])
else:
vm_test_args.append('host-cmd')
if args.deploy_chrome:
vm_test_args.append('--deploy-chrome')
vm_test_path_args = [
('--cros-cache', RelativizePathToScript(args.cros_cache)),

Просмотреть файл

@ -322,13 +322,14 @@ def vm_test(args, unknown_args):
def host_cmd(args, unknown_args):
if not args.cmd:
logging.error('Must specify command to run on the host.')
return 1
raise TestFormatError('Must specify command to run on the host.')
elif unknown_args:
logging.error(
'Args "%s" unsupported. Is your host command correctly formatted?',
' '.join(unknown_args))
return 1
raise TestFormatError(
'Args "%s" unsupported. Is your host command correctly formatted?' % (
' '.join(unknown_args)))
elif args.deploy_chrome and not args.path_to_outdir:
raise TestFormatError(
'--path-to-outdir must be specified if --deploy-chrome is passed.')
cros_run_vm_test_cmd = [
CROS_RUN_VM_TEST_PATH,
@ -339,6 +340,24 @@ def host_cmd(args, unknown_args):
if args.verbose:
cros_run_vm_test_cmd.append('--debug')
test_env = os.environ.copy()
if args.deploy_chrome:
cros_run_vm_test_cmd += [
'--deploy',
'--build-dir', os.path.abspath(args.path_to_outdir),
]
# If we're deploying, push chromite/bin's deploy_chrome onto PATH.
test_env['PATH'] = (
test_env['PATH'] + ':' + os.path.join(CHROMITE_PATH, 'bin'))
# deploy_chrome needs a set of GN args used to build chrome to determine if
# certain libraries need to be pushed to the VM. It looks for the args via
# an env var. To trigger the default deploying behavior, give it a dummy set
# of args.
# TODO(crbug.com/823996): Make the GN-dependent deps controllable via cmd
# line args.
if not test_env.get('GN_ARGS'):
test_env['GN_ARGS'] = 'is_chromeos = true'
cros_run_vm_test_cmd += [
'--host-cmd',
'--',
@ -348,7 +367,7 @@ def host_cmd(args, unknown_args):
logging.info(' '.join(cros_run_vm_test_cmd))
return subprocess42.call(
cros_run_vm_test_cmd, stdout=sys.stdout, stderr=sys.stderr)
cros_run_vm_test_cmd, stdout=sys.stdout, stderr=sys.stderr, env=test_env)
def main():
@ -366,6 +385,14 @@ def main():
host_cmd_parser.set_defaults(func=host_cmd)
host_cmd_parser.add_argument(
'--cros-cache', type=str, required=True, help='Path to cros cache.')
host_cmd_parser.add_argument(
'--path-to-outdir', type=os.path.realpath,
help='Path to output directory, all of whose contents will be deployed '
'to the device.')
host_cmd_parser.add_argument(
'--deploy-chrome', action='store_true',
help='Will deploy a locally built Chrome binary to the VM before running '
'the host-cmd.')
host_cmd_parser.add_argument('cmd', nargs=argparse.REMAINDER)
# VM-side test args.
vm_test_parser = subparsers.add_parser(

Просмотреть файл

@ -9,6 +9,12 @@ declare_args() {
cros_sdk_version = ""
}
# Creates a script at $generated_script that can be used to launch a cros VM
# and optionally run a test within it.
# Args:
# generated_script: Path to place the generated script.
# deploy_chrome: If true, deploys a locally built chrome located in the root
# build dir to the VM after launching it.
template("generate_vm_runner_script") {
_cache_path_prefix =
"//build/cros_cache/chrome-sdk/tarballs/${cros_board}+${cros_sdk_version}"
@ -64,8 +70,14 @@ template("generate_vm_runner_script") {
rebase_path("//build/cros_cache/", root_build_dir),
"--board",
cros_board,
"--output-directory",
rebase_path(root_out_dir, root_build_dir),
]
if (defined(invoker.deploy_chrome) && invoker.deploy_chrome) {
args += [ "--deploy-chrome" ]
}
# When --test-exe is specified, run_vm_test will push the exe to the VM and
# execute it. Otherwise it wraps a host-side command and just takes care
# launching & tearing-down the VM.
@ -73,8 +85,6 @@ template("generate_vm_runner_script") {
args += [
"--test-exe",
rebase_path(invoker.test_exe, root_build_dir),
"--output-directory",
rebase_path(root_out_dir, root_build_dir),
]
if (defined(invoker.runtime_deps_file)) {
args += [