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

Proposed by nicopace
Status: Merged
Merged at revision: 53
Proposed branch: lp:~nicopace/charms/trusty/squid-reverseproxy/all-tests
Merge into: lp:charms/trusty/squid-reverseproxy
Diff against target: 481 lines (+432/-0)
10 files modified
tests/00-setup (+16/-0)
tests/12-nagios.py (+46/-0)
tests/13-squid-apache.py (+44/-0)
tests/14-listening-port.py (+50/-0)
tests/15-port-options.py (+71/-0)
tests/16-https.py (+59/-0)
tests/17-via.py (+52/-0)
tests/19-snmp.py (+45/-0)
tests/cert.cert (+21/-0)
tests/cert.key (+28/-0)
To merge this branch: bzr merge lp:~nicopace/charms/trusty/squid-reverseproxy/all-tests
Reviewer Review Type Date Requested Status
Whit Morriss (community) Disapprove
charmers Pending
Review via email: mp+251999@code.launchpad.net

Description of the change

Battery of tests for squid-reverseproxy.
They will all fail, as there is an open bug on this charm: https://bugs.launchpad.net/charms/+source/squid-reverseproxy/+bug/1426152

To post a comment you must log in.
Revision history for this message
Whit Morriss (whitmo) wrote :

Merges cleanly

Revision history for this message
Whit Morriss (whitmo) wrote :

https://gist.github.com/whitmo/8a30bbb4bbf9a5b01ac8

Package install and python compatibility issue.

-1 needs fixing

review: Disapprove
Revision history for this message
nicopace (nicopace) wrote :

The test implementation doesn't have to fix existing issues.
This charm already fails to install without this patch.

On Tuesday, March 10, 2015, Whit Morriss <email address hidden> wrote:

> Review: Disapprove
>
> https://gist.github.com/whitmo/8a30bbb4bbf9a5b01ac8
>
> Package install and python compatibility issue.
>
> -1 needs fixing
> --
>
> https://code.launchpad.net/~nicopace/charms/trusty/squid-reverseproxy/all-tests/+merge/251999
> You are the owner of
> lp:~nicopace/charms/trusty/squid-reverseproxy/all-tests.
>

--
Ing. Nicolás Pace

Revision history for this message
nicopace (nicopace) wrote :

The test implementation doesn't have to fix existing issues.
This charm already fails to install without this patch.

Revision history for this message
Whit Morriss (whitmo) wrote :

while true, I can't recommend merging and pushing to the store while there
is this issue.

-w

On Tue, Mar 10, 2015 at 10:42 AM, nicopace <email address hidden> wrote:

> The test implementation doesn't have to fix existing issues.
> This charm already fails to install without this patch.
> --
>
> https://code.launchpad.net/~nicopace/charms/trusty/squid-reverseproxy/all-tests/+merge/251999
> You are reviewing the proposed merge of
> lp:~nicopace/charms/trusty/squid-reverseproxy/all-tests into
> lp:charms/trusty/squid-reverseproxy.
>

--
---------------
D. Whit Morriss
Developer, Juju Ecosystem
Canonical USA

Revision history for this message
Whit Morriss (whitmo) wrote :

nico, I'm attempting to contact the maintainers to get the base issues fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/00-setup'
2--- tests/00-setup 1970-01-01 00:00:00 +0000
3+++ tests/00-setup 2015-03-05 18:48:27 +0000
4@@ -0,0 +1,16 @@
5+#!/bin/bash
6+
7+# This script sets up the requirements for amulet tests.
8+
9+set -x
10+
11+# Check if amulet is installed before adding the stable repository and updating apt-get.
12+dpkg -s amulet
13+if [ $? -ne 0 ]; then
14+ sudo add-apt-repository -y ppa:juju/stable
15+ sudo apt-get update -qq
16+ sudo apt-get install -y amulet
17+fi
18+
19+# Install any additional python packages and other required software.
20+sudo apt-get install -y python3-requests squidclient
21
22=== added file 'tests/12-nagios.py'
23--- tests/12-nagios.py 1970-01-01 00:00:00 +0000
24+++ tests/12-nagios.py 2015-03-05 18:48:27 +0000
25@@ -0,0 +1,46 @@
26+#!/usr/bin/python3
27+import amulet
28+import requests
29+
30+seconds = 20000
31+
32+d = amulet.Deployment(series='trusty')
33+
34+d.add('squid-reverseproxy')
35+d.add('nagios')
36+d.add('nrpe-external-master')
37+
38+d.relate('nagios:monitors', 'squid-reverseproxy:monitors')
39+d.relate('nrpe-external-master:general-info', 'squid-reverseproxy:juju-info')
40+d.relate('nrpe-external-master:monitors', 'nagios:monitors')
41+
42+d.expose('nagios')
43+
44+try:
45+ d.setup(timeout=seconds)
46+except amulet.helpers.TimeoutError:
47+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
48+except:
49+ raise
50+
51+
52+##
53+# Set relationship aliases
54+##
55+squid_unit = d.sentry.unit['squid/0']
56+nagios_unit = d.sentry.unit['nagios/0']
57+
58+
59+def test_hosts_being_monitored():
60+ nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip()
61+ host_url = ("http://%s/cgi-bin/nagios3/status.cgi?"
62+ "hostgroup=all&style=hostdetail")
63+ r = requests.get(host_url % nagios_unit.info['public-address'],
64+ auth=('nagiosadmin', nagpwd))
65+ if not r.text.find('squid'):
66+ amulet.raise_status(amulet.ERROR,
67+ msg='Nagios is not monitoring the' +
68+ ' host it supposed to.')
69+
70+
71+test_hosts_being_monitored()
72
73=== added file 'tests/13-squid-apache.py'
74--- tests/13-squid-apache.py 1970-01-01 00:00:00 +0000
75+++ tests/13-squid-apache.py 2015-03-05 18:48:27 +0000
76@@ -0,0 +1,44 @@
77+#!/usr/bin/python3
78+import amulet
79+import requests
80+
81+seconds = 20000
82+
83+d = amulet.Deployment(series='trusty')
84+
85+d.add('apache2')
86+d.add('squid-reverseproxy')
87+
88+d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
89+
90+d.expose('apache2')
91+d.expose('squid-reverseproxy')
92+
93+try:
94+ d.setup(timeout=seconds)
95+except amulet.helpers.TimeoutError:
96+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
97+except:
98+ raise
99+
100+
101+##
102+# Set relationship aliases
103+##
104+squid_unit = d.sentry.unit['squid-reverseproxy/0']
105+apache_unit = d.sentry.unit['apache2/0']
106+
107+
108+def test_web_proxy():
109+ url = 'http://%s/'
110+ squid_request = requests.get(url % squid_unit.info['public-address'])
111+ apache_request = requests.get(url % apache_unit.info['public-address'])
112+ if not squid_request.ok or not apache_request.ok:
113+ amulet.raise_status(amulet.FAIL,
114+ msg="Error connecting.")
115+ if squid_request.text != apache_request.text:
116+ amulet.raise_status(amulet.FAIL,
117+ msg="Squid response different from apache.")
118+
119+
120+test_web_proxy()
121
122=== added file 'tests/14-listening-port.py'
123--- tests/14-listening-port.py 1970-01-01 00:00:00 +0000
124+++ tests/14-listening-port.py 2015-03-05 18:48:27 +0000
125@@ -0,0 +1,50 @@
126+#!/usr/bin/python3
127+import amulet
128+import requests
129+
130+seconds = 20000
131+PORT = 9999
132+
133+d = amulet.Deployment(series='trusty')
134+
135+d.add('apache2')
136+d.add('squid-reverseproxy')
137+
138+d.configure('squid-reverseproxy', {
139+ 'port': PORT
140+})
141+
142+d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
143+
144+d.expose('apache2')
145+d.expose('squid-reverseproxy')
146+
147+try:
148+ d.setup(timeout=seconds)
149+except amulet.helpers.TimeoutError:
150+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
151+except:
152+ raise
153+
154+
155+##
156+# Set relationship aliases
157+##
158+squid_unit = d.sentry.unit['squid-reverseproxy/0']
159+apache_unit = d.sentry.unit['apache2/0']
160+
161+
162+def test_web_proxy():
163+ squid_request = requests.get(
164+ 'http://%s:%s/' % (squid_unit.info['public-address'], PORT))
165+ apache_request = requests.get(
166+ 'http://%s/' % apache_unit.info['public-address'])
167+ if not squid_request.ok or not apache_request.ok:
168+ amulet.raise_status(amulet.FAIL,
169+ msg="Error connecting.")
170+ if squid_request.text != apache_request.text:
171+ amulet.raise_status(amulet.FAIL,
172+ msg="Squid response different from apache.")
173+
174+
175+test_web_proxy()
176
177=== added file 'tests/15-port-options.py'
178--- tests/15-port-options.py 1970-01-01 00:00:00 +0000
179+++ tests/15-port-options.py 2015-03-05 18:48:27 +0000
180@@ -0,0 +1,71 @@
181+#!/usr/bin/python3
182+import sys
183+import time
184+import json
185+
186+import amulet
187+import requests
188+
189+seconds = 20000
190+
191+d = amulet.Deployment(series='trusty')
192+
193+d.add('kibana')
194+d.add('elasticsearch')
195+d.add('logstash-indexer', charm='cs:precise/logstash-indexer')
196+
197+d.add_unit('elasticsearch', 2)
198+
199+d.relate('logstash-indexer:cluster', 'elasticsearch:client')
200+d.relate('kibana:rest', 'elasticsearch:client')
201+
202+d.expose('kibana')
203+
204+try:
205+ d.setup(timeout=seconds)
206+except amulet.helpers.TimeoutError:
207+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
208+except:
209+ raise
210+
211+
212+##
213+# Set relationship aliases
214+##
215+kibana_unit = d.sentry.unit['kibana/0']
216+elasticsearch_unit = d.sentry.unit['elasticsearch/1']
217+
218+
219+def test_web_interface():
220+
221+ elasticsearch_unit.run("""
222+ curl -X POST 'http://127.0.0.1:9200/person/1' -d '{
223+ "info" : {
224+ "height" : 2,
225+ "width" : 20
226+ }
227+ }'
228+ """)
229+
230+ time.sleep(3)
231+
232+ url = 'http://%s/_all/_search' % kibana_unit.info['public-address']
233+ r = requests.get(url,
234+ data=json.load(open('11-scale-elastic-query.json')))
235+ if not r.ok:
236+ amulet.raise_status(amulet.FAIL,
237+ msg="Error connecting.")
238+ try:
239+ result = r.json()
240+ if result['hits']['total'] != 1:
241+ amulet.raise_status(amulet.FAIL,
242+ msg="Error inserting value in elasticsearch.")
243+ except ValueError:
244+ exc_type, value, traceback = sys.exc_info()
245+ exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)
246+ amulet.raise_status(amulet.FAIL,
247+ msg="Value returned not a valid json." + r.text +
248+ exc_text)
249+
250+
251+test_web_interface()
252
253=== added file 'tests/16-https.py'
254--- tests/16-https.py 1970-01-01 00:00:00 +0000
255+++ tests/16-https.py 2015-03-05 18:48:27 +0000
256@@ -0,0 +1,59 @@
257+#!/usr/bin/python3
258+from base64 import b64encode
259+
260+import amulet
261+import requests
262+
263+seconds = 20000
264+
265+d = amulet.Deployment(series='trusty')
266+
267+d.add('apache2')
268+d.add('squid-reverseproxy')
269+
270+d.configure('squid-reverseproxy', {
271+ 'enable_https': True,
272+ 'ssl_key': b64encode(open('cert.key').read()),
273+ 'ssl_cert': b64encode(open('cert.cert').read())
274+})
275+
276+d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
277+
278+d.expose('apache2')
279+d.expose('squid-reverseproxy')
280+
281+try:
282+ d.setup(timeout=seconds)
283+except amulet.helpers.TimeoutError:
284+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
285+except:
286+ raise
287+
288+
289+##
290+# Set relationship aliases
291+##
292+squid_unit = d.sentry.unit['squid-reverseproxy/0']
293+apache_unit = d.sentry.unit['apache2/0']
294+
295+
296+def test_web_proxy():
297+ try:
298+ squid_request = requests.get(
299+ 'https://%s/' % squid_unit.info['public-address'],
300+ cert=('cert.cert', 'cert.key')
301+ )
302+ apache_request = requests.get(
303+ 'http://%s/' % apache_unit.info['public-address'])
304+ if not squid_request.ok or not apache_request.ok:
305+ amulet.raise_status(amulet.FAIL,
306+ msg="Error connecting.")
307+ if squid_request.text != apache_request.text:
308+ amulet.raise_status(amulet.FAIL,
309+ msg="Squid response different from apache.")
310+ except requests.exceptions.SSLError:
311+ amulet.raise_status(amulet.FAIL,
312+ msg="SSL wrongly configured.")
313+
314+
315+test_web_proxy()
316
317=== added file 'tests/17-via.py'
318--- tests/17-via.py 1970-01-01 00:00:00 +0000
319+++ tests/17-via.py 2015-03-05 18:48:27 +0000
320@@ -0,0 +1,52 @@
321+#!/usr/bin/python3
322+import amulet
323+import requests
324+
325+seconds = 20000
326+
327+d = amulet.Deployment(series='trusty')
328+
329+d.add('apache2')
330+d.add('squid-reverseproxy')
331+
332+d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
333+
334+d.expose('apache2')
335+d.expose('squid-reverseproxy')
336+
337+try:
338+ d.setup(timeout=seconds)
339+except amulet.helpers.TimeoutError:
340+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
341+except:
342+ raise
343+
344+
345+##
346+# Set relationship aliases
347+##
348+squid_unit = d.sentry.unit['squid-reverseproxy/0']
349+apache_unit = d.sentry.unit['apache2/0']
350+
351+
352+def test_via_header():
353+ url = 'http://%s/'
354+ squid_request = requests.get(url % squid_unit.info['public-address'])
355+ # check headers
356+ if 'Via' not in squid_request.headers:
357+ amulet.raise_status(amulet.FAIL,
358+ msg="Environment wasn't stood up in time")
359+
360+ # config via off
361+ d.configure('squid-reverseproxy', {
362+ 'via': 'off'
363+ })
364+ d.sentry.wait()
365+
366+ # check headers again
367+ if 'Via' in squid_request.headers:
368+ amulet.raise_status(amulet.FAIL,
369+ msg="Environment wasn't stood up in time")
370+
371+
372+test_via_header()
373
374=== added file 'tests/19-snmp.py'
375--- tests/19-snmp.py 1970-01-01 00:00:00 +0000
376+++ tests/19-snmp.py 2015-03-05 18:48:27 +0000
377@@ -0,0 +1,45 @@
378+#!/usr/bin/python3
379+import subprocess
380+
381+import amulet
382+
383+seconds = 20000
384+
385+d = amulet.Deployment(series='trusty')
386+
387+d.add('apache2')
388+d.add('squid-reverseproxy')
389+
390+d.configure('squid-reverseproxy', {
391+ 'snmp_community': 'juju',
392+ 'snmp_allowed_ips': '0.0.0.0/0'
393+})
394+
395+d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
396+
397+d.expose('squid-reverseproxy')
398+
399+try:
400+ d.setup(timeout=seconds)
401+except amulet.helpers.TimeoutError:
402+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
403+except:
404+ raise
405+
406+
407+##
408+# Set relationship aliases
409+##
410+squid_unit = d.sentry.unit['squid-reverseproxy/0']
411+
412+
413+def test_snmp():
414+ try:
415+ subprocess.check_output(
416+ "squidclient -h %s mgr:info" % squid_unit.info['public-address'])
417+ except subprocess.CalledProcessError:
418+ amulet.raise_status(amulet.FAIL,
419+ msg="Wasn't able to connect via SNMP.")
420+
421+
422+test_snmp()
423
424=== added file 'tests/cert.cert'
425--- tests/cert.cert 1970-01-01 00:00:00 +0000
426+++ tests/cert.cert 2015-03-05 18:48:27 +0000
427@@ -0,0 +1,21 @@
428+-----BEGIN CERTIFICATE-----
429+MIIDXTCCAkWgAwIBAgIJAP8/lbMbA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FnjrAC4ojs+usC3+3k6ZYZif2xEDnyHjPg4CxH16vJguerR2HH1qPQ+Up
446+yBNAMRkkPLv3d90wGVrknvEGn/Pjde+mZN/9tXs3zMZVOOl+KU11tEoyOFbTxU64
447+SA==
448+-----END CERTIFICATE-----
449
450=== added file 'tests/cert.key'
451--- tests/cert.key 1970-01-01 00:00:00 +0000
452+++ tests/cert.key 2015-03-05 18:48:27 +0000
453@@ -0,0 +1,28 @@
454+-----BEGIN PRIVATE KEY-----
455+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDvziF2X4cTlR3x
456+Id9O1pCPYf1AWkF0VvyI1u0nW/UYbfXCJXR+BXoaSTV/LFppmTgGonLDn2bacVoX
457+0io9xcCsnxlGvPb1k2sv6buYskMoFIDiuWlHuJ4l7D+rPKPhwZZaoa1BlBbspoX6
458+pWscJlXdZa3IaF767xMbvYBbTa625zCUea0fPlbqMqRVNV8a/SQy+hYJux1LRhab
459+ondmDbnM0TOD7fx85O5k8nbWUzzPkp+8nkR7+GYz2o4Y8mHMChdFj05dMKcRKskW
460+DcZjyGTOiDt6hBwOHTm7vKaSYue5gkAw47JmTLiU92QvZTvyj1ehel/QWGOw4ln9
461+HF7Hyr/FAgMBAAECggEBAJ4a8LMD7qH5mcEmzP1EuBDg0UFBgJA83ck2sytVFLZj
462+oTm8yh5gbA2yoOPVEVM4Itk096eEjCKPw4+bECCkJhFp4BdkdQqahHwVhYr6VQ6y
463+3fsdtY0E6rgkGCJFG+O3Z/MfT4TCJ48lh4Ym1AS+PbR32mkcbyrQv291tI/+GqgZ
464+ZGw1EWcILqVaH1VCfV0ApbIdiWK5jT571mqTcp6I55RQC3gzFGU6jNnGY7A8Rp4X
465+Nouhwta+eAU6bTNRzFi9skB9YGrsCYz9pWK6BMKbRMZHUiNcshAg8qH+HMVj9U+z
466+ufLid4XmTdA4JsAWkUT39v3F4hjudGDaE7Q9OGY/BKECgYEA/6h98O/aQv8C+NWT
467+Nr0G/PdXtI5Ka1Je+HCPn4vHQf/g0Y0xwIgSgKXexhSgJm/aqvZvP4KsptjGDTdW
468+oQ9kxDfc27zXlb5zaJAHSzm7KQud9K97lm1a4kImfEtyVNx99dNHp6K7jxYfa6XP
469+fch9A0U5jD8227yLGzbOMkmc5u0CgYEA8CA2Z1lPgloObCM9KWUf2l+SdUr1dji3
470+mLNFbtZrzgDmmKvEVGlg9uatFv7Omj/bSYihVujILeN8z583YPSD8FdTTb5Ob5vF
471+xBFoP1tSPfNFm+7Ls9dzLWj1HZttbS2rW2VBf51M7FZ0iXQ39vYQMmbOTAdicjJ5
472+7NEGCXIRCTkCgYAjqKewVHQYBiOu+3MmHmV8IS+9gl9E6t9OPbz6nu9y+DKuZ8g5
473+t4EFKp2Q+U2BLvbMA8VukVZtiyzMqRxPKKuAZt5KU+OqAj9spTIvPuUpC3LDrzpI
474+uAYGKv3dNlTDG2ICSK7k5eDNS2OkiyMOw0kUjLJDKooHShwI9rL59qSI3QKBgC9Y
475+iqGSEIVJMHLN9+9DiyZJld0erItk335ySoxyJst1jgIoTAvAw2erUBGqqB3t3VUA
476+ZZ93QpEZu7BMWmT5kVJARaKclWaYNkRUklN7tBmW7/CxAuUw4/reKQZvcQIH8TOS
477+IXoCD/rBiTTY/3foSIVHlAGVqymNHlE9XY1bOlSxAoGBAMB5I+aa7r8e9R3b7hT4
478+dBGg/mlF0GVQFYJWrye3UWmxzM92pRH1FpIJgm1V0jGO3EAYWnxVcvaPsWmh2S01
479+ZlYNnSkRMtAynTHDQktW78/xgNWthqMG3HRLMfZM+WkQfWz3lygLViB2l+JSsSS8
480+MVvnClZPQ386RtYBxVlPQL2A
481+-----END PRIVATE KEY-----

Subscribers

People subscribed via source and target branches

to all changes: