Merge lp:~jose/charms/trusty/python-moinmoin/refactor-tests into lp:charms/trusty/python-moinmoin

Proposed by José Antonio Rey
Status: Merged
Merged at revision: 12
Proposed branch: lp:~jose/charms/trusty/python-moinmoin/refactor-tests
Merge into: lp:charms/trusty/python-moinmoin
Diff against target: 366 lines (+55/-244)
9 files modified
README.md (+3/-3)
hooks/hooks.py (+1/-1)
tests/00-setup (+3/-11)
tests/10-bundle-test.py (+0/-40)
tests/10-deploy (+48/-0)
tests/100-deploy-test (+0/-119)
tests/bundles.yaml (+0/-21)
tests/get-unit-info (+0/-46)
tests/tests.yaml (+0/-3)
To merge this branch: bzr merge lp:~jose/charms/trusty/python-moinmoin/refactor-tests
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Adam Israel (community) Approve
Review Queue (community) automated testing Needs Fixing
Review via email: mp+248331@code.launchpad.net
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-11016-results

review: Needs Fixing (automated testing)
Revision history for this message
Adam Israel (aisrael) wrote :

Hi José,

I had the opportunity to review this merge proposal today. I'm happy to report that all changes look good, and the tests are passing.

LGTM. +1

review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

Thanks adam, I've taken action on this MP based on your review.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2013-09-26 06:15:02 +0000
3+++ README.md 2015-02-03 06:23:50 +0000
4@@ -14,7 +14,7 @@
5 admin_name: "Admin"
6 languages: English French
7 xapian_search: True
8- port: 80
9+ listen_port: 80
10
11 To then deploy the wiki, with pre-seeded configuration:
12
13@@ -48,10 +48,10 @@
14
15 juju set python_moinmoin xapian_search="True"
16
17-# port
18+# listen_port
19 The port moinmoin should listen on. By default it's 8080
20
21- juju set python_moinmoin port=80
22+ juju set python_moinmoin listen_port=80
23
24 # use_openid
25 Setting to say if the wiki is using OpenID authentication or not.
26
27=== modified file 'hooks/hooks.py'
28--- hooks/hooks.py 2013-09-19 06:09:37 +0000
29+++ hooks/hooks.py 2015-02-03 06:23:50 +0000
30@@ -104,7 +104,7 @@
31 shutil.copytree('/usr/share/moin/underlay', basedir + "/underlay")
32 if not os.path.exists(staticdir):
33 shutil.copytree('/usr/share/moin/htdocs', staticdir)
34-
35+ open_port(listen_port)
36
37 @hooks.hook("config-changed")
38 def config_changed():
39
40=== modified file 'tests/00-setup'
41--- tests/00-setup 2014-10-29 21:59:41 +0000
42+++ tests/00-setup 2015-02-03 06:23:50 +0000
43@@ -1,13 +1,5 @@
44 #!/bin/bash
45
46-set -ex
47-
48-# Check if amulet is installed before adding repository and updating apt-get.
49-dpkg -s amulet
50-if [ $? -ne 0 ]; then
51- sudo add-apt-repository -y ppa:juju/stable
52- sudo apt-get update
53- sudo apt-get install -y amulet python3-requests
54-fi
55-
56-# Install any additional python packages or software here.
57+sudo add-apt-repository ppa:juju/stable -y
58+sudo apt-get update
59+sudo apt-get install amulet python3-requests -y
60
61=== removed file 'tests/10-bundle-test.py'
62--- tests/10-bundle-test.py 2014-10-29 21:59:41 +0000
63+++ tests/10-bundle-test.py 1970-01-01 00:00:00 +0000
64@@ -1,40 +0,0 @@
65-#!/usr/bin/env python3
66-
67-# This amulet test deploys the bundles.yaml file in this directory.
68-
69-import os
70-import unittest
71-import yaml
72-import amulet
73-import requests
74-
75-seconds_to_wait = 600
76-
77-
78-class BundleTest(unittest.TestCase):
79- """ Create a class for testing the charm in the unit test framework. """
80- @classmethod
81- def setUpClass(cls):
82- """ Set up an amulet deployment using the bundle. """
83- d = amulet.Deployment()
84- bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml')
85- with open(bundle_path, 'r') as bundle_file:
86- contents = yaml.safe_load(bundle_file)
87- d.load(contents)
88- d.setup(seconds_to_wait)
89- d.sentry.wait(seconds_to_wait)
90- cls.d = d
91-
92- def test_deployed(self):
93- """ Test to see if the bundle deployed successfully. """
94- self.assertTrue(self.d.deployed)
95-
96- def test_response(self):
97- wiki = self.d.sentry.unit['python-moinmoin/0'].info['public-address']
98- pub_address = "http://{}:{}".format(wiki, 8080)
99- response = requests.get(pub_address)
100- response.raise_for_status()
101-
102-
103-if __name__ == '__main__':
104- unittest.main()
105
106=== added file 'tests/10-deploy'
107--- tests/10-deploy 1970-01-01 00:00:00 +0000
108+++ tests/10-deploy 2015-02-03 06:23:50 +0000
109@@ -0,0 +1,48 @@
110+#!/usr/bin/env python3
111+
112+import amulet
113+import requests
114+import unittest
115+
116+
117+class TestDeployment(unittest.TestCase):
118+ @classmethod
119+ def setUpClass(cls):
120+ cls.deployment = amulet.Deployment(series='trusty')
121+
122+ cls.deployment.add('python-moinmoin')
123+ cls.deployment.configure('python-moinmoin', {'wiki_name': 'Amulet Wiki',
124+ 'admin_name': 'citest', 'languages': 'English',
125+ 'xapian_search': 'True', 'listen_port': '8080',
126+ 'use_openid': 'False'})
127+ cls.deployment.expose('python-moinmoin')
128+
129+ try:
130+ cls.deployment.setup(timeout=900)
131+ cls.deployment.sentry.wait()
132+ except amulet.helpers.TimeoutError:
133+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
134+ except:
135+ raise
136+
137+ cls.unit = cls.deployment.sentry.unit['python-moinmoin/0']
138+ cls.address = cls.unit.info['public-address']
139+
140+ def test_exposed(self):
141+ website = 'http://%s:8080/' % self.address
142+ r= requests.get(website)
143+ r.raise_for_status()
144+
145+ string = 'Amulet Wiki'
146+ find_text = r.text.find(string)
147+ found_string = find_text != -1
148+
149+ if found_string:
150+ print('MoinMoin seems to be running!')
151+ else:
152+ print('Apparently MoinMoin is not running.')
153+ amulet.raise_status(amulet.FAIL)
154+
155+
156+if __name__ == '__main__':
157+ unittest.main()
158
159=== removed file 'tests/100-deploy-test'
160--- tests/100-deploy-test 2014-10-29 21:59:41 +0000
161+++ tests/100-deploy-test 1970-01-01 00:00:00 +0000
162@@ -1,119 +0,0 @@
163-#!/bin/sh
164-
165-if [ -z "`which wget`" ] ; then
166- echo SKIP: need wget to run test.
167- exit 100
168-fi
169-
170-set -ex
171-
172-teardown() {
173- juju destroy-service python-moinmoin
174- #juju destroy-service haproxy
175- if [ -n "$datadir" ] ; then
176- if [ -f $datadir/passed ]; then
177- rm -r $datadir
178- else
179- echo $datadir preserved
180- fi
181- fi
182-}
183-trap teardown EXIT
184-
185-
186-juju deploy cs:precise/python-moinmoin
187-juju deploy cs:precise/haproxy
188-juju add-relation haproxy:reverseproxy python-moinmoin:website
189-juju expose haproxy
190-
191-for try in `seq 1 600` ; do
192- host=`juju status | tests/get-unit-info haproxy public-address`
193- if [ -z "$host" ] ; then
194- sleep 1
195- else
196- break
197- fi
198-done
199-
200-if [ -z "$host" ] ; then
201- echo ERROR: status timed out
202- exit 1
203-fi
204-
205-if [ $try -eq 600 ] ; then
206- echo ERROR: Timed out waiting.
207- exit 1
208-fi
209-
210-datadir=`mktemp -d ${TMPDIR:-/tmp}/wget.test.XXXXXXX`
211-echo INFO: datadir=$datadir
212-
213-for try_wget in `seq 1 600` ; do
214- wget --timeout=6 http://$host/ -O - -a $datadir/wget.log
215- if [ $? -ne 0 ] ; then
216- sleep 1
217- else
218- break
219- fi
220-done
221-
222-if [ $try_wget -eq 600 ] ; then
223- echo ERROR:The frontpage never show up
224- exit 1
225-fi
226-
227-# Test English language
228-wget --tries=100 --timeout=6 http://$host/FindPage -O - -a $datadir/wget.log
229-
230-if [ $? -ne 0 ] ; then
231- echo ERROR: English Underlay not found
232- exit 1
233-fi
234-
235-## Test Japanese language
236-#wget --tries=100 --timeout=6 http://$host/%E3%83%9A%E3%83%BC%E3%82%B8%E6%A4%9C%E7%B4%A2 -O - -a $datadir/wget.log
237-#
238-#if [ $? -ne 0 ] ; then
239-# echo ERROR: Japanese Underlay not found
240-# exit 1
241-#fi
242-
243-# Test the search engine
244-wget --tries=100 --timeout=6 --user-agent=Firefox "http://$host/?action=fullsearch&context=180&value=Help&titlesearch=Titres" -O - -a $datadir/wget.log
245-
246-if [ $? -ne 0 ] ; then
247- echo ERROR: The search is not working
248- exit 1
249-fi
250-
251-## Test admin user creation
252-#wget --timeout=6 --user-agent=Firefox --post-data='name=Admin&password1=TestPass&password2=TestPass&email=test@acme.com' "http://$host/login?action=newaccount" -O - -a $datadir/wget.log
253-#
254-#if [ $? -ne 0 ] ; then
255-# echo ERROR: Not able to create admin user
256-# exit 1
257-#fi
258-#
259-## Test admin user log-in
260-#wget --timeout=6 "http://$host/login?action=login" --post-data='name=Admin&password=TestPass' --save-cookies=cookies.txt --keep-session-cookies -O - -a $datadir/wget.log
261-#
262-#if [ $? -ne 0 ] ; then
263-# echo ERROR: Not able to log in as admin user
264-# exit 1
265-#fi
266-#
267-## Test super user permissions
268-#wget --timeout=6 "http://$host/System?action=userprefs&sub=suid" --load-cookies=cookies.txt -O - -a $datadir/wget.log
269-#
270-#if [ $? -ne 0 ] ; then
271-# echo ERROR: Incorrect permissions for admin user
272-# exit 1
273-#fi
274-
275-touch $datadir/passed
276-
277-trap - EXIT
278-teardown
279-
280-echo INFO: PASS
281-exit 0
282
283=== removed file 'tests/bundles.yaml'
284--- tests/bundles.yaml 2014-10-29 21:59:41 +0000
285+++ tests/bundles.yaml 1970-01-01 00:00:00 +0000
286@@ -1,21 +0,0 @@
287-python-moinmoin-starter:
288- services:
289- "python-moinmoin":
290- charm: "python-moinmoin"
291- num_units: 1
292- exposed: true
293- options:
294- wiki_name: amulet wiki
295- annotations:
296- "gui-x": "300"
297- "gui-y": "300"
298- apache2:
299- charm: "cs:trusty/apache2"
300- num_units: 1
301- annotations:
302- "gui-x": "688"
303- "gui-y": "301"
304- relations:
305- - - "apache2:reverseproxy"
306- - "python-moinmoin:website"
307- series: trusty
308
309=== removed file 'tests/get-unit-info'
310--- tests/get-unit-info 2012-03-01 04:13:58 +0000
311+++ tests/get-unit-info 1970-01-01 00:00:00 +0000
312@@ -1,46 +0,0 @@
313-#!/usr/bin/python
314-# machines:
315-# 0: {dns-name: ec2-50-17-84-127.compute-1.amazonaws.com, instance-id: i-8c5c3fec}
316-# 1: {dns-name: ec2-184-73-102-113.compute-1.amazonaws.com, instance-id: i-14a2c174}
317-# 2: {dns-name: ec2-75-101-184-93.compute-1.amazonaws.com, instance-id: i-e0a2c180}
318-# services:
319-# mysql:
320-# charm: local:mysql-11
321-# relations: {db: wordpress}
322-# units:
323-# mysql/0:
324-# machine: 2
325-# relations:
326-# db: {state: up}
327-# state: started
328-# wordpress:
329-# charm: local:wordpress-31
330-# exposed: true
331-# relations: {db: mysql}
332-# units:
333-# wordpress/0:
334-# machine: 1
335-# open-ports: []
336-# relations: {}
337-# state: null
338-
339-import yaml
340-import sys
341-from subprocess import Popen, PIPE
342-
343-
344-def main():
345- d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
346- srv = d.get("services", {}).get(sys.argv[1])
347- if srv is None:
348- return
349- units = srv.get("units", {})
350- if units is None:
351- return
352- item = units.items()[0][1].get(sys.argv[2])
353- if item is None:
354- return
355- print item
356-
357-if __name__ == "__main__":
358- main()
359
360=== removed file 'tests/tests.yaml'
361--- tests/tests.yaml 2014-10-29 21:59:41 +0000
362+++ tests/tests.yaml 1970-01-01 00:00:00 +0000
363@@ -1,3 +0,0 @@
364-bootstrap: true
365-reset: true
366-tests: "10-bundle-test.py"

Subscribers

People subscribed via source and target branches

to all changes: