Merge lp:~lazypower/charms/precise/mediawiki/lp_1292651 into lp:charms/mediawiki

Proposed by Charles Butler
Status: Merged
Merged at revision: 79
Proposed branch: lp:~lazypower/charms/precise/mediawiki/lp_1292651
Merge into: lp:charms/mediawiki
Diff against target: 68 lines (+21/-25)
2 files modified
tests/00-setup (+1/-2)
tests/100-deploy (+20/-23)
To merge this branch: bzr merge lp:~lazypower/charms/precise/mediawiki/lp_1292651
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
José Antonio Rey (community) Approve
Jorge Niedbalski (community) Needs Fixing
Cory Johns (community) Needs Fixing
charmers Pending
Review via email: mp+220095@code.launchpad.net

Description of the change

Refactors out phantomjs/selenium - uses requests and title validation.

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

A hard-coded IP got left in the test which causes it to fail (see inline comment).

review: Needs Fixing
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

Tests not passing, please read inline comments.

review: Needs Fixing
80. By Charles Butler

José Antonio Rey 2014-06-20 Removed private IP address and changed it for a variable

Revision history for this message
José Antonio Rey (jose) wrote :

After the fix recently pushed, I ran the tests and they returned with a 0 exit code. Looks like they're ready for merging now.

review: Approve
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/00-setup'
2--- tests/00-setup 2014-02-21 23:29:26 +0000
3+++ tests/00-setup 2014-07-10 02:27:07 +0000
4@@ -6,5 +6,4 @@
5 sudo apt-add-repository ppa:juju/stable -y
6 sudo apt-get update
7
8-sudo apt-get install amulet python3 python3-requests python3-dev python3-pip phantomjs -y
9-sudo pip3 install splinter selenium
10+sudo apt-get install amulet python3 python3-requests python3-dev python3-pip -y
11
12=== modified file 'tests/100-deploy'
13--- tests/100-deploy 2014-02-21 23:29:26 +0000
14+++ tests/100-deploy 2014-07-10 02:27:07 +0000
15@@ -1,6 +1,6 @@
16 #!/usr/bin/env python3
17 import amulet
18-from splinter import Browser
19+import requests
20
21 seconds = 900
22
23@@ -59,26 +59,23 @@
24 memcached_relation['port'])
25
26 #############################################################
27-# Validate the installation configuration using PhantomJS
28+# Validate the installation configuration using Requests
29 #############################################################
30-browser = Browser('phantomjs')
31-browser.visit("http://%s/mediawiki/index.php?"
32- "title=Special:UserLogin&returnto=Main+Page" %
33- d.sentry.unit['mediawiki/0'].info['public-address'])
34-
35-
36-title = str(browser.title).find("Log in")
37-if title == -1:
38- amulet.raise_status(amulet.FAIL, msg="Failed login test.")
39-
40-title = str(browser.title).find("amulet-wiki")
41-if title == -1:
42- amulet.raise_status(amulet.FAIL, msg="Failed to parse provided title")
43-
44-browser.fill("wpName", 'tom')
45-browser.fill('wpPassword', 'swordfish')
46-browser.find_by_id('wpLoginAttempt').first.click()
47-
48-if not browser.is_text_present('tom'):
49- amulet.raise_status(amulet.FAIL,
50- msg="Failed to login with configured admin")
51+mw_ip = d.sentry.unit['mediawiki/0'].info['public-address']
52+mw_url = "http://%s/mediawiki/index.php" % mw_ip
53+response = requests.get(mw_url)
54+
55+if response.content.find(b"<title>amulet-wiki") == -1:
56+ amulet.raise_status(amulet.FAIL,
57+ "Unable to validate configuration for wiki-name")
58+
59+login_url = "http://%s/mediawiki/index.php?title=" % mw_ip
60+"Special:UserLogin&action=submitlogin&type=login&returnto=Main+Page"
61+
62+payload = {'wpName': 'tom', 'wpPassword': 'swordfish'}
63+
64+with requests.Session() as s:
65+
66+ resp = s.post(login_url, data=payload)
67+ if resp.text.find("<title>amulet-wiki") == -1:
68+ amulet.raise_status(amulet.FAIL, "Unable to validate admin login")

Subscribers

People subscribed via source and target branches

to all changes: