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

Proposed by José Antonio Rey
Status: Merged
Merged at revision: 11
Proposed branch: lp:~jose/charms/precise/python-moinmoin/refactor-tests
Merge into: lp:charms/python-moinmoin
Diff against target: 276 lines (+57/-169)
6 files modified
README.md (+3/-3)
hooks/hooks.py (+1/-1)
tests/00-setup (+5/-0)
tests/01_deploy.test (+0/-119)
tests/10-deploy (+48/-0)
tests/get-unit-info (+0/-46)
To merge this branch: bzr merge lp:~jose/charms/precise/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+248330@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-11017-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 for the reviews 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 05:58:12 +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 05:58:12 +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=== added file 'tests/00-setup'
41--- tests/00-setup 1970-01-01 00:00:00 +0000
42+++ tests/00-setup 2015-02-03 05:58:12 +0000
43@@ -0,0 +1,5 @@
44+#!/bin/bash
45+
46+sudo add-apt-repository ppa:juju/stable -y
47+sudo apt-get update
48+sudo apt-get install amulet python3-requests -y
49
50=== removed file 'tests/01_deploy.test'
51--- tests/01_deploy.test 2014-09-11 06:54:37 +0000
52+++ tests/01_deploy.test 1970-01-01 00:00:00 +0000
53@@ -1,119 +0,0 @@
54-#!/bin/sh
55-
56-if [ -z "`which wget`" ] ; then
57- echo SKIP: need wget to run test.
58- exit 100
59-fi
60-
61-set -ex
62-
63-teardown() {
64- juju destroy-service python-moinmoin
65- juju destroy-service haproxy
66- if [ -n "$datadir" ] ; then
67- if [ -f $datadir/passed ]; then
68- rm -r $datadir
69- else
70- echo $datadir preserved
71- fi
72- fi
73-}
74-trap teardown EXIT
75-
76-
77-juju deploy cs:precise/python-moinmoin
78-juju deploy cs:precise/haproxy
79-juju add-relation haproxy:reverseproxy python-moinmoin:website
80-juju expose haproxy
81-
82-for try in `seq 1 600` ; do
83- host=`juju status | tests/get-unit-info haproxy public-address`
84- if [ -z "$host" ] ; then
85- sleep 1
86- else
87- break
88- fi
89-done
90-
91-if [ -z "$host" ] ; then
92- echo ERROR: status timed out
93- exit 1
94-fi
95-
96-if [ $try -eq 600 ] ; then
97- echo ERROR: Timed out waiting.
98- exit 1
99-fi
100-
101-datadir=`mktemp -d ${TMPDIR:-/tmp}/wget.test.XXXXXXX`
102-echo INFO: datadir=$datadir
103-
104-for try_wget in `seq 1 600` ; do
105- wget --timeout=6 http://$host/ -O - -a $datadir/wget.log
106- if [ $? -ne 0 ] ; then
107- sleep 1
108- else
109- break
110- fi
111-done
112-
113-if [ $try_wget -eq 600 ] ; then
114- echo ERROR:The frontpage never show up
115- exit 1
116-fi
117-
118-# Test English language
119-wget --tries=100 --timeout=6 http://$host/FindPage -O - -a $datadir/wget.log
120-
121-if [ $? -ne 0 ] ; then
122- echo ERROR: English Underlay not found
123- exit 1
124-fi
125-
126-## Test Japanese language
127-#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
128-#
129-#if [ $? -ne 0 ] ; then
130-# echo ERROR: Japanese Underlay not found
131-# exit 1
132-#fi
133-
134-# Test the search engine
135-wget --tries=100 --timeout=6 --user-agent=Firefox "http://$host/?action=fullsearch&context=180&value=Help&titlesearch=Titres" -O - -a $datadir/wget.log
136-
137-if [ $? -ne 0 ] ; then
138- echo ERROR: The search is not working
139- exit 1
140-fi
141-
142-## Test admin user creation
143-#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
144-#
145-#if [ $? -ne 0 ] ; then
146-# echo ERROR: Not able to create admin user
147-# exit 1
148-#fi
149-#
150-## Test admin user log-in
151-#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
152-#
153-#if [ $? -ne 0 ] ; then
154-# echo ERROR: Not able to log in as admin user
155-# exit 1
156-#fi
157-#
158-## Test super user permissions
159-#wget --timeout=6 "http://$host/System?action=userprefs&sub=suid" --load-cookies=cookies.txt -O - -a $datadir/wget.log
160-#
161-#if [ $? -ne 0 ] ; then
162-# echo ERROR: Incorrect permissions for admin user
163-# exit 1
164-#fi
165-
166-touch $datadir/passed
167-
168-trap - EXIT
169-teardown
170-
171-echo INFO: PASS
172-exit 0
173
174=== added file 'tests/10-deploy'
175--- tests/10-deploy 1970-01-01 00:00:00 +0000
176+++ tests/10-deploy 2015-02-03 05:58:12 +0000
177@@ -0,0 +1,48 @@
178+#!/usr/bin/env python3
179+
180+import amulet
181+import requests
182+import unittest
183+
184+
185+class TestDeployment(unittest.TestCase):
186+ @classmethod
187+ def setUpClass(cls):
188+ cls.deployment = amulet.Deployment(series='precise')
189+
190+ cls.deployment.add('python-moinmoin')
191+ cls.deployment.configure('python-moinmoin', {'wiki_name': 'Amulet Wiki',
192+ 'admin_name': 'citest', 'languages': 'English',
193+ 'xapian_search': 'True', 'listen_port': '8080',
194+ 'use_openid': 'False'})
195+ cls.deployment.expose('python-moinmoin')
196+
197+ try:
198+ cls.deployment.setup(timeout=900)
199+ cls.deployment.sentry.wait()
200+ except amulet.helpers.TimeoutError:
201+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
202+ except:
203+ raise
204+
205+ cls.unit = cls.deployment.sentry.unit['python-moinmoin/0']
206+ cls.address = cls.unit.info['public-address']
207+
208+ def test_exposed(self):
209+ website = 'http://%s:8080/' % self.address
210+ r= requests.get(website)
211+ r.raise_for_status()
212+
213+ string = 'Amulet Wiki'
214+ find_text = r.text.find(string)
215+ found_string = find_text != -1
216+
217+ if found_string:
218+ print('MoinMoin seems to be running!')
219+ else:
220+ print('Apparently MoinMoin is not running.')
221+ amulet.raise_status(amulet.FAIL)
222+
223+
224+if __name__ == '__main__':
225+ unittest.main()
226
227=== removed file 'tests/get-unit-info'
228--- tests/get-unit-info 2012-03-01 04:13:58 +0000
229+++ tests/get-unit-info 1970-01-01 00:00:00 +0000
230@@ -1,46 +0,0 @@
231-#!/usr/bin/python
232-# machines:
233-# 0: {dns-name: ec2-50-17-84-127.compute-1.amazonaws.com, instance-id: i-8c5c3fec}
234-# 1: {dns-name: ec2-184-73-102-113.compute-1.amazonaws.com, instance-id: i-14a2c174}
235-# 2: {dns-name: ec2-75-101-184-93.compute-1.amazonaws.com, instance-id: i-e0a2c180}
236-# services:
237-# mysql:
238-# charm: local:mysql-11
239-# relations: {db: wordpress}
240-# units:
241-# mysql/0:
242-# machine: 2
243-# relations:
244-# db: {state: up}
245-# state: started
246-# wordpress:
247-# charm: local:wordpress-31
248-# exposed: true
249-# relations: {db: mysql}
250-# units:
251-# wordpress/0:
252-# machine: 1
253-# open-ports: []
254-# relations: {}
255-# state: null
256-
257-import yaml
258-import sys
259-from subprocess import Popen, PIPE
260-
261-
262-def main():
263- d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
264- srv = d.get("services", {}).get(sys.argv[1])
265- if srv is None:
266- return
267- units = srv.get("units", {})
268- if units is None:
269- return
270- item = units.items()[0][1].get(sys.argv[2])
271- if item is None:
272- return
273- print item
274-
275-if __name__ == "__main__":
276- main()

Subscribers

People subscribed via source and target branches

to all changes: