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

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: Addressing comments 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 main_waterfall_cache = {}
30 variable_builders_cache = defaultdict(list)
31 tryservers = set()
32
33 print 'Determining missing support...'
34
35 supported_masters = steps_for_masters_rules.get(
36 'supported_masters', {}).keys()
37 for master in supported_masters:
38 print 'Master: %s' % master
39
40 if not trybots.get(master):
41 print 'Not found. Tryjobs for %s may not be supported.' % master
42 print
43 continue
44
45 json_url = BUILDER_URL_TEMPLATE % master
46 try:
47 result = urlfetch.fetch(json_url, deadline=60)
48 main_waterfall_builders = json.loads(result.content).keys()
49 except Exception:
50 print 'Data could not be retrieved from %s. Skipping.' % json_url
51 print
52 main_waterfall_cache[master] = NOT_AVAILABLE
53 continue
54
55 # Cache the results for later when checking for deprecated trybots.
56 main_waterfall_cache[master] = main_waterfall_builders
57
58 any_missing = False
59 for builder in main_waterfall_builders:
60 if builder not in trybots[master]:
61 any_missing = True
62 print '\'%s\' is missing.' % builder
63 continue
64
65 # Cache the variable builders in use for determining if any should be
66 # deprecated.
67 tryserver = trybots[master][builder]['mastername']
68 tryservers.add(tryserver)
69 variable_builder = trybots[master][builder]['buildername']
70 variable_builders_cache[variable_builder].append(
71 {
72 'master': master,
73 'builder': builder
74 })
75
76 if not any_missing:
77 print 'OK'
78
79 print
80
81 print 'Determining deprecated bots...'
82
83 for master, trybot_mapping in trybots.iteritems():
84 print 'Master: %s' % master
85
86 any_deprecated = False
87 if master not in supported_masters:
88 print '\'%s\' is deprecated.' % master
89 any_deprecated = False
90 elif main_waterfall_cache.get(master) == NOT_AVAILABLE:
91 print 'Unable to determine support. Skipping.'
92 print
93 continue
94
95 for builder in trybot_mapping.keys():
96 if builder not in main_waterfall_cache.get(master, []):
97 print '\'%s\' is deprecated.' % builder
98 any_deprecated = True
99
100 if not any_deprecated:
101 print 'OK'
102
103 print
104
105 print 'Determining unused variable builders...'
106
107 # Keep track of all variable builders in config.
108 variable_builders_in_config = set()
109 for master, builders in trybots.iteritems():
110 for builder_info in builders.values():
111 variable_builder = builder_info['buildername']
112 variable_builders_in_config.add(variable_builder)
113
114 for tryserver in tryservers:
115 print 'Tryserver: %s' % tryserver
116
117 json_url = BUILDER_URL_TEMPLATE % tryserver
118 try:
119 result = urlfetch.fetch(json_url, deadline=60)
120 tryserver_builders = json.loads(result.content).keys()
121 except Exception:
122 print 'Data could not be retrieved from %s' % json_url
123 print
124 continue
125
126 any_unused = False
127 for builder in tryserver_builders:
128 if 'variable' in builder and builder not in variable_builders_in_config:
129 print '\'%s\' is unused.' % builder
130 any_unused = True
131
132 if not any_unused:
133 print 'OK'
134
135 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