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

Side by Side Diff: scripts/slave/recipe_modules/chromium_tests/bot_config_and_test_db.py

Issue 1565113003: Add concept of bot config and test spec database (BotConfigAndTestDB). (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Rebased. (Probably unnecessary.) Created 4 years, 11 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
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 class BotConfigAndTestDB(object):
6 """An immutable database of bot configurations and test specifications.
7 Holds the data for potentially multiple waterfalls (masternames). Most
8 queries against this database are made with (mastername, buildername)
9 pairs.
10 """
11
12 def __init__(self):
13 # Indexed by mastername. Each entry contains a master_dict and a
14 # test_spec.
15 self._db = {}
16
17 def _add_master_dict_and_test_spec(self, mastername, master_dict, test_spec):
18 """Only used during construction in chromium_tests.prepare_checkout. Do not
19 call this externally.
20 """
21 # TODO(kbr): currently the master_dicts that are created by
22 # get_master_dict_with_dynamic_tests are over-specialized to a
23 # particular builder -- the "enable_swarming" flag paradoxically comes
24 # from that builder, rather than from each individual builder and/or
25 # the parent builder. This needs to be fixed so that there's exactly
26 # one master_dict per waterfall.
27 assert mastername not in self._db, (
28 'Illegal attempt to add multiple master dictionaries for waterfall %s' %
29 (mastername))
30 self._db[mastername] = { 'master_dict': master_dict,
31 'test_spec': test_spec }
32
33 def get_bot_config(self, mastername, buildername):
34 return self._db[mastername]['master_dict'].get('builders', {}).get(
35 buildername)
36
37 def get_master_settings(self, mastername):
38 return self._db[mastername]['master_dict'].get('settings', {})
39
40 def bot_configs_matching_parent_buildername(
41 self, mastername, parent_buildername):
42 """A generator of all the (buildername, bot_config) tuples whose
43 parent_buildername is the passed one on the given master.
44 """
45 for buildername, bot_config in self._db[mastername]['master_dict'].get(
46 'builders', {}).iteritems():
47 if bot_config.get('parent_buildername') == parent_buildername:
48 yield buildername, bot_config
49
50 def get_test_spec(self, mastername, buildername):
51 return self._db[mastername]['test_spec'].get(buildername, {})
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/chromium_tests/api.py ('k') | scripts/slave/recipe_modules/perf_try/api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698