Commit 85e93c12 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

tools: use go client in run-swarmed.py


Bug: 984869
Change-Id: I1376a7ca637041c4d71bea60c6354b6a63054958
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038810
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738703}
parent 6e766760
...@@ -23,6 +23,8 @@ See //docs/workflow/debugging-with-swarming.md for more details. ...@@ -23,6 +23,8 @@ See //docs/workflow/debugging-with-swarming.md for more details.
from __future__ import print_function from __future__ import print_function
import argparse import argparse
import hashlib
import json
import multiprocessing import multiprocessing
import os import os
import shutil import shutil
...@@ -46,34 +48,44 @@ def _Spawn(args): ...@@ -46,34 +48,44 @@ def _Spawn(args):
""" """
index, args, isolated_hash = args index, args, isolated_hash = args
json_file = os.path.join(args.results, '%d.json' % index) json_file = os.path.join(args.results, '%d.json' % index)
trigger_args = [sys.executable, trigger_args = [
'tools/swarming_client/swarming.py', 'trigger', 'tools/luci-go/swarming',
'-S', 'https://chromium-swarm.appspot.com', 'trigger',
'-I', 'https://isolateserver.appspot.com', '-S',
'-d', 'pool', args.pool, 'https://chromium-swarm.appspot.com',
'-s', isolated_hash, '-I',
'--dump-json', json_file, 'https://isolateserver.appspot.com',
'-d', 'os', args.swarming_os, '-d',
'--tags=purpose:user-debug-run-swarmed', 'pool=' + args.pool,
'-s',
isolated_hash,
'-dump-json',
json_file,
'-d',
'os=' + args.swarming_os,
'-tag=purpose:user-debug-run-swarmed',
] ]
if args.target_os == 'fuchsia': if args.target_os == 'fuchsia':
trigger_args += [ trigger_args += [
'-d', 'kvm', '1', '-d',
'-d', 'gpu', 'none', 'kvm=1',
'-d', 'cpu', args.arch, '-d',
'gpu=none',
'-d',
'cpu=' + args.arch,
] ]
if args.target_os == 'android': if args.target_os == 'android':
trigger_args += ['-d', 'device_os', args.device_os] trigger_args += ['-d', 'device_os=' + args.device_os]
# The canonical version numbers are stored in the infra repository here: # The canonical version numbers are stored in the infra repository here:
# build/scripts/slave/recipe_modules/swarming/api.py # build/scripts/slave/recipe_modules/swarming/api.py
cpython_version = 'version:2.7.15.chromium14' cpython_version = 'version:2.7.15.chromium14'
vpython_version = 'git_revision:98a268c6432f18aedd55d62b9621765316dc2a16' vpython_version = 'git_revision:98a268c6432f18aedd55d62b9621765316dc2a16'
cpython_pkg = ( cpython_pkg = (
'.swarming_module:infra/python/cpython/${platform}:' + cpython_version) '.swarming_module:infra/python/cpython/${platform}=' + cpython_version)
vpython_native_pkg = ( vpython_native_pkg = (
'.swarming_module:infra/tools/luci/vpython-native/${platform}:' + '.swarming_module:infra/tools/luci/vpython-native/${platform}=' +
vpython_version) vpython_version)
vpython_pkg = ('.swarming_module:infra/tools/luci/vpython/${platform}:' + vpython_pkg = ('.swarming_module:infra/tools/luci/vpython/${platform}=' +
vpython_version) vpython_version)
trigger_args += [ trigger_args += [
'--cipd-package', '--cipd-package',
...@@ -83,14 +95,11 @@ def _Spawn(args): ...@@ -83,14 +95,11 @@ def _Spawn(args):
'--cipd-package', '--cipd-package',
vpython_pkg, vpython_pkg,
'--env-prefix', '--env-prefix',
'PATH', 'PATH=.swarming_module',
'.swarming_module',
'--env-prefix', '--env-prefix',
'PATH', 'PATH=.swarming_module/bin',
'.swarming_module/bin',
'--env-prefix', '--env-prefix',
'VPYTHON_VIRTUALENV_ROOT', 'VPYTHON_VIRTUALENV_ROOT=.swarming_module_cache/vpython',
'.swarming_module_cache/vpython',
] ]
trigger_args += [ trigger_args += [
'--', '--',
...@@ -110,12 +119,19 @@ def _Spawn(args): ...@@ -110,12 +119,19 @@ def _Spawn(args):
def _Collect(spawn_result): def _Collect(spawn_result):
index, json_file, args = spawn_result index, json_file, args = spawn_result
p = subprocess.Popen([sys.executable, with open(json_file) as f:
'tools/swarming_client/swarming.py', 'collect', task_json = json.load(f)
'-S', 'https://chromium-swarm.appspot.com', task_ids = [task['task_id'] for task in task_json['tasks']]
'--json', json_file, p = subprocess.Popen(
'--task-output-stdout=console'], [
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 'tools/luci-go/swarming',
'collect',
'-S',
'https://chromium-swarm.appspot.com',
'--task-output-stdout=console',
] + task_ids,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout = p.communicate()[0] stdout = p.communicate()[0]
if p.returncode != 0 and len(stdout) < 2**10 and 'Internal error!' in stdout: if p.returncode != 0 and len(stdout) < 2**10 and 'Internal error!' in stdout:
exit_code = INTERNAL_ERROR_EXIT_CODE exit_code = INTERNAL_ERROR_EXIT_CODE
...@@ -192,12 +208,14 @@ def main(): ...@@ -192,12 +208,14 @@ def main():
) )
print('Uploading to isolate server, this can take a while...') print('Uploading to isolate server, this can take a while...')
archive_output = subprocess.check_output( isolated = os.path.join(args.out_dir, args.target_name + '.isolated')
[sys.executable,'tools/swarming_client/isolate.py', 'archive', subprocess.check_output([
'-I', 'https://isolateserver.appspot.com', 'tools/luci-go/isolate', 'archive', '-I',
'-i', os.path.join(args.out_dir, args.target_name + '.isolate'), 'https://isolateserver.appspot.com', '-i',
'-s', os.path.join(args.out_dir, args.target_name + '.isolated')]) os.path.join(args.out_dir, args.target_name + '.isolate'), '-s', isolated
isolated_hash = archive_output.split()[0] ])
with open(isolated) as f:
isolated_hash = hashlib.sha1(f.read()).hexdigest()
if os.path.isdir(args.results): if os.path.isdir(args.results):
shutil.rmtree(args.results) shutil.rmtree(args.results)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment