Commit 2815e781 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Chromium LUCI CQ

[mb] use luci-go in `mb run --swarmed`

Because go client doesn't have `run` subcommand, I replaced that with
`trigger` + `collect`.

Tested with
$ ./tools/mb/mb.py run --swarmed out/Release/ base_unittests

Bug: 1142713
Change-Id: I0420e7b92368decc40ca97a52cdb72d13904162e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2576880
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: default avatarDirk Pranke <dpranke@google.com>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834795}
parent 64b1211f
......@@ -618,7 +618,7 @@ class MetaBuildWrapper(object):
# TODO(dpranke): Also, add support for sharding and merging results.
dimensions = []
for k, v in self._DefaultDimensions() + self.args.dimensions:
dimensions += ['-d', k, v]
dimensions += ['-d', '%s=%s' % (k, v)]
archive_json_path = self.ToSrcRelPath(
'%s/%s.archive.json' % (build_dir, target))
......@@ -672,27 +672,47 @@ class MetaBuildWrapper(object):
file=sys.stderr)
return 1
tags = ['--tags=%s' % tag for tag in self.args.tags]
tags = ['-tag=%s' % tag for tag in self.args.tags]
try:
json_dir = self.TempDir()
json_file = self.PathJoin(json_dir, 'task.json')
cmd = [
self.PathJoin('tools', 'luci-go', 'swarming'),
'trigger',
'-isolated',
isolated_hash,
'-I',
'https://' + isolate_server,
'-namespace',
namespace,
'-server',
swarming_server,
'-tag=purpose:user-debug-mb',
'-relative-cwd',
self.ToSrcRelPath(build_dir),
'-dump-json',
json_file,
] + tags + dimensions + ['--'] + list(isolate_cmd)
if self.args.extra_args:
cmd += self.args.extra_args
self.Print('')
ret, _, _ = self.Run(cmd, force_verbose=True, buffer_output=False)
if ret:
return ret
task_json = self.ReadFile(json_file)
task_id = json.loads(task_json)["tasks"][0]['task_id']
finally:
if json_dir:
self.RemoveDirectory(json_dir)
cmd = [
self.executable,
self.PathJoin('tools', 'swarming_client', 'swarming.py'),
'run',
'-s',
isolated_hash,
'-I',
isolate_server,
'--namespace',
namespace,
'-S',
self.PathJoin('tools', 'luci-go', 'swarming'),
'collect',
'-server',
swarming_server,
'--tags=purpose:user-debug-mb',
'--relative-cwd',
self.ToSrcRelPath(build_dir),
] + tags + dimensions + ['--raw-cmd', '--'] + list(isolate_cmd)
if self.args.extra_args:
cmd += self.args.extra_args
self.Print('')
'-task-output-stdout=console',
task_id,
]
ret, _, _ = self.Run(cmd, force_verbose=True, buffer_output=False)
return ret
......
......@@ -319,7 +319,9 @@ class UnitTest(unittest.TestCase):
actual_ret = mbw.Main(args)
finally:
os.environ = prev_env
self.assertEqual(actual_ret, ret)
self.assertEqual(
actual_ret, ret,
"ret: %s, out: %s, err: %s" % (actual_ret, mbw.out, mbw.err))
if out is not None:
self.assertEqual(mbw.out, out)
if err is not None:
......@@ -714,7 +716,10 @@ class UnitTest(unittest.TestCase):
"/some/vpython/pkg git_revision:deadbeef\n"),
}
task_json = json.dumps({'tasks': [{'task_id': '00000'}]})
mbw = self.fake_mbw(files=files)
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
original_impl = mbw.ToSrcRelPath
def to_src_rel_path_stub(path):
......@@ -726,6 +731,9 @@ class UnitTest(unittest.TestCase):
self.check(['run', '-s', '-c', 'debug_goma', '//out/Default',
'base_unittests'], mbw=mbw, ret=0)
mbw = self.fake_mbw(files=files)
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
mbw.ToSrcRelPath = to_src_rel_path_stub
self.check(['run', '-s', '-c', 'debug_goma', '-d', 'os', 'Win7',
'//out/Default', 'base_unittests'], mbw=mbw, ret=0)
......
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