Merge lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk into lp:charms/oneiric/python-moinmoin

Proposed by Patrick Hetu on 2012-03-05
Status: Merged
Merged at revision: 5
Proposed branch: lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk
Merge into: lp:charms/oneiric/python-moinmoin
Diff against target: 265 lines (+180/-9)
6 files modified
config.yaml (+2/-2)
hooks/config-changed (+9/-5)
hooks/install (+3/-1)
revision (+1/-1)
tests/01_deploy.test (+119/-0)
tests/get-unit-info (+46/-0)
To merge this branch: bzr merge lp:~patrick-hetu/charms/oneiric/python-moinmoin/trunk
Reviewer Review Type Date Requested Status
Juan L. Negron (community) 2012-03-05 Approve on 2012-03-05
Review via email: mp+95974@code.launchpad.net

Description of the change

bug fixing + tests

To post a comment you must log in.
Juan L. Negron (negronjl) wrote :

Hi Patrick:

Thanks for the update. This looks good to me.

-Juan

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2012-01-28 01:28:34 +0000
3+++ config.yaml 2012-03-05 19:25:31 +0000
4@@ -8,14 +8,14 @@
5 type: string
6 description: The wiki name of the admin user.
7 languages:
8- defaut: English
9+ default: "English"
10 type: string
11 description: |
12 Languages to installed in a space-separated format.
13 For available languages see: http://moinmo.in/4ct10n/AttachFile/LanguageSetup?action=AttachFile
14 (write only the language name part)
15 xapian_search:
16- default: False
17+ default: "True"
18 type: string
19 description: Set to True to enable the Xapian search engine.
20 extra_settings:
21
22=== modified file 'hooks/config-changed'
23--- hooks/config-changed 2012-01-10 18:20:17 +0000
24+++ hooks/config-changed 2012-03-05 19:25:31 +0000
25@@ -8,6 +8,7 @@
26 XAPIAN_SETTINGS=$(config-get xapian_search)
27 EXTRA_SETTINGS=$(config-get extra_settings)
28
29+juju-log "variables: WIKI_NAME: $WIKI_NAME,ADMIN_NAME: $ADMIN_NAME ,LANGUAGES: $LANGUAGES ,XAPIAN_SETTINGS: $XAPIAN_SETTINGS"
30
31 cat > /srv/${UNIT_NAME}/wikiconfig.py <<EOF
32 # -*- coding: utf-8 -*-
33@@ -21,10 +22,10 @@
34 data_dir = os.path.join(instance_dir, 'data', '') # path with trailing /
35 data_underlay_dir = os.path.join(instance_dir, 'underlay', '') # path with trailing /
36
37- sitename = u'$WIKI_NAME'
38+ sitename = u'${WIKI_NAME}'
39 logo_string = u'<img src="%s/common/moinmoin.png" alt="MoinMoin Logo">' % url_prefix_static
40- superuser = [u"$ADMIN_NAME", ]
41- acl_rights_before = u"$ADMIN_NAME:read,write,delete,revert,admin"
42+ superuser = [u"${ADMIN_NAME}", ]
43+ acl_rights_before = u"${ADMIN_NAME}:read,write,delete,revert,admin"
44
45 page_front_page = u"FrontPage"
46 navi_bar = [
47@@ -36,6 +37,9 @@
48 xapian_search = ${XAPIAN_SETTINGS}
49 xapian_stemming = ${XAPIAN_SETTINGS}
50
51+ mail_smarthost = "localhost"
52+ mail_from = u"${WIKI_NAME} <noreply>"
53+
54 ${EXTRA_SETTINGS}
55 EOF
56
57@@ -55,8 +59,8 @@
58 python -m MoinMoin.packages i ./underlay/pages/LanguageSetup/attachments/${lang}--all_pages.zip
59 done
60
61-chown www-data /srv/${UNIT_NAME}/ -R
62+chown root:www-data /srv/${UNIT_NAME}/ -R
63 chmod g+rw /srv/${UNIT_NAME}/ -R
64
65 /etc/init.d/gunicorn start
66-/etc/init.d/gunicorn reload
67+/etc/init.d/gunicorn restart
68
69=== modified file 'hooks/install'
70--- hooks/install 2012-01-10 18:20:17 +0000
71+++ hooks/install 2012-03-05 19:25:31 +0000
72@@ -5,7 +5,9 @@
73 WIKI_NAME=$(config-get wiki_name)
74 ADMIN_NAME=$(config-get admin_name)
75
76-apt-get install -y python-moinmoin fckeditor python-flup gunicorn python-eventlet unzip python-openid python-xapian python-xappy --no-install-recommends
77+# --no-install-recommends and not fckeditor: because we don't want apache2 here.
78+
79+apt-get install --no-install-recommends -y python-moinmoin python-flup gunicorn python-eventlet unzip python-openid python-xapian python-xappy python-docutils
80
81 # MoinMoin's command line script 'moin' check there first
82 # and we don't want that
83
84=== modified file 'revision'
85--- revision 2012-01-10 18:20:17 +0000
86+++ revision 2012-03-05 19:25:31 +0000
87@@ -1,1 +1,1 @@
88-5
89+6
90
91=== added directory 'tests'
92=== added file 'tests/01_deploy.test'
93--- tests/01_deploy.test 1970-01-01 00:00:00 +0000
94+++ tests/01_deploy.test 2012-03-05 19:25:31 +0000
95@@ -0,0 +1,119 @@
96+#!/bin/sh
97+
98+if [ -z "`which wget`" ] ; then
99+ echo SKIP: need wget to run test.
100+ exit 100
101+fi
102+
103+set -e
104+
105+teardown() {
106+ juju destroy-service python-moinmoin
107+ juju destroy-service haproxy
108+ if [ -n "$datadir" ] ; then
109+ if [ -f $datadir/passed ]; then
110+ rm -r $datadir
111+ else
112+ echo $datadir preserved
113+ fi
114+ fi
115+}
116+trap teardown EXIT
117+
118+
119+juju deploy python-moinmoin
120+juju deploy haproxy
121+juju add-relation haproxy:reverseproxy python-moinmoin:website
122+juju expose haproxy
123+
124+for try in `seq 1 600` ; do
125+ host=`juju status | tests/get-unit-info haproxy public-address`
126+ if [ -z "$host" ] ; then
127+ sleep 1
128+ else
129+ break
130+ fi
131+done
132+
133+if [ -z "$host" ] ; then
134+ echo ERROR: status timed out
135+ exit 1
136+fi
137+
138+if [ $try -eq 600 ] ; then
139+ echo ERROR: Timed out waiting.
140+ exit 1
141+fi
142+
143+datadir=`mktemp -d ${TMPDIR:-/tmp}/wget.test.XXXXXXX`
144+echo INFO: datadir=$datadir
145+
146+for try_wget in `seq 1 600` ; do
147+ wget --timeout=6 http://$host/ -O - -a $datadir/wget.log
148+ if [ $? -ne 0 ] ; then
149+ sleep 1
150+ else
151+ break
152+ fi
153+done
154+
155+if [ $try_wget -eq 600 ] ; then
156+ echo ERROR:The frontpage never show up
157+ exit 1
158+fi
159+
160+# Test English language
161+wget --tries=100 --timeout=6 http://$host/FindPage -O - -a $datadir/wget.log
162+
163+if [ $? -ne 0 ] ; then
164+ echo ERROR: English Underlay not found
165+ exit 1
166+fi
167+
168+## Test Japanese language
169+#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
170+#
171+#if [ $? -ne 0 ] ; then
172+# echo ERROR: Japanese Underlay not found
173+# exit 1
174+#fi
175+
176+# Test the search engine
177+wget --tries=100 --timeout=6 --user-agent=Firefox "http://$host/?action=fullsearch&context=180&value=Help&titlesearch=Titres" -O - -a $datadir/wget.log
178+
179+if [ $? -ne 0 ] ; then
180+ echo ERROR: The search is not working
181+ exit 1
182+fi
183+
184+## Test admin user creation
185+#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
186+#
187+#if [ $? -ne 0 ] ; then
188+# echo ERROR: Not able to create admin user
189+# exit 1
190+#fi
191+#
192+## Test admin user log-in
193+#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
194+#
195+#if [ $? -ne 0 ] ; then
196+# echo ERROR: Not able to log in as admin user
197+# exit 1
198+#fi
199+#
200+## Test super user permissions
201+#wget --timeout=6 "http://$host/System?action=userprefs&sub=suid" --load-cookies=cookies.txt -O - -a $datadir/wget.log
202+#
203+#if [ $? -ne 0 ] ; then
204+# echo ERROR: Incorrect permissions for admin user
205+# exit 1
206+#fi
207+
208+touch $datadir/passed
209+
210+trap - EXIT
211+teardown
212+
213+echo INFO: PASS
214+exit 0
215
216=== added file 'tests/get-unit-info'
217--- tests/get-unit-info 1970-01-01 00:00:00 +0000
218+++ tests/get-unit-info 2012-03-05 19:25:31 +0000
219@@ -0,0 +1,46 @@
220+#!/usr/bin/python
221+# machines:
222+# 0: {dns-name: ec2-50-17-84-127.compute-1.amazonaws.com, instance-id: i-8c5c3fec}
223+# 1: {dns-name: ec2-184-73-102-113.compute-1.amazonaws.com, instance-id: i-14a2c174}
224+# 2: {dns-name: ec2-75-101-184-93.compute-1.amazonaws.com, instance-id: i-e0a2c180}
225+# services:
226+# mysql:
227+# charm: local:mysql-11
228+# relations: {db: wordpress}
229+# units:
230+# mysql/0:
231+# machine: 2
232+# relations:
233+# db: {state: up}
234+# state: started
235+# wordpress:
236+# charm: local:wordpress-31
237+# exposed: true
238+# relations: {db: mysql}
239+# units:
240+# wordpress/0:
241+# machine: 1
242+# open-ports: []
243+# relations: {}
244+# state: null
245+
246+import yaml
247+import sys
248+from subprocess import Popen, PIPE
249+
250+
251+def main():
252+ d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
253+ srv = d.get("services", {}).get(sys.argv[1])
254+ if srv is None:
255+ return
256+ units = srv.get("units", {})
257+ if units is None:
258+ return
259+ item = units.items()[0][1].get(sys.argv[2])
260+ if item is None:
261+ return
262+ print item
263+
264+if __name__ == "__main__":
265+ main()

Subscribers

People subscribed via source and target branches

to all changes: