Commit b422e687 authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Commit Bot

[git-cl-try] update builders-map response handling

Remove code path.

Update new code path to expect one bucket, instead of a list.
Related:
https://chromium-review.googlesource.com/c/infra/infra/+/927792

TBR=tandrii@chromium.org
Bug: 800355
Change-Id: I60fbcf92dc242fc9b448760aaa5399320e257323
Reviewed-on: https://chromium-review.googlesource.com/928053
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
parent 64e33cba
......@@ -420,20 +420,9 @@ def _get_bucket_map_for_builders(builders):
bucket_map = {}
for builder in builders:
builder_info = builders_map.get(builder, {})
if isinstance(builder_info, list):
# This is a list of masters, legacy mode.
# TODO(nodir): remove this code path.
buckets = map(_prefix_master, builder_info)
else:
buckets = builder_info.get('buckets') or []
if not buckets:
return None, ('No matching bucket for builder %s.' % builder)
if len(buckets) > 1:
return None, ('The builder name %s exists in multiple buckets %s.' %
(builder, buckets))
bucket_map.setdefault(buckets[0], {})[builder] = []
bucket = builders_map.get(builder, {}).get('bucket')
if bucket:
bucket_map.setdefault(bucket, {})[builder] = []
return bucket_map, None
......
......@@ -3061,18 +3061,21 @@ class TestGitCl(TestCase):
body = json.loads(kw['body'])
self.assertEqual(len(body['builds']), 2)
first_build_params = json.loads(body['builds'][0]['parameters_json'])
self.assertEqual(first_build_params['builder_name'], 'builder1')
self.assertEqual(first_build_params['properties']['master'], 'master1')
self.assertEqual(body['builds'][0]['bucket'], 'bucket1')
params = json.loads(body['builds'][0]['parameters_json'])
self.assertEqual(params['builder_name'], 'builder1')
first_build_params = json.loads(body['builds'][1]['parameters_json'])
self.assertEqual(first_build_params['builder_name'], 'builder2')
self.assertEqual(first_build_params['properties']['master'], 'master2')
self.assertEqual(body['builds'][1]['bucket'], 'bucket2')
params = json.loads(body['builds'][1]['parameters_json'])
self.assertEqual(params['builder_name'], 'builder2')
self.mock(git_cl, '_buildbucket_retry', _buildbucket_retry)
self.mock(git_cl.urllib2, 'urlopen', lambda _: StringIO.StringIO(
json.dumps({'builder1': ['master1'], 'builder2': ['master2']})))
json.dumps({
'builder1': {'bucket': 'bucket1'},
'builder2': {'bucket': 'bucket2'},
})))
self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
self.assertEqual(
......@@ -3080,9 +3083,9 @@ class TestGitCl(TestCase):
self.assertEqual(
git_cl.sys.stdout.getvalue(),
'Tried jobs on:\n'
'Bucket: master.master1\n'
'Bucket: bucket1\n'
' builder1: []\n'
'Bucket: master.master2\n'
'Bucket: bucket2\n'
' builder2: []\n'
'To see results here, run: git cl try-results\n'
'To see results in browser, run: git cl web\n')
......
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