Merge lp:~bigkevmcd/offspring/bug-1039135-fix-notifications into lp:offspring

Proposed by Kevin McDermott
Status: Merged
Approved by: Cody A.W. Somerville
Approved revision: 153
Merged at revision: 153
Proposed branch: lp:~bigkevmcd/offspring/bug-1039135-fix-notifications
Merge into: lp:offspring
Diff against target: 53 lines (+35/-0)
2 files modified
lib/offspring/master/master.py (+1/-0)
lib/offspring/master/tests/test_master.py (+34/-0)
To merge this branch: bzr merge lp:~bigkevmcd/offspring/bug-1039135-fix-notifications
Reviewer Review Type Date Requested Status
Cody A.W. Somerville Approve
Review via email: mp+120567@code.launchpad.net

Description of the change

Test and fix for this bug.

To post a comment you must log in.
Revision history for this message
Cody A.W. Somerville (cody-somerville) wrote :

Looks good. Thanks for tackling this so quickly Kevin - much appreciated!

review: Approve

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-04-10 10:18:46 +0000
3+++ lib/offspring/master/master.py 2012-08-21 13:40:24 +0000
4@@ -66,6 +66,7 @@
5 "Uncaught error propagated to main execution loop.")
6 notifications.notify_crash(
7 "Lexbuilder Master (Build Queue Dispatcher)",
8+ self.config,
9 mailer=self.mailer)
10 logging.error(
11 "SHUTTING DOWN: Fatal error has occurred.")
12
13=== modified file 'lib/offspring/master/tests/test_master.py'
14--- lib/offspring/master/tests/test_master.py 2012-04-10 10:18:46 +0000
15+++ lib/offspring/master/tests/test_master.py 2012-08-21 13:40:24 +0000
16@@ -368,3 +368,37 @@
17 "name": self.project.name, "priority": self.project.priority,
18 "builder": builder1.name},
19 log_file.getvalue())
20+
21+
22+ def test_run_dispatches_errors_correctly(self):
23+ """
24+ If an error is triggered during the master run, it should call
25+ notification successfully.
26+ """
27+ log_file = self.capture_logging(log_level=logging.DEBUG)
28+ sleep_mock = self.mocker.replace("time.sleep")
29+ sleep_mock(20)
30+ sys_exit_mock = self.mocker.replace("sys.exit")
31+ sys_exit_mock(1)
32+
33+ self.config.set("master", "poll_frequency", "20")
34+ master = self.get_master()
35+ mock_master = self.mocker.patch(master)
36+ mock_master.scanSlaves()
37+ self.mocker.throw(ValueError("Just a Test"))
38+
39+ # We need to set the value of "self.is_online" so that it will run only
40+ # once.
41+ mock_master.is_online
42+ self.mocker.result(True)
43+ mock_master.is_online
44+ self.mocker.result(False)
45+
46+ self.mocker.replay()
47+ master.run()
48+ self.assertEqual(('Lexbuilder Master (Build Queue Dispatcher) <testing@example.com>',
49+ 'testing@example.com'),
50+ self.mailer.mails[0][0:2])
51+ log = log_file.getvalue()
52+ self.assertTrue("SHUTTING DOWN: Fatal error has occurred." in log,
53+ "Master didn't shutdown on fatal error.")

Subscribers

People subscribed via source and target branches