Merge lp:~bigkevmcd/offspring/master-dont-scan-slaves into lp:offspring

Proposed by Kevin McDermott on 2013-01-03
Status: Work in progress
Proposed branch: lp:~bigkevmcd/offspring/master-dont-scan-slaves
Merge into: lp:offspring
Diff against target: 71 lines (+18/-6)
2 files modified
lib/offspring/master/master.py (+3/-3)
lib/offspring/master/tests/test_master.py (+15/-3)
To merge this branch: bzr merge lp:~bigkevmcd/offspring/master-dont-scan-slaves
Reviewer Review Type Date Requested Status
Offspring Committers 2013-01-03 Pending
Review via email: mp+141758@code.launchpad.net

Description of the change

This changes the behaviour of the master to not include builders marked as not active, which cuts down on logged errors.

To post a comment you must log in.

Unmerged revisions

155. By Kevin McDermott on 2013-01-03

Implement fix for this.

154. By Kevin McDermott on 2013-01-03

Failing test for filtering slaves.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/offspring/master/master.py'
2--- lib/offspring/master/master.py 2012-08-21 13:38:17 +0000
3+++ lib/offspring/master/master.py 2013-01-03 14:02:23 +0000
4@@ -77,14 +77,14 @@
5 def stop(self):
6 self.is_online = False
7
8- def _get_builders(self):
9- return self.db_store.find(Lexbuilder)
10+ def get_builders(self):
11+ return self.db_store.find(Lexbuilder, Lexbuilder.is_active==True)
12
13 def scanSlaves(self):
14 """
15 Scan the currently known build slaves.
16 """
17- for builder in self._get_builders():
18+ for builder in self.get_builders():
19 try:
20 old_state, new_state = builder.scan()
21 except SlaveCommunicationError, issue:
22
23=== modified file 'lib/offspring/master/tests/test_master.py'
24--- lib/offspring/master/tests/test_master.py 2012-08-21 13:38:17 +0000
25+++ lib/offspring/master/tests/test_master.py 2013-01-03 14:02:23 +0000
26@@ -28,7 +28,8 @@
27 return LexbuilderMaster(self.config, self.db_store,
28 mailer=self.mailer.mail)
29
30- def create_builder(self, current_state=Slave.STATE_IDLE, arch=None):
31+ def create_builder(
32+ self, current_state=Slave.STATE_IDLE, arch=None, is_active=True):
33 """
34 Create and add a Lexbuilder to the store.
35 """
36@@ -36,7 +37,7 @@
37 builder.name = u"test-builder"
38 builder.previous_state = Slave.STATE_IDLE
39 builder.current_state = current_state
40- builder.is_active = True
41+ builder.is_active = is_active
42 builder.is_okay = True
43 builder.machine_type = arch or self.project.arch
44 self.db_store.add(builder)
45@@ -104,7 +105,7 @@
46 fake_builder = FakeBuilder(Slave.STATE_IDLE, None)
47 master = self.get_master()
48 mock_builder = self.mocker.patch(master)
49- mock_builder._get_builders()
50+ mock_builder.get_builders()
51 self.mocker.result([fake_builder])
52 self.mocker.replay()
53
54@@ -216,6 +217,17 @@
55 "Scan cycle completed\n" % {"builder": builder.name},
56 log_file.getvalue())
57
58+ def test_get_builders(self):
59+ """
60+ LexbuilderMaster.get_builders should return active Lexbuilders.
61+ """
62+ builder1 = self.create_builder()
63+ builder2 = self.create_builder(is_active=False)
64+
65+ master = self.get_master()
66+ result = master.get_builders()
67+ self.assertEqual([builder1], list(result))
68+
69 def test_dispatch_builds(self):
70 """
71 dispatchBuilds sends BuildRequests to a slave.

Subscribers

People subscribed via source and target branches