Commit 862ddfc8 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Chromium LUCI CQ

trigger_scripts: support json from go client

This is fix for
https://ci.chromium.org/p/chrome/builders/ci/linux-perf-fyi/47656
due to incompatible format of json from swarming client.

Bug: 1127205
Change-Id: I8ff3b050f1d999d19218ad85a96b56e637c8e80c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626686
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843280}
parent f27b9b53
...@@ -323,7 +323,13 @@ class BaseTestTriggerer(object): ...@@ -323,7 +323,13 @@ class BaseTestTriggerer(object):
# However, reset the "tasks" entry to an empty dictionary, # However, reset the "tasks" entry to an empty dictionary,
# which will be handled specially. # which will be handled specially.
merged_json['tasks'] = {} merged_json['tasks'] = {}
for k, v in result_json['tasks'].items(): tasks = result_json['tasks']
if args.use_swarming_go:
# TODO(crbug.com/1127205): remove this
tasks = {
task['request']['task_id']: task['request'] for task in tasks
}
for k, v in tasks.items():
v['shard_index'] = shard_index v['shard_index'] = shard_index
merged_json['tasks'][k + ':%d:%d' % (shard_index, args.shards)] = v merged_json['tasks'][k + ':%d:%d' % (shard_index, args.shards)] = v
finally: finally:
...@@ -360,4 +366,3 @@ class BaseTestTriggerer(object): ...@@ -360,4 +366,3 @@ class BaseTestTriggerer(object):
default=False, default=False,
action='store_true', action='store_true',
help='Uses swarming Go CLI to trigger tasks.') help='Uses swarming Go CLI to trigger tasks.')
...@@ -86,14 +86,14 @@ class UnitTest(unittest.TestCase): ...@@ -86,14 +86,14 @@ class UnitTest(unittest.TestCase):
triggerer = FakeTriggerer(args, swarming_args, triggerer = FakeTriggerer(args, swarming_args,
self.get_files(args.shards, previous_task_assignment_map, self.get_files(args.shards, previous_task_assignment_map,
alive_bots, dead_bots)) alive_bots, dead_bots, use_swarming_go=use_swarming_go))
triggerer.trigger_tasks( triggerer.trigger_tasks(
args, args,
swarming_args) swarming_args)
return triggerer return triggerer
def get_files(self, num_shards, previous_task_assignment_map, def get_files(self, num_shards, previous_task_assignment_map,
alive_bots, dead_bots): alive_bots, dead_bots, use_swarming_go):
files = {} files = {}
file_index = 0 file_index = 0
files['base_trigger_dimensions%d.json' % file_index] = ( files['base_trigger_dimensions%d.json' % file_index] = (
...@@ -113,20 +113,29 @@ class UnitTest(unittest.TestCase): ...@@ -113,20 +113,29 @@ class UnitTest(unittest.TestCase):
self.generate_last_task_to_shard_query_response(i, bot_id)) self.generate_last_task_to_shard_query_response(i, bot_id))
file_index = file_index + 1 file_index = file_index + 1
for i in xrange(num_shards): for i in xrange(num_shards):
task = { if use_swarming_go:
'base_task_name': 'webgl_conformance_tests', task = {
'request': { 'tasks': [{
'expiration_secs': 3600, 'request': {
'properties': { 'task_id': 'f%d' % i,
'execution_timeout_secs': 3600, },
}],
}
else:
task = {
'base_task_name': 'webgl_conformance_tests',
'request': {
'expiration_secs': 3600,
'properties': {
'execution_timeout_secs': 3600,
},
}, },
}, 'tasks': {
'tasks': { 'webgl_conformance_tests on NVIDIA GPU on Windows': {
'webgl_conformance_tests on NVIDIA GPU on Windows': { 'task_id': 'f%d' % i,
'task_id': 'f%d' % i, },
}, },
}, }
}
files['base_trigger_dimensions%d.json' % file_index] = task files['base_trigger_dimensions%d.json' % file_index] = task
file_index = file_index + 1 file_index = file_index + 1
return files return files
......
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