Merge lp:~nicopace/charms/trusty/nagios/all-tests into lp:charms/trusty/nagios
- Trusty Tahr (14.04)
- all-tests
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 30 |
Proposed branch: | lp:~nicopace/charms/trusty/nagios/all-tests |
Merge into: | lp:charms/trusty/nagios |
Diff against target: |
139 lines (+119/-0) 3 files modified
tests/20-ssl-test (+1/-0) tests/21-monitors-interface-test (+62/-0) tests/22-extraconfig-test (+56/-0) |
To merge this branch: | bzr merge lp:~nicopace/charms/trusty/nagios/all-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cory Johns (community) | Approve | ||
amir sanjar (community) | Disapprove | ||
charmers | Pending | ||
Review via email: mp+251286@code.launchpad.net |
Commit message
Description of the change
Integration of all nagios tests implemented:
* initial test
* nrpe test
* ssl test
* monitors interface test
* extraconfig test
amir sanjar (asanjar) wrote : | # |
obviously bundletester itself is buggy, rerunning the test as follow
(.venv)
amir sanjar (asanjar) wrote : | # |
Test failed..
(.venv)
nagios
charm-proof PASS
[sudo] password for sanjar:
00-setup PASS
10-initial-test PASS
100-deploy PASS
15-nrpe-test ERROR
-------
ERROR: nagios:
[/home/
2015-02-27 14:46:10 Starting deployment of local
2015-02-27 14:46:12 Deploying services...
2015-02-27 14:46:18 Adding relations...
2015-02-27 14:46:19 Adding relation nrpe:general-info <-> mediawiki:juju-info
Traceback (most recent call last):
File "/usr/bin/
load_
File "/usr/lib/
run()
File "/usr/lib/
importer.
File "/usr/lib/
rels_created = self.add_
File "/usr/lib/
self.
File "/usr/lib/
return self.client.
File "/usr/lib/
'Endpoints': [endpoint_a, endpoint_b]
File "/usr/lib/
raise EnvError(result)
jujuclient.
{ u'Error': u'cannot add relation "nrpe:general-info mediawiki:
u'RequestId': 1,
u'Response': { }}
>
Traceback (most recent call last):
File "/home/
d.setup(
File "/usr/lib/
], cwd=self.
File "/usr/lib/
raise CalledProcessEr
subprocess.
Cory Johns (johnsca) wrote : | # |
Nicolas,
I think Amir's error was due to checking out the branch directly instead of merging it against the upstream. It seems that the missing default series was fixed in the upstream already. With that fix, however, there are still the following issues with the tests:
* The first call to requests in test_web_
* Both calls to requests in test_web_
* The tests need to call d.sentry.wait() immediately after d.setup() to ensure that the environment stabilizes before running the tests
nicopace (nicopace) wrote : | # |
> obviously bundletester itself is buggy, rerunning the test as follow
> (.venv)
Why do you say that bundletester is buggy?
It is the tool i've been using all these 3 months for executing the tests.
nicopace (nicopace) wrote : | # |
> Nicolas,
>
> I think Amir's error was due to checking out the branch directly instead of
> merging it against the upstream. It seems that the missing default series was
> fixed in the upstream already. With that fix, however, there are still the
> following issues with the tests:
>
> * The first call to requests in test_web_
> https:// instead of http://
The first option tests the 'on' option. That means that nagios should provide http and https (that's why the first request is without ssl, and the second with.
>
> * Both calls to requests in test_web_
> verify=False to skip certificate validation
The first one doesn't use ssl, so it is not required.
>
> * The tests need to call d.sentry.wait() immediately after d.setup() to
> ensure that the environment stabilizes before running the tests
I've updated the test to reflect this.
Cory Johns (johnsca) wrote : | # |
> The first option tests the 'on' option. That means that nagios should provide
> http and https (that's why the first request is without ssl, and the second
> with.
Ah, fair enough. I think we saw a connection error on the plain http: request at one point, so assume that SSL on meant only SSL, but it makes much more sense that it would enable both and that the test should cover that. It's likely that the connection error we saw was actually due to the missing sentry.wait() calls, so I'll go ahead and re-run those tests to see if that resolved the issue.
nicopace (nicopace) wrote : | # |
Bump
nicopace (nicopace) wrote : | # |
So... @johnsca, is there any other conflict that is preventing this branch to be merged?
Cory Johns (johnsca) wrote : | # |
Sorry for the delay. The 21-monitors-
Cory Johns (johnsca) wrote : | # |
I created a MP against this branch with the fixes from my previous comment. With that applied, I would give this a +1.
https:/
- 34. By Nicolas Pace <email address hidden>
-
Cory changes
nicopace (nicopace) wrote : | # |
Merged cory's code
Preview Diff
1 | === modified file 'tests/20-ssl-test' | |||
2 | --- tests/20-ssl-test 2015-02-03 19:48:51 +0000 | |||
3 | +++ tests/20-ssl-test 2015-03-18 00:31:39 +0000 | |||
4 | @@ -21,6 +21,7 @@ | |||
5 | 21 | 21 | ||
6 | 22 | try: | 22 | try: |
7 | 23 | d.setup(timeout=seconds) | 23 | d.setup(timeout=seconds) |
8 | 24 | d.sentry.wait() | ||
9 | 24 | except amulet.helpers.TimeoutError: | 25 | except amulet.helpers.TimeoutError: |
10 | 25 | amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time") | 26 | amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time") |
11 | 26 | except: | 27 | except: |
12 | 27 | 28 | ||
13 | === added file 'tests/21-monitors-interface-test' | |||
14 | --- tests/21-monitors-interface-test 1970-01-01 00:00:00 +0000 | |||
15 | +++ tests/21-monitors-interface-test 2015-03-18 00:31:39 +0000 | |||
16 | @@ -0,0 +1,62 @@ | |||
17 | 1 | #!/usr/bin/python3 | ||
18 | 2 | |||
19 | 3 | import amulet | ||
20 | 4 | import requests | ||
21 | 5 | |||
22 | 6 | seconds = 20000 | ||
23 | 7 | |||
24 | 8 | d = amulet.Deployment(series='trusty') | ||
25 | 9 | |||
26 | 10 | d.add('nagios') | ||
27 | 11 | d.add('mysql') | ||
28 | 12 | d.add('nrpe') | ||
29 | 13 | d.add('mediawiki') | ||
30 | 14 | |||
31 | 15 | d.relate('mysql:db', 'mediawiki:db') | ||
32 | 16 | d.relate('nagios:monitors', 'mysql:monitors') | ||
33 | 17 | d.relate('nrpe:general-info', 'mysql:juju-info') | ||
34 | 18 | d.relate('nrpe:monitors', 'nagios:monitors') | ||
35 | 19 | d.relate('nrpe:local-monitors', 'mysql:local-monitors') | ||
36 | 20 | |||
37 | 21 | d.expose('nagios') | ||
38 | 22 | |||
39 | 23 | try: | ||
40 | 24 | d.setup(timeout=seconds) | ||
41 | 25 | d.sentry.wait() | ||
42 | 26 | except amulet.helpers.TimeoutError: | ||
43 | 27 | amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time") | ||
44 | 28 | except: | ||
45 | 29 | raise | ||
46 | 30 | |||
47 | 31 | |||
48 | 32 | ## | ||
49 | 33 | # Set relationship aliases | ||
50 | 34 | ## | ||
51 | 35 | mysql_unit = d.sentry.unit['mysql/0'] | ||
52 | 36 | nagios_unit = d.sentry.unit['nagios/0'] | ||
53 | 37 | |||
54 | 38 | |||
55 | 39 | def test_nrpe_monitors_config(): | ||
56 | 40 | # look for procrunning in nrpe config | ||
57 | 41 | try: | ||
58 | 42 | mysql_unit.file_contents('/etc/nagios/nrpe.d/procrunning_mysqld.cfg') | ||
59 | 43 | except IOError as e: | ||
60 | 44 | amulet.raise_status(amulet.ERROR, | ||
61 | 45 | msg="procrunning config not found. Error:" + | ||
62 | 46 | e.args[1]) | ||
63 | 47 | |||
64 | 48 | |||
65 | 49 | def test_nagios_monitors_response(): | ||
66 | 50 | # look for mysql_database requests | ||
67 | 51 | nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip() | ||
68 | 52 | host_url = ("http://%s/cgi-bin/nagios3/status.cgi?" | ||
69 | 53 | "host=mysql-0") | ||
70 | 54 | r = requests.get(host_url % nagios_unit.info['public-address'], | ||
71 | 55 | auth=('nagiosadmin', nagpwd)) | ||
72 | 56 | if not r.text.find('mysql-0-basic'): | ||
73 | 57 | amulet.raise_status(amulet.ERROR, | ||
74 | 58 | msg='Nagios is not monitoring the' + | ||
75 | 59 | ' hosts it supposed to.') | ||
76 | 60 | |||
77 | 61 | test_nrpe_monitors_config() | ||
78 | 62 | test_nagios_monitors_response() | ||
79 | 0 | 63 | ||
80 | === added file 'tests/22-extraconfig-test' | |||
81 | --- tests/22-extraconfig-test 1970-01-01 00:00:00 +0000 | |||
82 | +++ tests/22-extraconfig-test 2015-03-18 00:31:39 +0000 | |||
83 | @@ -0,0 +1,56 @@ | |||
84 | 1 | #!/usr/bin/python3 | ||
85 | 2 | |||
86 | 3 | import amulet | ||
87 | 4 | import requests | ||
88 | 5 | |||
89 | 6 | seconds = 20000 | ||
90 | 7 | |||
91 | 8 | d = amulet.Deployment(series='trusty') | ||
92 | 9 | |||
93 | 10 | d.add('nagios') | ||
94 | 11 | d.add('mysql') | ||
95 | 12 | |||
96 | 13 | d.expose('nagios') | ||
97 | 14 | d.expose('mysql') | ||
98 | 15 | |||
99 | 16 | try: | ||
100 | 17 | d.setup(timeout=seconds) | ||
101 | 18 | d.sentry.wait() | ||
102 | 19 | except amulet.helpers.TimeoutError: | ||
103 | 20 | amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time") | ||
104 | 21 | except: | ||
105 | 22 | raise | ||
106 | 23 | |||
107 | 24 | |||
108 | 25 | ## | ||
109 | 26 | # Set relationship aliases | ||
110 | 27 | ## | ||
111 | 28 | mysql_unit = d.sentry.unit['mysql/0'] | ||
112 | 29 | nagios_unit = d.sentry.unit['nagios/0'] | ||
113 | 30 | |||
114 | 31 | d.configure('nagios', { | ||
115 | 32 | 'extraconfig': """ | ||
116 | 33 | define host{ | ||
117 | 34 | use generic-host ; Name of host template to use | ||
118 | 35 | host_name server02 | ||
119 | 36 | alias Server 02 | ||
120 | 37 | address %s | ||
121 | 38 | }""" % mysql_unit.info['public-address'] | ||
122 | 39 | }) | ||
123 | 40 | |||
124 | 41 | d.sentry.wait() | ||
125 | 42 | |||
126 | 43 | |||
127 | 44 | def test_hosts_being_monitored(): | ||
128 | 45 | nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip() | ||
129 | 46 | host_url = ("http://%s/cgi-bin/nagios3/status.cgi?" | ||
130 | 47 | "hostgroup=all&style=hostdetail") | ||
131 | 48 | r = requests.get(host_url % nagios_unit.info['public-address'], | ||
132 | 49 | auth=('nagiosadmin', nagpwd)) | ||
133 | 50 | if not r.text.find('server02'): | ||
134 | 51 | amulet.raise_status(amulet.ERROR, | ||
135 | 52 | msg='Nagios is not monitoring the' + | ||
136 | 53 | ' hosts it supposed to.') | ||
137 | 54 | |||
138 | 55 | |||
139 | 56 | test_hosts_being_monitored() |
+1 all tests passed sanjar@ sanjar- acer:~/ development/ charms$ bundletester -t nagios monitors- interface- test PASS extraconfig- test PASS
(.venv)
nagios
charm-proof PASS
00-setup PASS
10-initial-test PASS
100-deploy PASS
15-nrpe-test PASS
20-ssl-test PASS
21-
22-
PASS: 8 Total: 8 (0 sec)