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
=== modified file 'README.md'
--- README.md 2013-09-26 06:15:02 +0000
+++ README.md 2015-02-03 05:58:12 +0000
@@ -14,7 +14,7 @@
14 admin_name: "Admin"14 admin_name: "Admin"
15 languages: English French15 languages: English French
16 xapian_search: True16 xapian_search: True
17 port: 8017 listen_port: 80
1818
19To then deploy the wiki, with pre-seeded configuration:19To then deploy the wiki, with pre-seeded configuration:
2020
@@ -48,10 +48,10 @@
4848
49 juju set python_moinmoin xapian_search="True"49 juju set python_moinmoin xapian_search="True"
5050
51# port51# listen_port
52The port moinmoin should listen on. By default it's 808052The port moinmoin should listen on. By default it's 8080
5353
54 juju set python_moinmoin port=8054 juju set python_moinmoin listen_port=80
5555
56# use_openid56# use_openid
57Setting to say if the wiki is using OpenID authentication or not.57Setting to say if the wiki is using OpenID authentication or not.
5858
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2013-09-19 06:09:37 +0000
+++ hooks/hooks.py 2015-02-03 05:58:12 +0000
@@ -104,7 +104,7 @@
104 shutil.copytree('/usr/share/moin/underlay', basedir + "/underlay")104 shutil.copytree('/usr/share/moin/underlay', basedir + "/underlay")
105 if not os.path.exists(staticdir):105 if not os.path.exists(staticdir):
106 shutil.copytree('/usr/share/moin/htdocs', staticdir)106 shutil.copytree('/usr/share/moin/htdocs', staticdir)
107107 open_port(listen_port)
108108
109@hooks.hook("config-changed")109@hooks.hook("config-changed")
110def config_changed():110def config_changed():
111111
=== added file 'tests/00-setup'
--- tests/00-setup 1970-01-01 00:00:00 +0000
+++ tests/00-setup 2015-02-03 05:58:12 +0000
@@ -0,0 +1,5 @@
1#!/bin/bash
2
3sudo add-apt-repository ppa:juju/stable -y
4sudo apt-get update
5sudo apt-get install amulet python3-requests -y
06
=== removed file 'tests/01_deploy.test'
--- tests/01_deploy.test 2014-09-11 06:54:37 +0000
+++ tests/01_deploy.test 1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
1#!/bin/sh
2
3if [ -z "`which wget`" ] ; then
4 echo SKIP: need wget to run test.
5 exit 100
6fi
7
8set -ex
9
10teardown() {
11 juju destroy-service python-moinmoin
12 juju destroy-service haproxy
13 if [ -n "$datadir" ] ; then
14 if [ -f $datadir/passed ]; then
15 rm -r $datadir
16 else
17 echo $datadir preserved
18 fi
19 fi
20}
21trap teardown EXIT
22
23
24juju deploy cs:precise/python-moinmoin
25juju deploy cs:precise/haproxy
26juju add-relation haproxy:reverseproxy python-moinmoin:website
27juju expose haproxy
28
29for try in `seq 1 600` ; do
30 host=`juju status | tests/get-unit-info haproxy public-address`
31 if [ -z "$host" ] ; then
32 sleep 1
33 else
34 break
35 fi
36done
37
38if [ -z "$host" ] ; then
39 echo ERROR: status timed out
40 exit 1
41fi
42
43if [ $try -eq 600 ] ; then
44 echo ERROR: Timed out waiting.
45 exit 1
46fi
47
48datadir=`mktemp -d ${TMPDIR:-/tmp}/wget.test.XXXXXXX`
49echo INFO: datadir=$datadir
50
51for try_wget in `seq 1 600` ; do
52 wget --timeout=6 http://$host/ -O - -a $datadir/wget.log
53 if [ $? -ne 0 ] ; then
54 sleep 1
55 else
56 break
57 fi
58done
59
60if [ $try_wget -eq 600 ] ; then
61 echo ERROR:The frontpage never show up
62 exit 1
63fi
64
65# Test English language
66wget --tries=100 --timeout=6 http://$host/FindPage -O - -a $datadir/wget.log
67
68if [ $? -ne 0 ] ; then
69 echo ERROR: English Underlay not found
70 exit 1
71fi
72
73## Test Japanese language
74#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
75#
76#if [ $? -ne 0 ] ; then
77# echo ERROR: Japanese Underlay not found
78# exit 1
79#fi
80
81# Test the search engine
82wget --tries=100 --timeout=6 --user-agent=Firefox "http://$host/?action=fullsearch&context=180&value=Help&titlesearch=Titres" -O - -a $datadir/wget.log
83
84if [ $? -ne 0 ] ; then
85 echo ERROR: The search is not working
86 exit 1
87fi
88
89## Test admin user creation
90#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
91#
92#if [ $? -ne 0 ] ; then
93# echo ERROR: Not able to create admin user
94# exit 1
95#fi
96#
97## Test admin user log-in
98#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
99#
100#if [ $? -ne 0 ] ; then
101# echo ERROR: Not able to log in as admin user
102# exit 1
103#fi
104#
105## Test super user permissions
106#wget --timeout=6 "http://$host/System?action=userprefs&sub=suid" --load-cookies=cookies.txt -O - -a $datadir/wget.log
107#
108#if [ $? -ne 0 ] ; then
109# echo ERROR: Incorrect permissions for admin user
110# exit 1
111#fi
112
113touch $datadir/passed
114
115trap - EXIT
116teardown
117
118echo INFO: PASS
119exit 0
1200
=== added file 'tests/10-deploy'
--- tests/10-deploy 1970-01-01 00:00:00 +0000
+++ tests/10-deploy 2015-02-03 05:58:12 +0000
@@ -0,0 +1,48 @@
1#!/usr/bin/env python3
2
3import amulet
4import requests
5import unittest
6
7
8class TestDeployment(unittest.TestCase):
9 @classmethod
10 def setUpClass(cls):
11 cls.deployment = amulet.Deployment(series='precise')
12
13 cls.deployment.add('python-moinmoin')
14 cls.deployment.configure('python-moinmoin', {'wiki_name': 'Amulet Wiki',
15 'admin_name': 'citest', 'languages': 'English',
16 'xapian_search': 'True', 'listen_port': '8080',
17 'use_openid': 'False'})
18 cls.deployment.expose('python-moinmoin')
19
20 try:
21 cls.deployment.setup(timeout=900)
22 cls.deployment.sentry.wait()
23 except amulet.helpers.TimeoutError:
24 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
25 except:
26 raise
27
28 cls.unit = cls.deployment.sentry.unit['python-moinmoin/0']
29 cls.address = cls.unit.info['public-address']
30
31 def test_exposed(self):
32 website = 'http://%s:8080/' % self.address
33 r= requests.get(website)
34 r.raise_for_status()
35
36 string = 'Amulet Wiki'
37 find_text = r.text.find(string)
38 found_string = find_text != -1
39
40 if found_string:
41 print('MoinMoin seems to be running!')
42 else:
43 print('Apparently MoinMoin is not running.')
44 amulet.raise_status(amulet.FAIL)
45
46
47if __name__ == '__main__':
48 unittest.main()
049
=== removed file 'tests/get-unit-info'
--- tests/get-unit-info 2012-03-01 04:13:58 +0000
+++ tests/get-unit-info 1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
1#!/usr/bin/python
2# machines:
3# 0: {dns-name: ec2-50-17-84-127.compute-1.amazonaws.com, instance-id: i-8c5c3fec}
4# 1: {dns-name: ec2-184-73-102-113.compute-1.amazonaws.com, instance-id: i-14a2c174}
5# 2: {dns-name: ec2-75-101-184-93.compute-1.amazonaws.com, instance-id: i-e0a2c180}
6# services:
7# mysql:
8# charm: local:mysql-11
9# relations: {db: wordpress}
10# units:
11# mysql/0:
12# machine: 2
13# relations:
14# db: {state: up}
15# state: started
16# wordpress:
17# charm: local:wordpress-31
18# exposed: true
19# relations: {db: mysql}
20# units:
21# wordpress/0:
22# machine: 1
23# open-ports: []
24# relations: {}
25# state: null
26
27import yaml
28import sys
29from subprocess import Popen, PIPE
30
31
32def main():
33 d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
34 srv = d.get("services", {}).get(sys.argv[1])
35 if srv is None:
36 return
37 units = srv.get("units", {})
38 if units is None:
39 return
40 item = units.items()[0][1].get(sys.argv[2])
41 if item is None:
42 return
43 print item
44
45if __name__ == "__main__":
46 main()

Subscribers

People subscribed via source and target branches

to all changes: