Merge lp:~gnuoy/charm-helpers/nrpe-proxy into lp:charm-helpers

Proposed by Liam Young
Status: Merged
Merged at revision: 361
Proposed branch: lp:~gnuoy/charm-helpers/nrpe-proxy
Merge into: lp:charm-helpers
Diff against target: 52 lines (+17/-5)
2 files modified
charmhelpers/contrib/charmsupport/nrpe.py (+3/-1)
tests/contrib/charmsupport/test_nrpe.py (+14/-4)
To merge this branch: bzr merge lp:~gnuoy/charm-helpers/nrpe-proxy
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+256626@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/charmsupport/nrpe.py'
2--- charmhelpers/contrib/charmsupport/nrpe.py 2015-02-19 07:49:41 +0000
3+++ charmhelpers/contrib/charmsupport/nrpe.py 2015-04-17 08:38:54 +0000
4@@ -247,7 +247,9 @@
5
6 service('restart', 'nagios-nrpe-server')
7
8- for rid in relation_ids("local-monitors"):
9+ monitor_ids = relation_ids("local-monitors") + \
10+ relation_ids("nrpe-external-master")
11+ for rid in monitor_ids:
12 relation_set(relation_id=rid, monitors=yaml.dump(monitors))
13
14
15
16=== modified file 'tests/contrib/charmsupport/test_nrpe.py'
17--- tests/contrib/charmsupport/test_nrpe.py 2015-02-19 08:41:54 +0000
18+++ tests/contrib/charmsupport/test_nrpe.py 2015-04-17 08:38:54 +0000
19@@ -117,7 +117,14 @@
20 self.patched['config'].return_value = {'nagios_context': 'a',
21 'nagios_servicegroups': ''}
22 self.patched['exists'].return_value = True
23- self.patched['relation_ids'].return_value = ['local-monitors:1']
24+
25+ def _rels(rname):
26+ relations = {
27+ 'local-monitors': 'local-monitors:1',
28+ 'nrpe-external-master': 'nrpe-external-master:2',
29+ }
30+ return [relations[rname]]
31+ self.patched['relation_ids'].side_effect = _rels
32
33 checker = nrpe.NRPE()
34 checker.add_check(shortname="myservice",
35@@ -159,11 +166,14 @@
36 {'command': 'check_myservice'}}
37 monitors = yaml.dump(
38 {"monitors": {"remote": {"nrpe": nrpe_monitors}}})
39- self.patched['relation_set'].assert_called_once_with(
40- relation_id="local-monitors:1", monitors=monitors)
41+ relation_set_calls = [
42+ call(monitors=monitors, relation_id="local-monitors:1"),
43+ call(monitors=monitors, relation_id="nrpe-external-master:2"),
44+ ]
45+ self.patched['relation_set'].assert_has_calls(relation_set_calls, any_order=True)
46 self.check_call_counts(config=1, getpwnam=1, getgrnam=1,
47 exists=3, open=2, listdir=1,
48- relation_ids=1, relation_set=1)
49+ relation_ids=2, relation_set=2)
50
51
52 class NRPECheckTestCase(NRPEBaseTestCase):

Subscribers

People subscribed via source and target branches