Merge lp:~lezbar/charms/trusty/midonet-api/trunk into lp:~celebdor/charms/trusty/midonet-api/trunk
- Trusty Tahr (14.04)
- trunk
- Merge into trunk
Proposed by
Antoni Segura Puimedon
Status: | Merged |
---|---|
Approved by: | Antoni Segura Puimedon |
Approved revision: | 14 |
Merged at revision: | 14 |
Proposed branch: | lp:~lezbar/charms/trusty/midonet-api/trunk |
Merge into: | lp:~celebdor/charms/trusty/midonet-api/trunk |
Diff against target: |
404 lines (+283/-102) 4 files modified
tests/010-basic-trusty-juno (+24/-0) tests/011-basic-trusty-kilo (+24/-0) tests/10-basic_deployment_test.py (+0/-102) tests/basic_deployment.py (+235/-0) |
To merge this branch: | bzr merge lp:~lezbar/charms/trusty/midonet-api/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Antoni Segura Puimedon | Approve | ||
Review via email: mp+274845@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'tests/010-basic-trusty-juno' |
2 | --- tests/010-basic-trusty-juno 1970-01-01 00:00:00 +0000 |
3 | +++ tests/010-basic-trusty-juno 2015-10-19 03:45:13 +0000 |
4 | @@ -0,0 +1,24 @@ |
5 | +#!/usr/bin/python |
6 | +# |
7 | +# Copyright (c) 2015 Midokura SARL, All Rights Reserved. |
8 | +# |
9 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
10 | +# you may not use this file except in compliance with the License. |
11 | +# You may obtain a copy of the License at |
12 | +# |
13 | +# http://www.apache.org/licenses/LICENSE-2.0 |
14 | +# |
15 | +# Unless required by applicable law or agreed to in writing, software |
16 | +# distributed under the License is distributed on an "AS IS" BASIS, |
17 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
18 | +# See the License for the specific language governing permissions and |
19 | +# limitations under the License. |
20 | + |
21 | + |
22 | +from basic_deployment import MidonetBasicDeployment |
23 | + |
24 | +if __name__ == '__main__': |
25 | + deployment = MidonetBasicDeployment(ubuntu_series='trusty', |
26 | + openstack='cloud:trusty-juno', |
27 | + midonet_release='juno/midonet-2015.06') |
28 | + deployment.run_tests() |
29 | |
30 | === added file 'tests/011-basic-trusty-kilo' |
31 | --- tests/011-basic-trusty-kilo 1970-01-01 00:00:00 +0000 |
32 | +++ tests/011-basic-trusty-kilo 2015-10-19 03:45:13 +0000 |
33 | @@ -0,0 +1,24 @@ |
34 | +#!/usr/bin/python |
35 | +# |
36 | +# Copyright (c) 2015 Midokura SARL, All Rights Reserved. |
37 | +# |
38 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
39 | +# you may not use this file except in compliance with the License. |
40 | +# You may obtain a copy of the License at |
41 | +# |
42 | +# http://www.apache.org/licenses/LICENSE-2.0 |
43 | +# |
44 | +# Unless required by applicable law or agreed to in writing, software |
45 | +# distributed under the License is distributed on an "AS IS" BASIS, |
46 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
47 | +# See the License for the specific language governing permissions and |
48 | +# limitations under the License. |
49 | + |
50 | + |
51 | +from basic_deployment import MidonetBasicDeployment |
52 | + |
53 | +if __name__ == '__main__': |
54 | + deployment = MidonetBasicDeployment(ubuntu_series='trusty', |
55 | + openstack='cloud:trusty-kilo', |
56 | + midonet_release='kilo/midonet-2015.06') |
57 | + deployment.run_tests() |
58 | |
59 | === removed file 'tests/10-basic_deployment_test.py' |
60 | --- tests/10-basic_deployment_test.py 2015-08-03 18:30:50 +0000 |
61 | +++ tests/10-basic_deployment_test.py 1970-01-01 00:00:00 +0000 |
62 | @@ -1,102 +0,0 @@ |
63 | -#!/usr/bin/env python3 |
64 | -# vim: tabstop=4 shiftwidth=4 softtabstop=4 filetype=python |
65 | -# |
66 | -# Copyright (c) 2015 Midokura Europe SARL, All Rights Reserved. |
67 | -# All Rights Reserved |
68 | -# |
69 | -# Licensed under the Apache License, Version 2.0 (the "License"); you may |
70 | -# not use this file except in compliance with the License. You may obtain |
71 | -# a copy of the License at |
72 | -# |
73 | -# http://www.apache.org/licenses/LICENSE-2.0 |
74 | -# |
75 | -# Unless required by applicable law or agreed to in writing, software |
76 | -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
77 | -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
78 | -# License for the specific language governing permissions and limitations |
79 | -# under the License. |
80 | -import amulet |
81 | - |
82 | -SETUP_TIMEOUT = 9600 |
83 | - |
84 | - |
85 | -deployment = amulet.Deployment(series='trusty') |
86 | -deployment.add('zookeeper', charm='cs:trusty/zookeeper', units=1, |
87 | - series='trusty') |
88 | -deployment.add('keystone', charm='cs:trusty/keystone', units=1, |
89 | - series='trusty') |
90 | -deployment.configure('keystone', {'openstack-origin': 'cloud:trusty-juno'}) |
91 | -deployment.add('mysql', charm='cs:trusty/mysql', units=1, series='trusty') |
92 | -deployment.relate('mysql:shared-db', 'keystone:shared-db') |
93 | - |
94 | -deployment.add('midonet-api', charm='midonet-api', units=1, |
95 | - branch='lp:~celebdor/charms/trusty/midonet-api/trunk', |
96 | - series='trusty') |
97 | - |
98 | -deployment.relate('midonet-api:zookeeper', 'zookeeper:zookeeper') |
99 | -deployment.relate('midonet-api:keystone', 'keystone:identity-admin') |
100 | - |
101 | -mn_version = '2015.01' |
102 | - |
103 | -try: |
104 | - deployment.setup(timeout=SETUP_TIMEOUT) |
105 | - deployment.sentry.wait() |
106 | -except amulet.helpers.TimeoutError: |
107 | - amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time") |
108 | - |
109 | -mn_api_sentry = deployment.sentry.unit['midonet-api/0'] |
110 | -zookeeper_sentry = deployment.sentry.unit['zookeeper/0'] |
111 | -keystone_sentry = deployment.sentry.unit['keystone/0'] |
112 | - |
113 | -zookeeper_relation = zookeeper_sentry.relation('zookeeper', |
114 | - 'midonet-api:zookeeper') |
115 | -keystone_relation = keystone_sentry.relation('identity-admin', |
116 | - 'midonet-api:keystone') |
117 | - |
118 | -# Check the key has been correctly fetched |
119 | -apt_key_out, apt_key_exit = mn_api_sentry.run('apt-key list | grep Midokura') |
120 | -if 'Midokura' not in apt_key_out: |
121 | - message = ("midonet-api error, the repository keys are not installed") |
122 | - amulet.raise_status(amulet.FAIL, msg=message) |
123 | - |
124 | -# Check if midonet-api package has been installed |
125 | -dpkg_api_out, dpkg_exit = mn_api_sentry.run('dpkg -l | grep midonet-api') |
126 | -if 'midonet-api' not in dpkg_api_out: |
127 | - message = ("midonet-api error, the package is not installed") |
128 | - amulet.raise_status(amulet.FAIL, msg=message) |
129 | - |
130 | -# Check if midonetclient package has been installed |
131 | -dpkg_client_out, dpkg_exit = mn_api_sentry.run('dpkg -l | grep midonetclient') |
132 | -if 'python-midonetclient' not in dpkg_client_out: |
133 | - message = ("python-midonetclient error, the package is not installed") |
134 | - amulet.raise_status(amulet.FAIL, msg=message) |
135 | - |
136 | -# Check if tomcat7 is installed and running |
137 | -tomcat7_out, tomcat7_exit = mn_api_sentry.run('service tomcat7 status') |
138 | -if tomcat7_exit == 1: |
139 | - message = ("midonet-api setup error, tomcat7 is not installed") |
140 | - amulet.raise_status(amulet.FAIL, msg=message) |
141 | -if tomcat7_exit == 0: |
142 | - if 'running' not in tomcat7_out: |
143 | - message = ("midonet-api setup error, tomcat7 is not running") |
144 | - amulet.raise_status(amulet.FAIL, msg=message) |
145 | - |
146 | -# Check midonetrc |
147 | -mn_rc_out, mn_rc_exit = mn_api_sentry.run( |
148 | - '[ -f /root/.midonetrc ] && echo \"True\" || echo \"False\"') |
149 | -if 'True' not in mn_rc_out: |
150 | - message = ("error: .midonetrc not found") |
151 | - amulet.raise_status(amulet.FAIL, msg=message) |
152 | -# Check cli |
153 | -cli_out, mn_exit = mn_api_sentry.run('midonet-cli -e create bridge name test') |
154 | -if mn_exit != 0: |
155 | - message = ("midonet-cli error: %s" % cli_out) |
156 | - amulet.raise_status(amulet.FAIL, msg=message) |
157 | - |
158 | -# Check if the bridge has been successfully created |
159 | -cli_out, mn_exit = mn_api_sentry.run('midonet-cli -e bridge list') |
160 | -if 'test' not in cli_out: |
161 | - message = ("midonet-cli error: %s" % cli_out) |
162 | - amulet.raise_status(amulet.FAIL, msg=message) |
163 | - |
164 | -print('midonet-api deploy and install tests completed successfully') |
165 | |
166 | === added file 'tests/basic_deployment.py' |
167 | --- tests/basic_deployment.py 1970-01-01 00:00:00 +0000 |
168 | +++ tests/basic_deployment.py 2015-10-19 03:45:13 +0000 |
169 | @@ -0,0 +1,235 @@ |
170 | +#!/usr/bin/env python3 |
171 | +# vim: tabstop=4 shiftwidth=4 softtabstop=4 filetype=python |
172 | +# |
173 | +# Copyright (c) 2015 Midokura Europe SARL, All Rights Reserved. |
174 | +# All Rights Reserved |
175 | +# |
176 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
177 | +# not use this file except in compliance with the License. You may obtain |
178 | +# a copy of the License at |
179 | +# |
180 | +# http://www.apache.org/licenses/LICENSE-2.0 |
181 | +# |
182 | +# Unless required by applicable law or agreed to in writing, software |
183 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
184 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
185 | +# License for the specific language governing permissions and limitations |
186 | +# under the License. |
187 | +import amulet |
188 | + |
189 | +from charmhelpers.contrib.openstack.amulet.utils import ( |
190 | + OpenStackAmuletUtils, |
191 | + DEBUG, # flake8: noqa |
192 | + ERROR |
193 | +) |
194 | + |
195 | +# Use DEBUG to turn on debug logging |
196 | +u = OpenStackAmuletUtils(DEBUG) |
197 | + |
198 | +SETUP_TIMEOUT = 9600 |
199 | + |
200 | + |
201 | +class MidonetBasicDeployment(): |
202 | + def __init__(self, ubuntu_series, openstack=None, midonet_release=None): |
203 | + self.os_release = openstack |
204 | + self.series = ubuntu_series |
205 | + self.midonet_release = midonet_release |
206 | + self.d = amulet.Deployment(series=self.series) |
207 | + self._add_services() |
208 | + self._add_relations() |
209 | + self._configure_services() |
210 | + self._deploy() |
211 | + self._initialize_tests() |
212 | + |
213 | + def _add_services(self): |
214 | + self.d.add('mysql', charm='cs:trusty/mysql', units=1, |
215 | + series=self.series) |
216 | + self.d.add('rabbitmq-server', charm='cs:trusty/rabbitmq-server', |
217 | + units=1, series=self.series) |
218 | + self.d.add('cassandra', charm='cassandra', units=1, |
219 | + branch='lp:charms/cassandra', series=self.series) |
220 | + self.d.add('keystone', charm='keystone', units=1, series=self.series, |
221 | + branch='lp:~celebdor/charms/trusty/keystone/trunk') |
222 | + self.d.add('nova-compute', charm='nova-compute', units=1, |
223 | + branch='lp:~celebdor/charms/trusty/nova-compute/trunk', |
224 | + series=self.series) |
225 | + self.d.add('neutron-api', charm='neutron-api', units=1, |
226 | + branch='lp:~celebdor/charms/trusty/neutron-api/trunk', |
227 | + series=self.series) |
228 | + self.d.add('nova-cloud-controller', charm='nova-cloud-controller', |
229 | + branch='lp:~celebdor/charms/trusty/nova-cloud-controller/trunk', |
230 | + units=1, series=self.series) |
231 | + self.d.add('zookeeper', charm='cs:trusty/zookeeper', units=1, |
232 | + series=self.series) |
233 | + self.d.add('midonet-api', charm='midonet-api', units=1, |
234 | + branch='lp:~celebdor/charms/trusty/midonet-api/trunk', |
235 | + series=self.series) |
236 | + self.d.add('midonet-agent', charm='midonet-agent', units=1, |
237 | + branch='lp:~celebdor/charms/trusty/midonet-agent/trunk', |
238 | + series=self.series) |
239 | + self.d.add('neutron-agents-midonet', charm='neutron-agents-midonet', |
240 | + branch='lp:~celebdor/charms/trusty/neutron-agents-midonet/trunk', |
241 | + series='trusty') |
242 | + |
243 | + def _add_relations(self): |
244 | + self.d.relate('mysql:shared-db', 'keystone:shared-db') |
245 | + self.d.relate('mysql:shared-db', 'nova-cloud-controller:shared-db') |
246 | + self.d.relate('rabbitmq-server:amqp', 'nova-compute:amqp') |
247 | + self.d.relate('rabbitmq-server:amqp', 'nova-cloud-controller:amqp') |
248 | + self.d.relate('rabbitmq-server:amqp', 'neutron-api:amqp') |
249 | + self.d.relate('nova-cloud-controller:identity-service', |
250 | + 'keystone:identity-service') |
251 | + |
252 | + self.d.relate('neutron-api:identity-service', |
253 | + 'keystone:identity-service') |
254 | + self.d.relate('nova-compute:cloud-compute', |
255 | + 'nova-cloud-controller:cloud-compute') |
256 | + self.d.relate('neutron-api:neutron-api', |
257 | + 'nova-cloud-controller:neutron-api') |
258 | + |
259 | + self.d.relate('keystone:identity-service', 'midonet-api:keystone') |
260 | + self.d.relate('zookeeper:zookeeper', 'midonet-api:zookeeper') |
261 | + self.d.relate('midonet-agent:host', 'midonet-api:host') |
262 | + self.d.relate('neutron-api:midonet', 'midonet-api:midonet-api') |
263 | + |
264 | + self.d.relate('neutron-agents-midonet:neutron_agents', |
265 | + 'nova-cloud-controller:quantum-network-service') |
266 | + |
267 | + self.d.relate('neutron-agents-midonet:neutron-plugin-api', |
268 | + 'neutron-api:neutron-plugin-api') |
269 | + |
270 | + self.d.relate('midonet-agent:neutron-plugin', |
271 | + 'nova-compute:neutron-plugin') |
272 | + |
273 | + self.d.relate('midonet-agent:host', 'neutron-api:midonet-host') |
274 | + self.d.relate('midonet-agent:cassandra', 'cassandra:database') |
275 | + self.d.relate('midonet-agent:zookeeper', 'zookeeper:zookeeper') |
276 | + |
277 | + def _configure_services(self): |
278 | + self.d.configure('keystone', { |
279 | + 'enable-pki': 'false', |
280 | + 'openstack-origin': self.os_release}) |
281 | + |
282 | + self.d.configure('cassandra', { |
283 | + 'allow-single-node': True, |
284 | + 'cluster-name': 'midonet', |
285 | + 'apt-repo-key': '7E41C00F85BFC1706C4FFFB3350200F2B999A372', |
286 | + 'apt-repo-spec': |
287 | + 'deb http://debian.datastax.com/community 2.0 main', |
288 | + 'extra_packages': 'openjdk-7-jre-headless dsc20'}) |
289 | + |
290 | + self.d.configure('mysql', {'max-connections': 2000}) |
291 | + |
292 | + self.d.configure('nova-compute', { |
293 | + 'openstack-origin': self.os_release, |
294 | + 'virt-type': 'qemu', |
295 | + 'flat-interface': 'eth0', |
296 | + 'manage-neutron-plugin-legacy-mode': 'false'}) |
297 | + |
298 | + self.d.configure('nova-cloud-controller', { |
299 | + 'openstack-origin': self.os_release, |
300 | + 'network-manager': 'Neutron', |
301 | + 'shared_secret': 'secret'}) |
302 | + |
303 | + self.d.configure('neutron-api', { |
304 | + 'neutron-plugin': 'midonet', |
305 | + 'neutron-security-groups': 'True', |
306 | + 'neutron-external-network': 'Public_Network', |
307 | + 'l2-population': 'False', |
308 | + 'openstack-origin': self.os_release, |
309 | + 'midonet-release': self.midonet_release}) |
310 | + |
311 | + self.d.configure('midonet-api', |
312 | + {'midonet-release': self.midonet_release}) |
313 | + |
314 | + self.d.configure('neutron-agents-midonet', |
315 | + {'shared_secret': 'secret'}) |
316 | + |
317 | + self.d.configure('midonet-agent', |
318 | + {'midonet-release': self.midonet_release}) |
319 | + |
320 | + def _deploy(self): |
321 | + try: |
322 | + self.d.setup(timeout=SETUP_TIMEOUT) |
323 | + self.d.sentry.wait(timeout=SETUP_TIMEOUT) |
324 | + except amulet.helpers.TimeoutError: |
325 | + amulet.raise_status(amulet.SKIP, |
326 | + msg="Environment wasn't stood up in time") |
327 | + |
328 | + def _initialize_tests(self): |
329 | + self.zookeeper_sentry = self.d.sentry.unit['zookeeper/0'] |
330 | + self.keystone_sentry = self.d.sentry.unit['keystone/0'] |
331 | + self.cassandra_sentry = self.d.sentry.unit['cassandra/0'] |
332 | + self.nova_compute_sentry = self.d.sentry.unit['nova-compute/0'] |
333 | + self.mn_api_sentry = self.d.sentry.unit['midonet-api/0'] |
334 | + self.mn_agent_sentry = self.d.sentry.unit['midonet-agent/0'] |
335 | + self.agents_mn_sentry = self.d.sentry.unit['neutron-agents-midonet/0'] |
336 | + |
337 | + self.keystone_api_relation = self.keystone_sentry.relation( |
338 | + 'identity-service', 'midonet-api:keystone') |
339 | + self.zookeeper_api_relation = self.zookeeper_sentry.relation( |
340 | + 'zookeeper', 'midonet-api:zookeeper') |
341 | + self.zk_host_relation = self.zookeeper_sentry.relation( |
342 | + 'zookeeper', 'midonet-agent:zookeeper') |
343 | + self.cs_host_relation = self.cassandra_sentry.relation( |
344 | + 'database', 'midonet-agent:cassandra') |
345 | + self.api_host_relation = self.mn_api_sentry.relation( |
346 | + 'host', 'midonet-agent:host') |
347 | + |
348 | + def run_tests(self): |
349 | + for test in dir(self): |
350 | + if test.startswith('test_'): |
351 | + getattr(self, test)() |
352 | + |
353 | + def test_mn_api(self): |
354 | + u.log.debug('Checking if the repo key has been correctly fetched...') |
355 | + apt_key_out, apt_key_exit = self.mn_agent_sentry.run( |
356 | + 'apt-key list | grep Midokura') |
357 | + if 'Midokura' not in apt_key_out: |
358 | + message = ("error, Midokura repository key is not installed") |
359 | + amulet.raise_status(amulet.FAIL, msg=message) |
360 | + |
361 | + u.log.debug('Checking if midonet-api package has been installed...') |
362 | + dpkg_api_out, dpkg_exit = self.mn_api_sentry.run( |
363 | + 'dpkg -l | grep midonet-api') |
364 | + if 'midonet-api' not in dpkg_api_out: |
365 | + message = ("error: midonet-api package is not installed") |
366 | + amulet.raise_status(amulet.FAIL, msg=message) |
367 | + |
368 | + u.log.debug('Checking if midonetclient package has been installed...') |
369 | + dpkg_client_out, dpkg_exit = self.mn_api_sentry.run( |
370 | + 'dpkg -l | grep midonetclient') |
371 | + if 'python-midonetclient' not in dpkg_client_out: |
372 | + message = ("error: python-midonetclient package is not installed") |
373 | + amulet.raise_status(amulet.FAIL, msg=message) |
374 | + |
375 | + u.log.debug('Checking if tomcat7 is installed and running...') |
376 | + tomcat7_out, tomcat7_exit = self.mn_api_sentry.run( |
377 | + 'service tomcat7 status') |
378 | + if tomcat7_exit == 1: |
379 | + message = ("midonet-api setup error, tomcat7 is not installed") |
380 | + amulet.raise_status(amulet.FAIL, msg=message) |
381 | + if tomcat7_exit == 0: |
382 | + if 'running' not in tomcat7_out: |
383 | + message = ("midonet-api setup error, tomcat7 is not running") |
384 | + amulet.raise_status(amulet.FAIL, msg=message) |
385 | + |
386 | + u.log.debug('Checking if midonetrc exists...') |
387 | + mn_rc_out, mn_rc_exit = self.mn_api_sentry.run( |
388 | + '[ -f /root/.midonetrc ] && echo \"True\" || echo \"False\"') |
389 | + if 'True' not in mn_rc_out: |
390 | + message = ("error: .midonetrc not found") |
391 | + amulet.raise_status(amulet.FAIL, msg=message) |
392 | + |
393 | + u.log.debug('Checking midonet-cli...') |
394 | + cli_out, mn_exit = self.mn_api_sentry.run( |
395 | + 'midonet-cli -e create bridge name test') |
396 | + if mn_exit != 0: |
397 | + message = ("midonet-cli error: %s" % cli_out) |
398 | + amulet.raise_status(amulet.FAIL, msg=message) |
399 | + |
400 | + u.log.debug('Checking if the bridge has been successfully created...') |
401 | + cli_out, mn_exit = self.mn_api_sentry.run('midonet-cli -e bridge list') |
402 | + if 'test' not in cli_out: |
403 | + message = ("midonet-cli error: %s" % cli_out) |
404 | + amulet.raise_status(amulet.FAIL, msg=message) |
Looks good. Thanks Lucas!