Merge lp:~nicopace/charms/trusty/zookeeper/all-tests into lp:charms/trusty/zookeeper

Proposed by nicopace
Status: Merged
Merge reported by: nicopace
Merged at revision: not available
Proposed branch: lp:~nicopace/charms/trusty/zookeeper/all-tests
Merge into: lp:charms/trusty/zookeeper
Diff against target: 214 lines (+180/-1)
6 files modified
tests/00-setup (+3/-1)
tests/11-basic-test.py (+34/-0)
tests/12-change-port.py (+29/-0)
tests/13-install-source.py (+41/-0)
tests/14-scale-test.py (+40/-0)
tests/18-zookeeper-relation.py (+33/-0)
To merge this branch: bzr merge lp:~nicopace/charms/trusty/zookeeper/all-tests
Reviewer Review Type Date Requested Status
Cory Johns (community) Approve
charmers Pending
Review via email: mp+251313@code.launchpad.net

Description of the change

All zookeeper tests into one branch:
* basic test
* install source
* scale test
* change port
* zookeeper relation

To post a comment you must log in.
Revision history for this message
amir sanjar (asanjar) wrote :

good job, merging new testcases to hdp-zookeer and future apache-zookeeper, as this charm will be deprecated and removed from charmstore soon.

Revision history for this message
Cory Johns (johnsca) wrote :

Ok, the additional tests from this branch have been merged into lp:charms/trusty/hdp-zookeeper so this MP can be closed.

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-10-29 16:21:18 +0000
3+++ tests/00-setup 2015-02-27 19:03:05 +0000
4@@ -13,4 +13,6 @@
5 fi
6
7 # Install any additional python packages or other required software.
8-sudo apt-get install -y python3-requests
9\ No newline at end of file
10+sudo apt-get install -y python3-requests
11+
12+easy_install3 install kazoo
13
14=== added file 'tests/11-basic-test.py'
15--- tests/11-basic-test.py 1970-01-01 00:00:00 +0000
16+++ tests/11-basic-test.py 2015-02-27 19:03:05 +0000
17@@ -0,0 +1,34 @@
18+#!/usr/bin/python3
19+
20+import amulet
21+from kazoo.client import KazooClient
22+
23+seconds = 20000
24+
25+d = amulet.Deployment(series='trusty')
26+
27+d.add('zookeeper')
28+
29+d.expose('zookeeper')
30+
31+try:
32+ d.setup(timeout=seconds)
33+except amulet.helpers.TimeoutError:
34+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
35+except:
36+ raise
37+
38+unit = d.sentry.unit['zookeeper/0']
39+
40+zk = KazooClient(hosts='%s:2181' % unit.info['public_address'])
41+zk.start()
42+writevalue = b"a value"
43+zk.create("/nodea", writevalue)
44+readvalue, stat = zk.get("/nodea")
45+
46+if writevalue != readvalue:
47+ amulet.raise_status(amulet.FAIL,
48+ msg='Error in Zookeeper server,'
49+ ' read different to write'
50+ 'write: %s, read: %s' % (writevalue, readvalue))
51+zk.stop()
52
53=== added file 'tests/12-change-port.py'
54--- tests/12-change-port.py 1970-01-01 00:00:00 +0000
55+++ tests/12-change-port.py 2015-02-27 19:03:05 +0000
56@@ -0,0 +1,29 @@
57+#!/usr/bin/python3
58+
59+import amulet
60+from kazoo.client import KazooClient
61+
62+seconds = 20000
63+
64+d = amulet.Deployment(series='trusty')
65+
66+d.add('zookeeper')
67+d.configure('zookeeper', {
68+ 'zk-port': 8888
69+})
70+
71+d.expose('zookeeper')
72+
73+try:
74+ d.setup(timeout=seconds)
75+except amulet.helpers.TimeoutError:
76+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
77+except:
78+ raise
79+
80+
81+unit = d.sentry.unit['zookeeper/0']
82+
83+zk = KazooClient(hosts='%s:8888' % unit.info['public_address'])
84+zk.start()
85+zk.stop()
86
87=== added file 'tests/13-install-source.py'
88--- tests/13-install-source.py 1970-01-01 00:00:00 +0000
89+++ tests/13-install-source.py 2015-02-27 19:03:05 +0000
90@@ -0,0 +1,41 @@
91+#!/usr/bin/python3
92+
93+import amulet
94+from kazoo.client import KazooClient
95+from kazoo.interfaces.IHandler import timeout_exception
96+
97+seconds = 20000
98+
99+d = amulet.Deployment(series='trusty')
100+
101+d.add('zookeeper')
102+
103+d.expose('zookeeper')
104+
105+try:
106+ d.setup(timeout=seconds)
107+except amulet.helpers.TimeoutError:
108+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
109+except:
110+ raise
111+
112+
113+sources = ['archive', 'dev', 'testing', 'stable']
114+
115+unit = d.sentry.unit['zookeeper/0']
116+
117+for source in sources:
118+ d.configure('zookeeper', {
119+ 'source', source
120+ })
121+
122+ d.sentry.wait()
123+
124+ zk = KazooClient(hosts='%s:2181' % unit.info['public_address'])
125+ try:
126+ zk.start()
127+ zk.stop()
128+ except timeout_exception:
129+ amulet.raise_status(amulet.FAIL,
130+ msg='Package %s doesn\'t work'
131+ ' as expected' % source)
132
133=== added file 'tests/14-scale-test.py'
134--- tests/14-scale-test.py 1970-01-01 00:00:00 +0000
135+++ tests/14-scale-test.py 2015-02-27 19:03:05 +0000
136@@ -0,0 +1,40 @@
137+#!/usr/bin/python3
138+
139+from time import sleep
140+
141+import amulet
142+from kazoo.client import KazooClient
143+
144+seconds = 20000
145+
146+d = amulet.Deployment(series='trusty')
147+
148+d.add('zookeeper', units=3)
149+
150+d.expose('zookeeper')
151+
152+try:
153+ d.setup(timeout=seconds)
154+except amulet.helpers.TimeoutError:
155+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
156+except:
157+ raise
158+
159+unit1 = d.sentry.unit['zookeeper/0']
160+unit2 = d.sentry.unit['zookeeper/1']
161+
162+zk = KazooClient(hosts='%s:2181' % unit1.info['public_address'])
163+zk.start()
164+writevalue = b"a value"
165+zk.create("/nodea", writevalue)
166+zk.stop()
167+
168+sleep(2)
169+
170+zk = KazooClient(hosts='%s:2181' % unit2.info['public_address'])
171+readvalue, stat = zk.get("/nodea")
172+if writevalue != readvalue:
173+ amulet.raise_status(amulet.FAIL,
174+ msg='Error in Zookeeper server,'
175+ ' read different to write'
176+ 'write: %s, read: %s' % (writevalue, readvalue))
177
178=== added file 'tests/18-zookeeper-relation.py'
179--- tests/18-zookeeper-relation.py 1970-01-01 00:00:00 +0000
180+++ tests/18-zookeeper-relation.py 2015-02-27 19:03:05 +0000
181@@ -0,0 +1,33 @@
182+#!/usr/bin/python3
183+
184+import amulet
185+
186+seconds = 20000
187+
188+d = amulet.Deployment(series='trusty')
189+
190+d.add('zookeeper')
191+d.add('kafka')
192+d.relate('kafka:zk', 'zookeeper:zookeeper')
193+
194+try:
195+ d.setup(timeout=seconds)
196+except amulet.helpers.TimeoutError:
197+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
198+except:
199+ raise
200+
201+zookeeper_unit = d.sentry.unit['zookeeper/0']
202+kafka_unit = d.sentry.unit['kafka/o']
203+
204+create_result, create_code = kafka_unit.run(
205+ "./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181"
206+ " --create --topic my_topic_name --partitions 5 --replication-factor 1")
207+
208+list_result, list_code = kafka_unit.run(
209+ "./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list")
210+
211+if 'my_topic_name' not in list_result:
212+ amulet.raise_status(amulet.FAIL,
213+ 'zookeeper relation not working properly '
214+ 'between zookeeper and kafka.')

Subscribers

People subscribed via source and target branches

to all changes: