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

Proposed by nicopace
Status: Merged
Merged at revision: 15
Proposed branch: lp:~nicopace/charms/trusty/varnish/all-tests
Merge into: lp:charms/trusty/varnish
Diff against target: 120 lines (+99/-1)
3 files modified
tests/10-deploy (+1/-1)
tests/11-varnish-wordpress (+55/-0)
tests/12-change-port (+43/-0)
To merge this branch: bzr merge lp:~nicopace/charms/trusty/varnish/all-tests
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
charmers Pending
Review via email: mp+251312@code.launchpad.net

Description of the change

Merge all varnish tests into one:
* Varnish wordpress test
* change port test

To post a comment you must log in.
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-11071-results

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

Wordpress test corrected, and deployment tests extended so it works on slower platforms.

19. By nicopace

Corrects time in tests, and decode on string.

Revision history for this message
nicopace (nicopace) wrote :

The failing test is due to a charm error.

Revision history for this message
nicopace (nicopace) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/10-deploy'
2--- tests/10-deploy 2014-10-28 20:52:26 +0000
3+++ tests/10-deploy 2015-03-12 17:10:52 +0000
4@@ -17,7 +17,7 @@
5 cls.deployment.expose('varnish')
6
7 try:
8- cls.deployment.setup(timeout=900)
9+ cls.deployment.setup(timeout=5000)
10 cls.deployment.sentry.wait()
11 except amulet.helpers.TimeoutError:
12 amulet.raise_status(
13
14=== added file 'tests/11-varnish-wordpress'
15--- tests/11-varnish-wordpress 1970-01-01 00:00:00 +0000
16+++ tests/11-varnish-wordpress 2015-03-12 17:10:52 +0000
17@@ -0,0 +1,55 @@
18+#!/usr/bin/env python3
19+import subprocess
20+
21+import requests
22+import amulet
23+import unittest
24+
25+
26+class TestDeployment(unittest.TestCase):
27+ @classmethod
28+ def setUpClass(cls):
29+ cls.deployment = amulet.Deployment(series='trusty')
30+
31+ cls.deployment.add('varnish')
32+ cls.deployment.add('wordpress')
33+ cls.deployment.relate('varnish:reverseproxy', 'wordpress:website')
34+
35+ cls.deployment.expose('varnish')
36+ cls.deployment.expose('wordpress')
37+
38+ try:
39+ cls.deployment.setup(timeout=5000)
40+ cls.deployment.sentry.wait()
41+ except amulet.helpers.TimeoutError:
42+ amulet.raise_status(
43+ amulet.SKIP, msg="Environment wasn't stood up in time")
44+ except:
45+ raise
46+
47+ cls.varnish = cls.deployment.sentry['varnish/0']
48+ cls.wordpress = cls.deployment.sentry['wordpress/0']
49+
50+ def test_deployed(self):
51+ result_header_varnish = subprocess.check_output([
52+ 'curl', '-o -', '-I',
53+ ' H "Host: %s"' % self.wordpress.info['public-address'],
54+ 'http://%s/' % self.varnish.info['public-address']])
55+
56+ if 'varnish' not in result_header_varnish.decode('utf-8'):
57+ amulet.raise_status(
58+ amulet.FAIL, msg="Varnish is not in the middle.")
59+
60+ result_varnish = requests.get(
61+ 'http://%s/' % self.varnish.info['public-address'])
62+ result_wordpress = requests.get(
63+ 'http://%s/' % self.wordpress.info['public-address'])
64+
65+ if result_varnish.content != result_wordpress.content:
66+ amulet.raise_status(
67+ amulet.FAIL,
68+ msg="Varnish is returning differnt content than wordpress.")
69+
70+
71+if __name__ == '__main__':
72+ unittest.main()
73
74=== added file 'tests/12-change-port'
75--- tests/12-change-port 1970-01-01 00:00:00 +0000
76+++ tests/12-change-port 2015-03-12 17:10:52 +0000
77@@ -0,0 +1,43 @@
78+#!/usr/bin/env python3
79+
80+import amulet
81+import unittest
82+
83+
84+class TestDeployment(unittest.TestCase):
85+ @classmethod
86+ def setUpClass(cls):
87+ cls.deployment = amulet.Deployment(series='trusty')
88+
89+ cls.deployment.add('varnish')
90+ cls.deployment.add('wordpress')
91+ cls.deployment.relate('varnish:reverseproxy', 'wordpress:website')
92+
93+ cls.deployment.configure('varnish', {
94+ 'port': 8080
95+ })
96+
97+ cls.deployment.expose('varnish')
98+ cls.deployment.expose('wordpress')
99+
100+ try:
101+ cls.deployment.setup(timeout=5000)
102+ cls.deployment.sentry.wait()
103+ except amulet.helpers.TimeoutError:
104+ amulet.raise_status(
105+ amulet.SKIP, msg="Environment wasn't stood up in time")
106+ except:
107+ raise
108+
109+ cls.varnish = cls.deployment.sentry['varnish/0']
110+ cls.wordpress = cls.deployment.sentry['wordpress/0']
111+
112+ def test_deployed(self):
113+ result, code = self.varnish.run('sudo netstat -plnt | grep 8080')
114+ if result == '':
115+ amulet.raise_status(amulet.FAIL,
116+ msg='change port failed.')
117+
118+
119+if __name__ == '__main__':
120+ unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: