Merge lp:~axino/mojo/mojo-specs into lp:mojo/mojo-specs

Proposed by Junien Fridrick
Status: Merged
Approved by: Tom Haddon
Approved revision: 105
Merged at revision: 104
Proposed branch: lp:~axino/mojo/mojo-specs
Merge into: lp:mojo/mojo-specs
Diff against target: 75 lines (+44/-0)
3 files modified
charm-testing/squid-reverseproxy/collect (+1/-0)
charm-testing/squid-reverseproxy/deploy (+5/-0)
charm-testing/squid-reverseproxy/post-deploy (+38/-0)
To merge this branch: bzr merge lp:~axino/mojo/mojo-specs
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Review via email: mp+343702@code.launchpad.net

Commit message

squid-reverseproxy : add test

To post a comment you must log in.
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM

review: Approve
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

Change successfully merged at revision 104

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charm-testing/squid-reverseproxy/collect'
--- charm-testing/squid-reverseproxy/collect 2018-04-13 11:24:35 +0000
+++ charm-testing/squid-reverseproxy/collect 2018-04-20 15:32:56 +0000
@@ -1,5 +1,6 @@
1squid-reverseproxy lp:~canonical-sysadmins/canonical-is-charms/squid-reverseproxy1squid-reverseproxy lp:~canonical-sysadmins/canonical-is-charms/squid-reverseproxy
2nrpe cs:{{ series }}/nrpe2nrpe cs:{{ series }}/nrpe
3apache2 cs:apache2
34
4squid-reverseproxy/exec.d @5squid-reverseproxy/exec.d @
5squid-reverseproxy/exec.d/basenode lp:~canonical-sysadmins/basenode/trunk6squid-reverseproxy/exec.d/basenode lp:~canonical-sysadmins/basenode/trunk
67
=== modified file 'charm-testing/squid-reverseproxy/deploy'
--- charm-testing/squid-reverseproxy/deploy 2018-04-13 11:24:35 +0000
+++ charm-testing/squid-reverseproxy/deploy 2018-04-20 15:32:56 +0000
@@ -3,8 +3,11 @@
3 services:3 services:
4 squid-reverseproxy:4 squid-reverseproxy:
5 charm: squid-reverseproxy5 charm: squid-reverseproxy
6 expose: True
6 options:7 options:
7 cache_dir: /var/spool/squid8 cache_dir: /var/spool/squid
9 apache2:
10 charm: apache2
8 nrpe:11 nrpe:
9 charm: nrpe12 charm: nrpe
10 {% if series == "xenial" or series == "bionic" %}options:13 {% if series == "xenial" or series == "bionic" %}options:
@@ -12,3 +15,5 @@
12 swap: '-w 90% -c 75% -n ok'{% endif %}15 swap: '-w 90% -c 75% -n ok'{% endif %}
13 relations:16 relations:
14 - ['squid-reverseproxy', 'nrpe:nrpe-external-master']17 - ['squid-reverseproxy', 'nrpe:nrpe-external-master']
18 - ['apache2', 'nrpe:nrpe-external-master']
19 - ['apache2:website', 'squid-reverseproxy']
1520
=== added file 'charm-testing/squid-reverseproxy/post-deploy'
--- charm-testing/squid-reverseproxy/post-deploy 1970-01-01 00:00:00 +0000
+++ charm-testing/squid-reverseproxy/post-deploy 2018-04-20 15:32:56 +0000
@@ -0,0 +1,38 @@
1#!/usr/bin/python3
2
3import subprocess
4import sys
5from time import sleep
6import urllib.request
7import yaml
8
9relation_set = ("relation-set -r website:2 services=\"["
10 "{{'url': 'http://{apache2}:80',"
11 "'proxy': [{{'proxy_target': 'http://{apache2}:80',"
12 "'match': 'http://{apache2}:3128'}}]}}]\"")
13
14status = yaml.safe_load(subprocess.check_output(['juju', 'status', '--format', 'yaml']))
15squid_ip = status['applications']['squid-reverseproxy']['units']['squid-reverseproxy/0']['public-address']
16apache2_ip = status['applications']['apache2']['units']['apache2/0']['public-address']
17print("Sending relation data...")
18subprocess.check_call(['juju', 'run', '--unit', 'apache2/0',
19 relation_set.format(apache2=apache2_ip, squid=squid_ip)])
20
21print("Sleeping 60s to wait for hook completion...")
22sleep(60)
23
24print("Testing the cache...")
25req = urllib.request.Request('http://{}:3128'.format(squid_ip), headers={'Host': apache2_ip})
26
27# First request to warm the cache
28urllib.request.urlopen(req)
29
30# Second to hit the cache
31res = urllib.request.urlopen(req)
32
33if res.getcode() == 200 and res.info()['X-Cache'][0:3] == "HIT":
34 print("SUCCESS : cache hit")
35 sys.exit(0)
36else:
37 print("ERROR : not 200 or no cache hit")
38 sys.exit(1)

Subscribers

People subscribed via source and target branches

to all changes: