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
=== added file 'tests/00-setup'
--- tests/00-setup 1970-01-01 00:00:00 +0000
+++ tests/00-setup 2015-03-05 18:48:27 +0000
@@ -0,0 +1,16 @@
1#!/bin/bash
2
3# This script sets up the requirements for amulet tests.
4
5set -x
6
7# Check if amulet is installed before adding the stable repository and updating apt-get.
8dpkg -s amulet
9if [ $? -ne 0 ]; then
10 sudo add-apt-repository -y ppa:juju/stable
11 sudo apt-get update -qq
12 sudo apt-get install -y amulet
13fi
14
15# Install any additional python packages and other required software.
16sudo apt-get install -y python3-requests squidclient
017
=== added file 'tests/12-nagios.py'
--- tests/12-nagios.py 1970-01-01 00:00:00 +0000
+++ tests/12-nagios.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,46 @@
1#!/usr/bin/python3
2import amulet
3import requests
4
5seconds = 20000
6
7d = amulet.Deployment(series='trusty')
8
9d.add('squid-reverseproxy')
10d.add('nagios')
11d.add('nrpe-external-master')
12
13d.relate('nagios:monitors', 'squid-reverseproxy:monitors')
14d.relate('nrpe-external-master:general-info', 'squid-reverseproxy:juju-info')
15d.relate('nrpe-external-master:monitors', 'nagios:monitors')
16
17d.expose('nagios')
18
19try:
20 d.setup(timeout=seconds)
21except amulet.helpers.TimeoutError:
22 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
23except:
24 raise
25
26
27##
28# Set relationship aliases
29##
30squid_unit = d.sentry.unit['squid/0']
31nagios_unit = d.sentry.unit['nagios/0']
32
33
34def test_hosts_being_monitored():
35 nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip()
36 host_url = ("http://%s/cgi-bin/nagios3/status.cgi?"
37 "hostgroup=all&style=hostdetail")
38 r = requests.get(host_url % nagios_unit.info['public-address'],
39 auth=('nagiosadmin', nagpwd))
40 if not r.text.find('squid'):
41 amulet.raise_status(amulet.ERROR,
42 msg='Nagios is not monitoring the' +
43 ' host it supposed to.')
44
45
46test_hosts_being_monitored()
047
=== added file 'tests/13-squid-apache.py'
--- tests/13-squid-apache.py 1970-01-01 00:00:00 +0000
+++ tests/13-squid-apache.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,44 @@
1#!/usr/bin/python3
2import amulet
3import requests
4
5seconds = 20000
6
7d = amulet.Deployment(series='trusty')
8
9d.add('apache2')
10d.add('squid-reverseproxy')
11
12d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
13
14d.expose('apache2')
15d.expose('squid-reverseproxy')
16
17try:
18 d.setup(timeout=seconds)
19except amulet.helpers.TimeoutError:
20 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
21except:
22 raise
23
24
25##
26# Set relationship aliases
27##
28squid_unit = d.sentry.unit['squid-reverseproxy/0']
29apache_unit = d.sentry.unit['apache2/0']
30
31
32def test_web_proxy():
33 url = 'http://%s/'
34 squid_request = requests.get(url % squid_unit.info['public-address'])
35 apache_request = requests.get(url % apache_unit.info['public-address'])
36 if not squid_request.ok or not apache_request.ok:
37 amulet.raise_status(amulet.FAIL,
38 msg="Error connecting.")
39 if squid_request.text != apache_request.text:
40 amulet.raise_status(amulet.FAIL,
41 msg="Squid response different from apache.")
42
43
44test_web_proxy()
045
=== added file 'tests/14-listening-port.py'
--- tests/14-listening-port.py 1970-01-01 00:00:00 +0000
+++ tests/14-listening-port.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,50 @@
1#!/usr/bin/python3
2import amulet
3import requests
4
5seconds = 20000
6PORT = 9999
7
8d = amulet.Deployment(series='trusty')
9
10d.add('apache2')
11d.add('squid-reverseproxy')
12
13d.configure('squid-reverseproxy', {
14 'port': PORT
15})
16
17d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
18
19d.expose('apache2')
20d.expose('squid-reverseproxy')
21
22try:
23 d.setup(timeout=seconds)
24except amulet.helpers.TimeoutError:
25 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
26except:
27 raise
28
29
30##
31# Set relationship aliases
32##
33squid_unit = d.sentry.unit['squid-reverseproxy/0']
34apache_unit = d.sentry.unit['apache2/0']
35
36
37def test_web_proxy():
38 squid_request = requests.get(
39 'http://%s:%s/' % (squid_unit.info['public-address'], PORT))
40 apache_request = requests.get(
41 'http://%s/' % apache_unit.info['public-address'])
42 if not squid_request.ok or not apache_request.ok:
43 amulet.raise_status(amulet.FAIL,
44 msg="Error connecting.")
45 if squid_request.text != apache_request.text:
46 amulet.raise_status(amulet.FAIL,
47 msg="Squid response different from apache.")
48
49
50test_web_proxy()
051
=== added file 'tests/15-port-options.py'
--- tests/15-port-options.py 1970-01-01 00:00:00 +0000
+++ tests/15-port-options.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,71 @@
1#!/usr/bin/python3
2import sys
3import time
4import json
5
6import amulet
7import requests
8
9seconds = 20000
10
11d = amulet.Deployment(series='trusty')
12
13d.add('kibana')
14d.add('elasticsearch')
15d.add('logstash-indexer', charm='cs:precise/logstash-indexer')
16
17d.add_unit('elasticsearch', 2)
18
19d.relate('logstash-indexer:cluster', 'elasticsearch:client')
20d.relate('kibana:rest', 'elasticsearch:client')
21
22d.expose('kibana')
23
24try:
25 d.setup(timeout=seconds)
26except amulet.helpers.TimeoutError:
27 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
28except:
29 raise
30
31
32##
33# Set relationship aliases
34##
35kibana_unit = d.sentry.unit['kibana/0']
36elasticsearch_unit = d.sentry.unit['elasticsearch/1']
37
38
39def test_web_interface():
40
41 elasticsearch_unit.run("""
42 curl -X POST 'http://127.0.0.1:9200/person/1' -d '{
43 "info" : {
44 "height" : 2,
45 "width" : 20
46 }
47 }'
48 """)
49
50 time.sleep(3)
51
52 url = 'http://%s/_all/_search' % kibana_unit.info['public-address']
53 r = requests.get(url,
54 data=json.load(open('11-scale-elastic-query.json')))
55 if not r.ok:
56 amulet.raise_status(amulet.FAIL,
57 msg="Error connecting.")
58 try:
59 result = r.json()
60 if result['hits']['total'] != 1:
61 amulet.raise_status(amulet.FAIL,
62 msg="Error inserting value in elasticsearch.")
63 except ValueError:
64 exc_type, value, traceback = sys.exc_info()
65 exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)
66 amulet.raise_status(amulet.FAIL,
67 msg="Value returned not a valid json." + r.text +
68 exc_text)
69
70
71test_web_interface()
072
=== added file 'tests/16-https.py'
--- tests/16-https.py 1970-01-01 00:00:00 +0000
+++ tests/16-https.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,59 @@
1#!/usr/bin/python3
2from base64 import b64encode
3
4import amulet
5import requests
6
7seconds = 20000
8
9d = amulet.Deployment(series='trusty')
10
11d.add('apache2')
12d.add('squid-reverseproxy')
13
14d.configure('squid-reverseproxy', {
15 'enable_https': True,
16 'ssl_key': b64encode(open('cert.key').read()),
17 'ssl_cert': b64encode(open('cert.cert').read())
18})
19
20d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
21
22d.expose('apache2')
23d.expose('squid-reverseproxy')
24
25try:
26 d.setup(timeout=seconds)
27except amulet.helpers.TimeoutError:
28 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
29except:
30 raise
31
32
33##
34# Set relationship aliases
35##
36squid_unit = d.sentry.unit['squid-reverseproxy/0']
37apache_unit = d.sentry.unit['apache2/0']
38
39
40def test_web_proxy():
41 try:
42 squid_request = requests.get(
43 'https://%s/' % squid_unit.info['public-address'],
44 cert=('cert.cert', 'cert.key')
45 )
46 apache_request = requests.get(
47 'http://%s/' % apache_unit.info['public-address'])
48 if not squid_request.ok or not apache_request.ok:
49 amulet.raise_status(amulet.FAIL,
50 msg="Error connecting.")
51 if squid_request.text != apache_request.text:
52 amulet.raise_status(amulet.FAIL,
53 msg="Squid response different from apache.")
54 except requests.exceptions.SSLError:
55 amulet.raise_status(amulet.FAIL,
56 msg="SSL wrongly configured.")
57
58
59test_web_proxy()
060
=== added file 'tests/17-via.py'
--- tests/17-via.py 1970-01-01 00:00:00 +0000
+++ tests/17-via.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,52 @@
1#!/usr/bin/python3
2import amulet
3import requests
4
5seconds = 20000
6
7d = amulet.Deployment(series='trusty')
8
9d.add('apache2')
10d.add('squid-reverseproxy')
11
12d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
13
14d.expose('apache2')
15d.expose('squid-reverseproxy')
16
17try:
18 d.setup(timeout=seconds)
19except amulet.helpers.TimeoutError:
20 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
21except:
22 raise
23
24
25##
26# Set relationship aliases
27##
28squid_unit = d.sentry.unit['squid-reverseproxy/0']
29apache_unit = d.sentry.unit['apache2/0']
30
31
32def test_via_header():
33 url = 'http://%s/'
34 squid_request = requests.get(url % squid_unit.info['public-address'])
35 # check headers
36 if 'Via' not in squid_request.headers:
37 amulet.raise_status(amulet.FAIL,
38 msg="Environment wasn't stood up in time")
39
40 # config via off
41 d.configure('squid-reverseproxy', {
42 'via': 'off'
43 })
44 d.sentry.wait()
45
46 # check headers again
47 if 'Via' in squid_request.headers:
48 amulet.raise_status(amulet.FAIL,
49 msg="Environment wasn't stood up in time")
50
51
52test_via_header()
053
=== added file 'tests/19-snmp.py'
--- tests/19-snmp.py 1970-01-01 00:00:00 +0000
+++ tests/19-snmp.py 2015-03-05 18:48:27 +0000
@@ -0,0 +1,45 @@
1#!/usr/bin/python3
2import subprocess
3
4import amulet
5
6seconds = 20000
7
8d = amulet.Deployment(series='trusty')
9
10d.add('apache2')
11d.add('squid-reverseproxy')
12
13d.configure('squid-reverseproxy', {
14 'snmp_community': 'juju',
15 'snmp_allowed_ips': '0.0.0.0/0'
16})
17
18d.relate('apache2:website-cache', 'squid-reverseproxy:cached-website')
19
20d.expose('squid-reverseproxy')
21
22try:
23 d.setup(timeout=seconds)
24except amulet.helpers.TimeoutError:
25 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
26except:
27 raise
28
29
30##
31# Set relationship aliases
32##
33squid_unit = d.sentry.unit['squid-reverseproxy/0']
34
35
36def test_snmp():
37 try:
38 subprocess.check_output(
39 "squidclient -h %s mgr:info" % squid_unit.info['public-address'])
40 except subprocess.CalledProcessError:
41 amulet.raise_status(amulet.FAIL,
42 msg="Wasn't able to connect via SNMP.")
43
44
45test_snmp()
046
=== added file 'tests/cert.cert'
--- tests/cert.cert 1970-01-01 00:00:00 +0000
+++ tests/cert.cert 2015-03-05 18:48:27 +0000
@@ -0,0 +1,21 @@
1-----BEGIN CERTIFICATE-----
2MIIDXTCCAkWgAwIBAgIJAP8/lbMbA1l3MA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
3BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
4aWRnaXRzIFB0eSBMdGQwHhcNMTUwMjI2MTkyMzQ0WhcNMTUwMzI4MTkyMzQ0WjBF
5MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
6ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
7CgKCAQEA784hdl+HE5Ud8SHfTtaQj2H9QFpBdFb8iNbtJ1v1GG31wiV0fgV6Gkk1
8fyxaaZk4BqJyw59m2nFaF9IqPcXArJ8ZRrz29ZNrL+m7mLJDKBSA4rlpR7ieJew/
9qzyj4cGWWqGtQZQW7KaF+qVrHCZV3WWtyGhe+u8TG72AW02utucwlHmtHz5W6jKk
10VTVfGv0kMvoWCbsdS0YWm6J3Zg25zNEzg+38fOTuZPJ21lM8z5KfvJ5Ee/hmM9qO
11GPJhzAoXRY9OXTCnESrJFg3GY8hkzog7eoQcDh05u7ymkmLnuYJAMOOyZky4lPdk
12L2U78o9XoXpf0FhjsOJZ/Rxex8q/xQIDAQABo1AwTjAdBgNVHQ4EFgQUR/QwCSZo
13j+OSEop1WSLQ0qZe0cEwHwYDVR0jBBgwFoAUR/QwCSZoj+OSEop1WSLQ0qZe0cEw
14DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAPbp7oHahP3h4Yz9oZwYJ
15gMIZUizqs8ifOTTBmpYFCeaG53sGpTsKBRR9NWPkvvMTwLQFlia/qDBrule51+1t
16HOFIMUg9SE8pzwhmhX4+ASav6ylew8ZTBdmsyUq+04srLW3IK4FEfYFJkUl739QG
177Xe1WtWp4BQ0wnhXTq+XayENup07M4eEtM2RRRI0tsyEgzsp2IXTskIZaKGkm/mj
18FbSOITNFnjrAC4ojs+usC3+3k6ZYZif2xEDnyHjPg4CxH16vJguerR2HH1qPQ+Up
19yBNAMRkkPLv3d90wGVrknvEGn/Pjde+mZN/9tXs3zMZVOOl+KU11tEoyOFbTxU64
20SA==
21-----END CERTIFICATE-----
022
=== added file 'tests/cert.key'
--- tests/cert.key 1970-01-01 00:00:00 +0000
+++ tests/cert.key 2015-03-05 18:48:27 +0000
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDvziF2X4cTlR3x
3Id9O1pCPYf1AWkF0VvyI1u0nW/UYbfXCJXR+BXoaSTV/LFppmTgGonLDn2bacVoX
40io9xcCsnxlGvPb1k2sv6buYskMoFIDiuWlHuJ4l7D+rPKPhwZZaoa1BlBbspoX6
5pWscJlXdZa3IaF767xMb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Ow0kUjLJDKooHShwI9rL59qSI3QKBgC9Y
22iqGSEIVJMHLN9+9DiyZJld0erItk335ySoxyJst1jgIoTAvAw2erUBGqqB3t3VUA
23ZZ93QpEZu7BMWmT5kVJARaKclWaYNkRUklN7tBmW7/CxAuUw4/reKQZvcQIH8TOS
24IXoCD/rBiTTY/3foSIVHlAGVqymNHlE9XY1bOlSxAoGBAMB5I+aa7r8e9R3b7hT4
25dBGg/mlF0GVQFYJWrye3UWmxzM92pRH1FpIJgm1V0jGO3EAYWnxVcvaPsWmh2S01
26ZlYNnSkRMtAynTHDQktW78/xgNWthqMG3HRLMfZM+WkQfWz3lygLViB2l+JSsSS8
27MVvnClZPQ386RtYBxVlPQL2A
28-----END PRIVATE KEY-----

Subscribers

People subscribed via source and target branches

to all changes: