Merge lp:~nicopace/charms/trusty/nagios/all-tests into lp:charms/trusty/nagios

Proposed by nicopace
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
Reviewer Review Type Date Requested Status
Cory Johns (community) Approve
amir sanjar (community) Disapprove
charmers Pending
Review via email: mp+251286@code.launchpad.net

Description of the change

Integration of all nagios tests implemented:
* initial test
* nrpe test
* ssl test
* monitors interface test
* extraconfig test

To post a comment you must log in.
Revision history for this message
amir sanjar (asanjar) wrote :

+1 all tests passed
(.venv)sanjar@sanjar-acer:~/development/charms$ bundletester -t nagios
nagios
    charm-proof PASS
    00-setup PASS
    10-initial-test PASS
    100-deploy PASS
    15-nrpe-test PASS
    20-ssl-test PASS
    21-monitors-interface-test PASS
    22-extraconfig-test PASS

PASS: 8 Total: 8 (0 sec)

review: Approve
Revision history for this message
amir sanjar (asanjar) wrote :

obviously bundletester itself is buggy, rerunning the test as follow
(.venv)sanjar@sanjar-acer:~/development/charms/trusty/nagios$ bundletester -v

Revision history for this message
amir sanjar (asanjar) wrote :

Test failed..
(.venv)sanjar@sanjar-acer:~/development/charms/trusty/nagios$ bundletester -v
nagios
    charm-proof PASS
[sudo] password for sanjar:
    00-setup PASS
    10-initial-test PASS
    100-deploy PASS
    15-nrpe-test ERROR

------------------------------------------------------------------------------
ERROR: nagios::15-nrpe-test
[/home/sanjar/development/charms/trusty/nagios/tests/15-nrpe-test exit 1]
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/juju-deployer", line 9, in <module>
    load_entry_point('juju-deployer==0.4.3', 'console_scripts', 'juju-deployer')()
  File "/usr/lib/python2.7/dist-packages/deployer/cli.py", line 130, in main
    run()
  File "/usr/lib/python2.7/dist-packages/deployer/cli.py", line 228, in run
    importer.Importer(env, deployment, options).run()
  File "/usr/lib/python2.7/dist-packages/deployer/action/importer.py", line 215, in run
    rels_created = self.add_relations()
  File "/usr/lib/python2.7/dist-packages/deployer/action/importer.py", line 131, in add_relations
    self.env.add_relation(end_a, end_b)
  File "/usr/lib/python2.7/dist-packages/deployer/env/go.py", line 34, in add_relation
    return self.client.add_relation(endpoint_a, endpoint_b)
  File "/usr/lib/python2.7/dist-packages/jujuclient.py", line 666, in add_relation
    'Endpoints': [endpoint_a, endpoint_b]
  File "/usr/lib/python2.7/dist-packages/jujuclient.py", line 148, in _rpc
    raise EnvError(result)
jujuclient.EnvError: <Env Error - Details:
 { u'Error': u'cannot add relation "nrpe:general-info mediawiki:juju-info": principal and subordinate services\' series must match',
    u'RequestId': 1,
    u'Response': { }}
 >
Traceback (most recent call last):
  File "/home/sanjar/development/charms/trusty/nagios/tests/15-nrpe-test", line 25, in <module>
    d.setup(timeout=seconds)
  File "/usr/lib/python3/dist-packages/amulet/deployer.py", line 315, in setup
    ], cwd=self.deployer_dir)
  File "/usr/lib/python3.4/subprocess.py", line 557, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['juju-deployer', '-W', '-L', '-c', '/tmp/amulet-juju-deployer-0_jxjpv4.json', '-e', 'local', '-t', '20100', 'local']' returned non-zero exit status 1

review: Disapprove
Revision history for this message
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_interface_with_ssl needs to be https:// instead of http://

  * Both calls to requests in test_web_interface_with_ssl need to include verify=False to skip certificate validation

  * The tests need to call d.sentry.wait() immediately after d.setup() to ensure that the environment stabilizes before running the tests

review: Needs Fixing
Revision history for this message
nicopace (nicopace) wrote :

> obviously bundletester itself is buggy, rerunning the test as follow
> (.venv)sanjar@sanjar-acer:~/development/charms/trusty/nagios$ bundletester -v

Why do you say that bundletester is buggy?
It is the tool i've been using all these 3 months for executing the tests.

32. By Nicolas Pace <email address hidden>

Get branch updates.

33. By Nicolas Pace <email address hidden>

Adds d.sentry.wait before setup, to stabilize the environment.

Revision history for this message
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_interface_with_ssl needs to be
> 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_interface_with_ssl need to include
> 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.

Revision history for this message
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.

Revision history for this message
nicopace (nicopace) wrote :

Bump

Revision history for this message
nicopace (nicopace) wrote :

So... @johnsca, is there any other conflict that is preventing this branch to be merged?

Revision history for this message
Cory Johns (johnsca) wrote :

Sorry for the delay. The 21-monitors-interface-test and 22-extraconfig-test tests are still missing d.sentry.wait(), but it turns out that the failure I was seeing was from the 21-monitors-interface-test test attempting to relate mysql and mediawiki when it doesn't deploy mediawiki.

review: Needs Fixing
Revision history for this message
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://code.launchpad.net/~johnsca/charms/trusty/nagios/all-tests/+merge/252786

review: Approve
34. By Nicolas Pace <email address hidden>

Cory changes

Revision history for this message
nicopace (nicopace) wrote :

Merged cory's code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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
6 try:
7 d.setup(timeout=seconds)
8+ d.sentry.wait()
9 except amulet.helpers.TimeoutError:
10 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
11 except:
12
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+#!/usr/bin/python3
18+
19+import amulet
20+import requests
21+
22+seconds = 20000
23+
24+d = amulet.Deployment(series='trusty')
25+
26+d.add('nagios')
27+d.add('mysql')
28+d.add('nrpe')
29+d.add('mediawiki')
30+
31+d.relate('mysql:db', 'mediawiki:db')
32+d.relate('nagios:monitors', 'mysql:monitors')
33+d.relate('nrpe:general-info', 'mysql:juju-info')
34+d.relate('nrpe:monitors', 'nagios:monitors')
35+d.relate('nrpe:local-monitors', 'mysql:local-monitors')
36+
37+d.expose('nagios')
38+
39+try:
40+ d.setup(timeout=seconds)
41+ d.sentry.wait()
42+except amulet.helpers.TimeoutError:
43+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
44+except:
45+ raise
46+
47+
48+##
49+# Set relationship aliases
50+##
51+mysql_unit = d.sentry.unit['mysql/0']
52+nagios_unit = d.sentry.unit['nagios/0']
53+
54+
55+def test_nrpe_monitors_config():
56+ # look for procrunning in nrpe config
57+ try:
58+ mysql_unit.file_contents('/etc/nagios/nrpe.d/procrunning_mysqld.cfg')
59+ except IOError as e:
60+ amulet.raise_status(amulet.ERROR,
61+ msg="procrunning config not found. Error:" +
62+ e.args[1])
63+
64+
65+def test_nagios_monitors_response():
66+ # look for mysql_database requests
67+ nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip()
68+ host_url = ("http://%s/cgi-bin/nagios3/status.cgi?"
69+ "host=mysql-0")
70+ r = requests.get(host_url % nagios_unit.info['public-address'],
71+ auth=('nagiosadmin', nagpwd))
72+ if not r.text.find('mysql-0-basic'):
73+ amulet.raise_status(amulet.ERROR,
74+ msg='Nagios is not monitoring the' +
75+ ' hosts it supposed to.')
76+
77+test_nrpe_monitors_config()
78+test_nagios_monitors_response()
79
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+#!/usr/bin/python3
85+
86+import amulet
87+import requests
88+
89+seconds = 20000
90+
91+d = amulet.Deployment(series='trusty')
92+
93+d.add('nagios')
94+d.add('mysql')
95+
96+d.expose('nagios')
97+d.expose('mysql')
98+
99+try:
100+ d.setup(timeout=seconds)
101+ d.sentry.wait()
102+except amulet.helpers.TimeoutError:
103+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
104+except:
105+ raise
106+
107+
108+##
109+# Set relationship aliases
110+##
111+mysql_unit = d.sentry.unit['mysql/0']
112+nagios_unit = d.sentry.unit['nagios/0']
113+
114+d.configure('nagios', {
115+ 'extraconfig': """
116+ define host{
117+ use generic-host ; Name of host template to use
118+ host_name server02
119+ alias Server 02
120+ address %s
121+}""" % mysql_unit.info['public-address']
122+})
123+
124+d.sentry.wait()
125+
126+
127+def test_hosts_being_monitored():
128+ nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip()
129+ host_url = ("http://%s/cgi-bin/nagios3/status.cgi?"
130+ "hostgroup=all&style=hostdetail")
131+ r = requests.get(host_url % nagios_unit.info['public-address'],
132+ auth=('nagiosadmin', nagpwd))
133+ if not r.text.find('server02'):
134+ amulet.raise_status(amulet.ERROR,
135+ msg='Nagios is not monitoring the' +
136+ ' hosts it supposed to.')
137+
138+
139+test_hosts_being_monitored()

Subscribers

People subscribed via source and target branches

to all changes: