Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: appengine/findit/util_scripts/remote_queries/check_trybot_mapping.py

Issue 1993883002: [Findit] Adding script to verify trybot support (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Identifies mismatches between main waterfall builders and Findit trybots."""
6 from collections import defaultdict
7 import json
8 import os
9 import sys
10
11 from google.appengine.api import urlfetch
12
13 _REMOTE_API_DIR = os.path.join(os.path.dirname(__file__), os.path.pardir)
14 sys.path.insert(1, _REMOTE_API_DIR)
15
16 import remote_api
17 from model.wf_config import FinditConfig
18
19
20 BUILDER_URL_TEMPLATE = 'http://build.chromium.org/p/%s/json/builders'
21 NOT_AVAILABLE = 'N/A'
22
23
24 if __name__ == '__main__':
25 remote_api.EnableRemoteApi(app_id='findit-for-me')
26
27 trybots = FinditConfig.Get().builders_to_trybots
28 steps_for_masters_rules = FinditConfig.Get().steps_for_masters_rules
29 supported_masters = steps_for_masters_rules.get(
30 'supported_masters', {}).keys()
31 main_waterfall_cache = {}
32 variable_builders_cache = defaultdict(list)
33 tryservers = set()
34
35 print 'Determining missing support...'
36
37 for master in supported_masters:
38 any_missing = False
stgao 2016/05/18 20:57:55 nit: move to before where it is first used.
39
40 print 'Master: %s' % master
41
42 if not trybots.get(master):
43 print 'Not found. Tryjobs for %s may not be supported.' % master
44 print
45 continue
46
47 json_url = BUILDER_URL_TEMPLATE % master
48 try:
49 result = urlfetch.fetch(json_url, deadline=60)
50 main_waterfall_builders = json.loads(result.content).keys()
51 except Exception:
52 print 'Data could not be retrieved from %s' % json_url
53 print
54 main_waterfall_cache[master] = NOT_AVAILABLE
55 continue
56
57 # Cache the results for later when comparing for deprecated trybots.
58 main_waterfall_cache[master] = main_waterfall_builders
59
60 for builder in main_waterfall_builders:
61 if builder not in trybots[master]:
62 any_missing = True
63 print '\'%s\' is missing.' % builder
64 continue
65
66 # Cache the variable builders in use for determining if any should be
67 # deprecated.
68 tryserver = trybots[master][builder]['mastername']
69 tryservers.add(tryserver)
70 variable_builder = trybots[master][builder]['buildername']
71 variable_builders_cache[variable_builder].append(
72 {
73 'master': master,
74 'builder': builder
75 })
76
77 if not any_missing:
78 print 'OK'
79
80 print
81
82 print 'Determining deprecated bots...'
83
84 for master, trybot_mapping in trybots.iteritems():
85 print 'Master: %s' % master
86
87 any_deprecated = False
88 if master not in supported_masters:
chanli 2016/05/18 20:33:57 To improve readability, move supported_masters =
lijeffrey 2016/05/18 21:13:00 supported_masters is used in line 37 too, moved cl
89 print '\'%s\' is deprecated.' % master
90 any_deprecated = False
91 elif main_waterfall_cache.get(master) == NOT_AVAILABLE:
92 print 'Unable to determine support. Skipping.'
93 print
94 continue
95
96 for builder in trybot_mapping.keys():
97 if builder not in main_waterfall_cache.get(master, []):
98 print '\'%s\' is deprecated' % builder
99 any_deprecated = True
100
101 if not any_deprecated:
102 print 'OK'
103
104 print
105
106 print 'Determining unused variable builders...'
107
108 # Keep track of all variable builders in config.
109 variable_builders_in_config = set()
110 for master, builders in trybots.iteritems():
111 for builder_info in builders.values():
112 variable_builder = builder_info['buildername']
113 variable_builders_in_config.add(variable_builder)
114
115 for tryserver in tryservers:
116 print 'Tryserver: %s' % tryserver
117
118 json_url = BUILDER_URL_TEMPLATE % tryserver
119 try:
120 result = urlfetch.fetch(json_url, deadline=60)
121 tryserver_builders = json.loads(result.content).keys()
122 except Exception:
123 print 'Data could not be retrieved from %s' % json_url
124 print
125 continue
126
127 any_unused = False
128 for builder in tryserver_builders:
129 if 'variable' in builder and builder not in variable_builders_in_config:
130 print '\'%s\' is unused.' % builder
131 any_unused = True
132
133 if not any_unused:
134 print 'OK'
135
136 print
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698