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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/chromium_tests/bot_config_and_test_db.py
diff --git a/scripts/slave/recipe_modules/chromium_tests/bot_config_and_test_db.py b/scripts/slave/recipe_modules/chromium_tests/bot_config_and_test_db.py
new file mode 100644
index 0000000000000000000000000000000000000000..c90aa3612e68646aacf4c4551bde6277f9741f0a
--- /dev/null
+++ b/scripts/slave/recipe_modules/chromium_tests/bot_config_and_test_db.py
@@ -0,0 +1,51 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+class BotConfigAndTestDB(object):
+ """An immutable database of bot configurations and test specifications.
+ Holds the data for potentially multiple waterfalls (masternames). Most
+ queries against this database are made with (mastername, buildername)
+ pairs.
+ """
+
+ def __init__(self):
+ # Indexed by mastername. Each entry contains a master_dict and a
+ # test_spec.
+ self._db = {}
+
+ def _add_master_dict_and_test_spec(self, mastername, master_dict, test_spec):
+ """Only used during construction in chromium_tests.prepare_checkout. Do not
+ call this externally.
+ """
+ # TODO(kbr): currently the master_dicts that are created by
+ # get_master_dict_with_dynamic_tests are over-specialized to a
+ # particular builder -- the "enable_swarming" flag paradoxically comes
+ # from that builder, rather than from each individual builder and/or
+ # the parent builder. This needs to be fixed so that there's exactly
+ # one master_dict per waterfall.
+ assert mastername not in self._db, (
+ 'Illegal attempt to add multiple master dictionaries for waterfall %s' %
+ (mastername))
+ self._db[mastername] = { 'master_dict': master_dict,
+ 'test_spec': test_spec }
+
+ def get_bot_config(self, mastername, buildername):
+ return self._db[mastername]['master_dict'].get('builders', {}).get(
+ buildername)
+
+ def get_master_settings(self, mastername):
+ return self._db[mastername]['master_dict'].get('settings', {})
+
+ def bot_configs_matching_parent_buildername(
+ self, mastername, parent_buildername):
+ """A generator of all the (buildername, bot_config) tuples whose
+ parent_buildername is the passed one on the given master.
+ """
+ for buildername, bot_config in self._db[mastername]['master_dict'].get(
+ 'builders', {}).iteritems():
+ if bot_config.get('parent_buildername') == parent_buildername:
+ yield buildername, bot_config
+
+ def get_test_spec(self, mastername, buildername):
+ return self._db[mastername]['test_spec'].get(buildername, {})
« 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