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

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

Issue 1575393002: Enhance chromium_tests.configure_build for generalized trybot mirroring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5
6 class BotConfig(object):
7 """Wrapper that allows combining several compatible bot configs."""
8
9 def __init__(self, bots_dict, bot_ids):
10 self._bots_dict = bots_dict
11
12 assert len(bot_ids) >= 1
13 self._bot_ids = bot_ids
14
15 def _consistent_get(self, getter, name, default=None):
16 result = getter(self._bot_ids[0], name, default)
17 for bot_id in self._bot_ids:
18 other_result = getter(bot_id, name, default)
19 assert result == other_result, (
20 'Inconsistent value for %r: bot %r has %r, '
21 'but bot %r has %r' % (
22 name, self._bot_ids[0], result, bot_id, other_result))
23 return result
24
25 def _get(self, bot_id, name, default=None):
26 return self._bots_dict.get(bot_id['mastername'], {}).get(
27 'builders', {}).get(bot_id['buildername'], {}).get(name, default)
28
29 def get(self, name, default=None):
30 return self._consistent_get(self._get, name, default)
Ken Russell (switch to Gerrit) 2016/01/12 18:06:21 This will need to be relaxed or generalized in the
Ken Russell (switch to Gerrit) 2016/01/12 18:20:35 Pawel and I talked offline about ensuring that the
31
32 def _get_master_setting(self, bot_id, name, default=None):
33 return self._bots_dict.get(bot_id['mastername'], {}).get(
34 'settings', {}).get(name, default)
35
36 def get_master_setting(self, name, default=None):
37 return self._consistent_get(self._get_master_setting, name, default)
38
39
5 class BotConfigAndTestDB(object): 40 class BotConfigAndTestDB(object):
6 """An immutable database of bot configurations and test specifications. 41 """An immutable database of bot configurations and test specifications.
7 Holds the data for potentially multiple waterfalls (masternames). Most 42 Holds the data for potentially multiple waterfalls (masternames). Most
8 queries against this database are made with (mastername, buildername) 43 queries against this database are made with (mastername, buildername)
9 pairs. 44 pairs.
10 """ 45 """
11 46
12 def __init__(self): 47 def __init__(self):
13 # Indexed by mastername. Each entry contains a master_dict and a 48 # Indexed by mastername. Each entry contains a master_dict and a
14 # test_spec. 49 # test_spec.
(...skipping 27 matching lines...) Expand all
42 """A generator of all the (buildername, bot_config) tuples whose 77 """A generator of all the (buildername, bot_config) tuples whose
43 parent_buildername is the passed one on the given master. 78 parent_buildername is the passed one on the given master.
44 """ 79 """
45 for buildername, bot_config in self._db[mastername]['master_dict'].get( 80 for buildername, bot_config in self._db[mastername]['master_dict'].get(
46 'builders', {}).iteritems(): 81 'builders', {}).iteritems():
47 if bot_config.get('parent_buildername') == parent_buildername: 82 if bot_config.get('parent_buildername') == parent_buildername:
48 yield buildername, bot_config 83 yield buildername, bot_config
49 84
50 def get_test_spec(self, mastername, buildername): 85 def get_test_spec(self, mastername, buildername):
51 return self._db[mastername]['test_spec'].get(buildername, {}) 86 return self._db[mastername]['test_spec'].get(buildername, {})
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698