Merge lp:~jose/charms/precise/tracks/add-tests into lp:charms/tracks

Proposed by José Antonio Rey
Status: Needs review
Proposed branch: lp:~jose/charms/precise/tracks/add-tests
Merge into: lp:charms/tracks
Diff against target: 92 lines (+70/-1)
3 files modified
hooks/install (+1/-1)
tests/00-setup (+5/-0)
tests/10-deploy (+64/-0)
To merge this branch: bzr merge lp:~jose/charms/precise/tracks/add-tests
Reviewer Review Type Date Requested Status
Adam Israel (community) Needs Fixing
Review Queue (community) automated testing Needs Fixing
charmers Pending
Review via email: mp+241413@code.launchpad.net

Description of the change

Add tests and fixed small bug on the install hook which prevented install

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-10342-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 ran into a couple small issues in tests/10-deploy:

line 34 should reference tractions_relation instead of relation
line 43 is missing a closing parentheses
line 57 needs a % after the string

I also had to bump up the deployment timeout to 3600 in order for it to complete.

Unfortunately, the test failed once the timeout and the above issues were resolved:

2014-12-17 16:26:11 Starting deployment of local
2014-12-17 16:26:14 Deploying services...
2014-12-17 16:26:15 Deploying service mysql using cs:precise/mysql-50
2014-12-17 16:26:21 Deploying service tracks using cs:precise/tracks-5
2014-12-17 16:57:55 Adding relations...
2014-12-17 16:57:57 Adding relation tracks:db <-> mysql:db
2014-12-17 16:58:58 Exposing service 'tracks'
2014-12-17 16:58:59 Deployment complete in 1969.82 seconds
/usr/lib/python3/dist-packages/charmworldlib/api.py:18: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=6, laddr=('192.168.1.147', 44436), raddr=('91.189.92.34', 443)>
  return self.fetch_json(endpoint, params, 'get')
/usr/lib/python3/dist-packages/charmworldlib/api.py:18: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=6, laddr=('192.168.1.147', 44128), raddr=('91.189.92.33', 443)>
  return self.fetch_json(endpoint, params, 'get')
EE/usr/lib/python3.4/unittest/case.py:602: ResourceWarning: unclosed <socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=6, laddr=('10.0.3.1', 43307), raddr=('10.0.3.32', 80)>
  outcome.errors.clear()

======================================================================
ERROR: test_1_verify_mysql_rel (__main__.TestDeployment)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/stone/charms/precise/tracks/tests/10-deploy", line 39, in test_1_verify_mysql_rel
    user = tracks_relation['username']
KeyError: 'username'

======================================================================
ERROR: test_2_verify_tracks (__main__.TestDeployment)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/stone/charms/precise/tracks/tests/10-deploy", line 58, in test_2_verify_tracks
    amulet.raise_status(amulet.FAIL, msg=message)
  File "/usr/lib/python3/dist-packages/amulet/helpers.py", line 140, in raise_status
    sys.exit(code)
SystemExit: 1

----------------------------------------------------------------------
Ran 2 tests in 2057.725s

FAILED (errors=2)
private-address 10.0.3.32
private-address 10.0.3.192
user uwofaemaakaimoh
database tracks
password soxeibusahcheal
slave False
host 10.0.3.192
Tracks was not found running on 10.0.3.32

Thanks for your work on improving this charm! Feel free to reach out if you have any questions about my findings.

review: Needs Fixing

Unmerged revisions

8. By José Antonio Rey

Added tests and fixed small bug on install hook

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/install'
2--- hooks/install 2014-07-14 06:23:58 +0000
3+++ hooks/install 2014-11-11 14:17:17 +0000
4@@ -17,7 +17,7 @@
5 libruby sqlite3 libmysql-ruby libmysql-ruby libsqlite3-ruby libsqlite3-dev \
6 imagemagick graphicsmagick libgraphicsmagick1-dev librmagick-ruby \
7 libxslt-dev libxml2-dev pwgen rubygems mysql-client wget ruby2.1-dev \
8-libcap2-bin
9+libcap2-bin git
10
11 juju-log "installing tracks"
12 cd /home/tracks/
13
14=== added directory 'tests'
15=== added file 'tests/00-setup'
16--- tests/00-setup 1970-01-01 00:00:00 +0000
17+++ tests/00-setup 2014-11-11 14:17:17 +0000
18@@ -0,0 +1,5 @@
19+#!/bin/bash
20+
21+sudo add-apt-repository ppa:juju/stable -y
22+sudo apt-get update
23+sudo apt-get install amulet python3-requests -y
24
25=== added file 'tests/10-deploy'
26--- tests/10-deploy 1970-01-01 00:00:00 +0000
27+++ tests/10-deploy 2014-11-11 14:17:17 +0000
28@@ -0,0 +1,64 @@
29+#!/usr/bin/env python3
30+
31+import amulet
32+import requests
33+import unittest
34+
35+
36+class TestDeployment(unittest.TestCase):
37+ @classmethod
38+ def setUpClass(cls):
39+ cls.deployment = amulet.Deployment(series='precise')
40+
41+ cls.deployment.add('tracks')
42+ cls.deployment.add('mysql')
43+ cls.deployment.relate('tracks:db', 'mysql:db')
44+ cls.deployment.expose('tracks')
45+
46+ try:
47+ cls.deployment.setup(timeout=900)
48+ cls.deployment.sentry.wait()
49+ except amulet.helpers.TimeoutError:
50+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up \
51+ in time")
52+ except:
53+ raise
54+ cls.tracksunit = cls.deployment.sentry.unit['tracks/0']
55+ cls.mysqlunit = cls.deployment.sentry.unit['mysql/0']
56+ cls.ipaddr = cls.tracksunit.info['public-address']
57+
58+
59+
60+ def test_1_verify_mysql_rel(self):
61+ tracks_relation = self.tracksunit.relation('db', 'mysql:db')
62+ for key, value in relation.items():
63+ print(key, value)
64+ mysql_relation = self.mysqlunit.relation('db', 'tracks:db')
65+ for key, value in mysql_relation.items():
66+ print(key, value)
67+ user = tracks_relation['username']
68+ mysql_ip = mysql_relation['db_host']
69+ mysql_password = mysql_relation['password']
70+ cmd = 'mysqladmin status -h {0} -u {1} --password={2}'.format(mysql_ip,
71+ mysql_user, mysql_password
72+ output, code = self.tracks_unit.run(cmd)
73+ if code != 0:
74+ message = 'Unable to get MySQL status on %s' % mysql_ip
75+ amulet.raise_status(amulet.FAIL, msg=message)
76+ else:
77+ print('Tracks <-> MySQL relation validated!')
78+
79+ def test_2_verify_tracks(self):
80+ url = 'http://%s/' % self.ipaddr
81+ r = requests.get(url)
82+ text = 'Welcome to TRACKS'
83+
84+ if text not in r:
85+ message = 'Tracks was not found running on %s' self.ipaddr
86+ amulet.raise_status(amulet.FAIL, msg=message)
87+ else:
88+ print('Tracks was found running on %s!' % self.ipaddr)
89+
90+
91+if __name__ == '__main__':
92+ unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: