Commit 9a376230 authored by Ye Kuang's avatar Ye Kuang Committed by Commit Bot

Fix mb.py when using `isolate archive`

* luci-go's `isolate archive` requires `-isolate` flag.
* we also enable `-dump-json`, which dumps a JSON file that contains the SHA1 hash of the isolated file.

Tested on the following command:

```
tools/mb/mb.py run -s --no-default-dimensions -d pool chromium.tests -d device_os KTU84P -d device_type hammerhead out/Release/ base_unittests -- --test-filter FakeClass#fakeTest
```

It runs successfully.

Bug: 1062881
Change-Id: I46af6679e43d3af6bfed797485cb485b39235733
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2105272Reviewed-by: default avatarTakuto Ikuta <tikuta@chromium.org>
Commit-Queue: Ye Kuang <yekuang@google.com>
Cr-Commit-Position: refs/heads/master@{#751624}
parent 34ad7c1a
......@@ -662,16 +662,22 @@ class MetaBuildWrapper(object):
for k, v in self._DefaultDimensions() + self.args.dimensions:
dimensions += ['-d', k, v]
archive_json_path = self.ToSrcRelPath(
'%s/%s.archive.json' % (build_dir, target))
cmd = [
self.PathJoin(self.chromium_src_dir, 'tools', 'luci-go',
self.isolate_exe),
'archive',
'-i',
self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)),
'-s',
self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)),
'-I',
isolate_server,
'-namespace',
namespace,
'-dump-json',
archive_json_path,
]
# Talking to the isolateserver may fail because we're not logged in.
......@@ -693,7 +699,21 @@ class MetaBuildWrapper(object):
return ret
isolated_hash = out.splitlines()[0].split()[0]
try:
archive_hashes = json.loads(self.ReadFile(archive_json_path))
except Exception:
self.Print(
'Failed to read JSON file "%s"' % archive_json_path, file=sys.stderr)
return 1
try:
isolated_hash = archive_hashes[target]
except Exception:
self.Print(
'Cannot find hash for "%s" in "%s", file content: %s' %
(target, archive_json_path, archive_hashes),
file=sys.stderr)
return 1
cmd = [
self.executable,
self.PathJoin('tools', 'swarming_client', 'swarming.py'),
......
......@@ -831,30 +831,31 @@ class UnitTest(unittest.TestCase):
def test_run_swarmed(self):
files = {
'/fake_src/testing/buildbot/gn_isolate_map.pyl': (
"{'base_unittests': {"
" 'label': '//base:base_unittests',"
" 'type': 'raw',"
" 'args': [],"
"}}\n"
),
'/fake_src/out/Default/base_unittests.runtime_deps': (
"base_unittests\n"
),
'/fake_src/third_party/depot_tools/cipd_manifest.txt': (
"# vpython\n"
"/some/vpython/pkg git_revision:deadbeef\n"
),
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
("{'base_unittests': {"
" 'label': '//base:base_unittests',"
" 'type': 'raw',"
" 'args': [],"
"}}\n"),
'/fake_src/out/Default/base_unittests.runtime_deps':
("base_unittests\n"),
'/fake_src/out/Default/base_unittests.archive.json':
("{\"base_unittests\":\"fake_hash\"}"),
'/fake_src/third_party/depot_tools/cipd_manifest.txt':
("# vpython\n"
"/some/vpython/pkg git_revision:deadbeef\n"),
}
def run_stub(cmd, **_kwargs):
if os.path.join('tools', 'luci-go', 'isolate') in cmd[0]:
return 0, 'fake_hash base_unittests', ''
else:
return 0, '', ''
mbw = self.fake_mbw(files=files)
mbw.Run = run_stub
original_impl = mbw.ToSrcRelPath
def to_src_rel_path_stub(path):
if path.endswith('base_unittests.archive.json'):
return 'base_unittests.archive.json'
return original_impl(path)
mbw.ToSrcRelPath = to_src_rel_path_stub
self.check(['run', '-s', '-c', 'debug_goma', '//out/Default',
'base_unittests'], mbw=mbw, ret=0)
self.check(['run', '-s', '-c', 'debug_goma', '-d', 'os', 'Win7',
......
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