Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 import collections | |
|
Sergey Berezin
2016/01/08 18:54:13
Not used, remove.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Done.
| |
| 6 | |
| 7 class BotConfigAndTestDB(object): | |
|
Sergiy Byelozyorov
2016/01/08 10:35:57
IMHO, this should be named BuilderConfigAndTestDB,
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Sergiy and I talked about this during a Hangout th
Sergey Berezin
2016/01/08 23:31:59
Acknowledged.
| |
| 8 """An immutable database of bot configurations and test specifications. | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: s/bot/builder/ in the docstring as well - agr
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Please see above -- I think the term 'bot' should
| |
| 9 Holds the data for potentially multiple waterfalls (masternames). Most | |
| 10 queries against this database are made with (mastername, buildername) | |
| 11 pairs. | |
| 12 """ | |
| 13 | |
| 14 def __init__(self): | |
| 15 # Indexed by mastername. Each entry contains a master_dict and a | |
| 16 # test_spec. | |
| 17 self._db = {} | |
| 18 pass | |
|
Paweł Hajdan Jr.
2016/01/08 16:00:42
nit: This line shouldn't be needed now.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Done.
| |
| 19 | |
| 20 def _add_master_dict_and_test_spec(self, mastername, master_dict, test_spec): | |
| 21 """Only used during construction in chromium_tests.prepare_checkout. Do not | |
| 22 call this externally. | |
| 23 | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: remove the empty line.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Done.
| |
| 24 """ | |
| 25 # TODO(kbr): currently the master_dicts that are created by | |
| 26 # get_master_dict_with_dynamic_tests are over-specialized to a | |
| 27 # particular builder -- the "enable_swarming" flag paradoxically comes | |
| 28 # from that builder, rather than from each individual builder and/or | |
| 29 # the parent builder. This needs to be fixed so that there's exactly | |
| 30 # one master_dict per waterfall. | |
| 31 assert mastername not in self._db, ( | |
| 32 'Illegal attempt to add multiple master dictionaries for waterfall %s' % | |
| 33 (mastername)) | |
| 34 self._db[mastername] = { 'master_dict': master_dict, | |
| 35 'test_spec': test_spec } | |
| 36 | |
| 37 def get_bot_config(self, mastername, buildername): | |
| 38 return self._db[mastername]['master_dict'].get('builders', {}).get( | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: if mastername is not in the _db, this will ra
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
There should be strong guarantees that a dictionar
Sergey Berezin
2016/01/08 23:31:59
Ack. Agreed, let's fail with exception here.
| |
| 39 buildername) | |
| 40 | |
| 41 def get_master_settings(self, mastername): | |
| 42 return self._db[mastername]['master_dict'].get('settings', {}) | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: same as above.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Same reply.
| |
| 43 | |
| 44 def bot_configs_matching_parent_buildername( | |
| 45 self, mastername, parent_buildername): | |
| 46 """A generator of all the (buildername, bot_config) tuples whose | |
| 47 parent_buildername is the passed one on the given master. | |
| 48 | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: remove the empty line.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:45
Done.
| |
| 49 """ | |
| 50 for buildername, bot_config in self._db[mastername]['master_dict'].get( | |
| 51 'builders', {}).iteritems(): | |
| 52 if bot_config.get('parent_buildername') == parent_buildername: | |
| 53 yield buildername, bot_config | |
| 54 | |
| 55 def get_test_spec(self, mastername, buildername): | |
| 56 return self._db[mastername]['test_spec'].get(buildername, {}) | |
|
Sergey Berezin
2016/01/08 18:54:13
nit: same as above.
Ken Russell (switch to Gerrit)
2016/01/08 23:02:44
Same reply.
| |
| OLD | NEW |