Merge lp:~gnuoy/openstack-mojo-specs/tempest-stable-spec into lp:openstack-mojo-specs

Proposed by Liam Young
Status: Merged
Merged at revision: 291
Proposed branch: lp:~gnuoy/openstack-mojo-specs/tempest-stable-spec
Merge into: lp:openstack-mojo-specs
Diff against target: 359 lines (+188/-6)
11 files modified
Makefile (+1/-1)
helper/bundles/full.yaml (+17/-0)
helper/collect/collect-stable-xenial (+2/-0)
helper/scripts/mojo-spec-check.py (+1/-0)
helper/setup/git_checkout_stable.py (+1/-1)
helper/setup/tempest_expected_results.yaml (+2/-0)
helper/setup/tempest_test.py (+90/-0)
helper/utils/mojo_os_utils.py (+8/-4)
helper/utils/mojo_utils.py (+37/-0)
specs/full_stack/stable_deploy_tempest/newton/SPEC_INFO.txt (+2/-0)
specs/full_stack/stable_deploy_tempest/newton/manifest (+27/-0)
To merge this branch: bzr merge lp:~gnuoy/openstack-mojo-specs/tempest-stable-spec
Reviewer Review Type Date Requested Status
Alex Kavanagh Approve
Review via email: mp+315760@code.launchpad.net
To post a comment you must log in.
290. By Liam Young

Action fixes

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

Looks great. Just a single comment that might help with readability.

291. By Liam Young

Update for readability post-review

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

LGTM. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-07-21 04:32:11 +0000
3+++ Makefile 2017-02-06 14:16:58 +0000
4@@ -4,7 +4,7 @@
5 lint:
6 @./helper/scripts/check-lint.sh
7 @echo Checking lint...
8- @flake8 -v helper/collect helper/setup helper/tests helper/utils
9+ @pep8 -v helper/collect helper/setup helper/tests helper/utils
10
11 gen_spec_summary:
12 @./helper/scripts/gen-spec-summary.sh > SPEC_SUMMARY.txt
13
14=== modified file 'helper/bundles/full.yaml'
15--- helper/bundles/full.yaml 2016-10-06 08:56:04 +0000
16+++ helper/bundles/full.yaml 2017-02-06 14:16:58 +0000
17@@ -49,6 +49,7 @@
18 constraints: mem=4G
19 options:
20 instance-mtu: 1300
21+ bridge-mappings: physnet1:br-ex
22 cinder:
23 charm: cinder
24 options:
25@@ -94,6 +95,9 @@
26 mongodb:
27 charm: mongodb
28 constraints: mem=1G
29+ tempest:
30+ charm: tempest
31+ constraints: mem=1G
32 relations:
33 - [ keystone, mysql ]
34 - [ nova-cloud-controller, mysql ]
35@@ -126,6 +130,7 @@
36 - [ ceilometer, mongodb ]
37 - [ ceilometer-agent, nova-compute ]
38 - [ ceilometer-agent, ceilometer ]
39+ - [ keystone, tempest ]
40 openstack-singlerabbit:
41 inherits: openstack-services
42 relations:
43@@ -280,3 +285,15 @@
44 overrides:
45 source: proposed
46 openstack-origin: distro-proposed
47+# newton
48+xenial-newton:
49+ inherits: openstack-icehouse
50+ series: xenial
51+ overrides:
52+ openstack-origin: cloud:xenial-newton
53+ source: cloud:xenial-newton
54+xenial-newton-proposed:
55+ inherits: xenial-newton
56+ overrides:
57+ openstack-origin: cloud:xenial-newton/proposed
58+ source: cloud:xenial-newton/proposed
59
60=== modified file 'helper/collect/collect-stable-xenial'
61--- helper/collect/collect-stable-xenial 2016-04-12 08:43:49 +0000
62+++ helper/collect/collect-stable-xenial 2017-02-06 14:16:58 +0000
63@@ -19,3 +19,5 @@
64 rabbitmq-server git://github.com/openstack/charm-rabbitmq-server
65 swift-proxy git://github.com/openstack/charm-swift-proxy
66 swift-storage git://github.com/openstack/charm-swift-storage
67+# There is no promulgated tempest charm atm
68+tempest cs:~openstack-charmers-next/tempest
69
70=== modified file 'helper/scripts/mojo-spec-check.py'
71--- helper/scripts/mojo-spec-check.py 2016-09-22 21:25:04 +0000
72+++ helper/scripts/mojo-spec-check.py 2017-02-06 14:16:58 +0000
73@@ -15,6 +15,7 @@
74 'images.yaml': 'image_setup.py',
75 'keystone_users.yaml': 'keystone_setup.py',
76 'network.yaml': 'network_setup.py',
77+ 'tempest_expected_results.yaml': 'tempest_test.py',
78 }
79
80
81
82=== modified file 'helper/setup/git_checkout_stable.py'
83--- helper/setup/git_checkout_stable.py 2016-09-13 14:03:22 +0000
84+++ helper/setup/git_checkout_stable.py 2017-02-06 14:16:58 +0000
85@@ -7,7 +7,7 @@
86 def main(argv):
87 log = logging.getLogger()
88 log.setLevel(logging.DEBUG)
89- mojo_utils.git_checkout_all('stable/16.07')
90+ mojo_utils.git_checkout_all('stable/16.10')
91
92 if __name__ == "__main__":
93 sys.exit(main(sys.argv))
94
95=== added file 'helper/setup/tempest_expected_results.yaml'
96--- helper/setup/tempest_expected_results.yaml 1970-01-01 00:00:00 +0000
97+++ helper/setup/tempest_expected_results.yaml 2017-02-06 14:16:58 +0000
98@@ -0,0 +1,2 @@
99+smoke:
100+ failed: 0
101
102=== added file 'helper/setup/tempest_test.py'
103--- helper/setup/tempest_test.py 1970-01-01 00:00:00 +0000
104+++ helper/setup/tempest_test.py 2017-02-06 14:16:58 +0000
105@@ -0,0 +1,90 @@
106+#!/usr/bin/python
107+import sys
108+import utils.mojo_utils as mojo_utils
109+import utils.mojo_os_utils as mojo_os_utils
110+import logging
111+
112+
113+class TempestRunException(Exception):
114+ pass
115+
116+
117+def raise_tempest_fail(msg):
118+ logging.error(msg)
119+ raise TempestRunException(msg)
120+
121+
122+def report_success(msg):
123+ logging.debug(msg)
124+
125+
126+def warn(msg):
127+ logging.warning(msg)
128+
129+
130+def keystone_v3_domain_setup():
131+ overcloud_novarc = mojo_utils.get_overcloud_auth()
132+ if overcloud_novarc.get('API_VERSION', 2) == 3:
133+ keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc)
134+ keystone_client = mojo_os_utils.get_keystone_session_client(
135+ keystone_session)
136+ mojo_os_utils.project_create(keystone_client,
137+ ['admin'],
138+ 'admin_domain')
139+ admin_project_id = mojo_os_utils.get_tenant_id(
140+ keystone_client,
141+ 'admin',
142+ api_version=3,
143+ domain_name='admin_domain')
144+ role = keystone_client.roles.find(name='admin')
145+ user = keystone_client.users.find(name='admin')
146+ keystone_client.roles.grant(role, user=user, project=admin_project_id)
147+
148+
149+def main(argv):
150+ # Tempest expects an admin project in the admin domain that the admin user
151+ # has admin role on so make sure that exists (pre-17.02)
152+ keystone_v3_domain_setup()
153+
154+ expected_results = mojo_utils.get_mojo_config(
155+ 'tempest_expected_results.yaml')['smoke']
156+ tempest_unit = mojo_utils.get_juju_units(service='tempest')
157+ action_id = mojo_utils.action_run(
158+ tempest_unit[0],
159+ 'run-tempest',
160+ timeout=18000)
161+ action_output = mojo_utils.action_get_output(action_id)
162+ logging.debug(action_output)
163+ actual_results = action_output['results']
164+
165+ result_matrix = {
166+ 'failed': {
167+ 'on_more': raise_tempest_fail,
168+ 'on_less': report_success},
169+ 'skipped': {
170+ 'on_more': warn,
171+ 'on_less': report_success},
172+ 'expected-fail': {
173+ 'on_more': raise_tempest_fail,
174+ 'on_less': report_success},
175+ 'unexpected-success': {
176+ 'on_more': report_success,
177+ 'on_less': warn},
178+ 'passed': {
179+ 'on_more': report_success,
180+ 'on_less': raise_tempest_fail}}
181+
182+ for result_type, expected in expected_results.items():
183+ actual = actual_results[result_type]
184+ msg = "Number of tests {} was {} expected {}".format(result_type,
185+ actual,
186+ expected)
187+ if int(actual) > expected:
188+ result_matrix[result_type]['on_more'](msg)
189+ elif int(actual) == expected:
190+ report_success(msg)
191+ else:
192+ result_matrix[result_type]['on_less'](msg)
193+
194+if __name__ == "__main__":
195+ sys.exit(main(sys.argv))
196
197=== modified file 'helper/utils/mojo_os_utils.py'
198--- helper/utils/mojo_os_utils.py 2016-07-22 09:24:59 +0000
199+++ helper/utils/mojo_os_utils.py 2017-02-06 14:16:58 +0000
200@@ -128,6 +128,7 @@
201 endpoint_type='publicURL')
202 else:
203 keystone_creds = get_ks_creds(novarc_creds, scope='PROJECT')
204+ logging.info(keystone_creds)
205 kc = keystoneclient_v3.Client(**keystone_creds)
206 glance_svc_id = kc.services.find(name='glance').id
207 ep = kc.endpoints.find(service_id=glance_svc_id, interface='public')
208@@ -262,11 +263,14 @@
209 tenant_id)
210
211
212-def get_tenant_id(ks_client, tenant_name, api_version=2):
213+def get_tenant_id(ks_client, tenant_name, api_version=2, domain_name=None):
214+ domain_id = None
215+ if domain_name:
216+ domain_id = ks_client.domains.list(name=domain_name)[0].id
217 if api_version == 2:
218 all_tenants = ks_client.tenants.list()
219 else:
220- all_tenants = ks_client.projects.list()
221+ all_tenants = ks_client.projects.list(domain=domain_id)
222 for t in all_tenants:
223 if t._info['name'] == tenant_name:
224 return t._info['id']
225@@ -574,8 +578,8 @@
226 nics = [{'net-id': net.id}]
227 # Obviously time may not produce a unique name
228 vm_name = time.strftime("%Y%m%d%H%M%S")
229- logging.info('Creating %s %s '
230- 'instance %s' % (flavor_name, image_name, vm_name))
231+ logging.info('Creating %s %s %s'
232+ 'instance %s' % (flavor_name, image_name, nics, vm_name))
233 instance = nova_client.servers.create(name=vm_name,
234 image=image,
235 flavor=flavor,
236
237=== modified file 'helper/utils/mojo_utils.py'
238--- helper/utils/mojo_utils.py 2016-04-17 04:45:43 +0000
239+++ helper/utils/mojo_utils.py 2017-02-06 14:16:58 +0000
240@@ -16,6 +16,12 @@
241 'allocating'],
242 }
243
244+JUJU_ACTION_STATUSES = {
245+ 'good': ['completed'],
246+ 'bad': ['fail'],
247+ 'transitional': ['pending', 'running'],
248+}
249+
250
251 def get_juju_status(service=None, unit=None):
252 cmd = ['juju', 'status', '--format=yaml']
253@@ -643,3 +649,34 @@
254 consoleHandler = logging.StreamHandler()
255 consoleHandler.setFormatter(logFormatter)
256 rootLogger.addHandler(consoleHandler)
257+
258+
259+def action_get_output(action_id):
260+ cmd = ['juju', 'action', 'fetch', '--format=yaml', action_id]
261+ return yaml.load(subprocess.check_output(cmd))
262+
263+
264+def action_get_status(action_id):
265+ return action_get_output(action_id)['status']
266+
267+
268+def action_wait(action_id, timeout=600):
269+ delay = 10
270+ run_time = 0
271+ while run_time < timeout:
272+ status = action_get_status(action_id)
273+ if status not in JUJU_ACTION_STATUSES['transitional']:
274+ break
275+ time.sleep(delay)
276+ run_time = run_time + delay
277+
278+
279+def action_run(unit, action_name, action_args=None, timeout=600):
280+ cmd = ['juju', 'action', 'do', '--format=yaml', unit, action_name]
281+ if action_args:
282+ cmd.extend(action_args)
283+ action_out = yaml.load(subprocess.check_output(cmd))
284+ action_id = action_out['Action queued with id']
285+ if timeout:
286+ action_wait(action_id, timeout)
287+ return action_id
288
289=== added directory 'specs/full_stack/stable_deploy_tempest'
290=== added directory 'specs/full_stack/stable_deploy_tempest/newton'
291=== added file 'specs/full_stack/stable_deploy_tempest/newton/SPEC_INFO.txt'
292--- specs/full_stack/stable_deploy_tempest/newton/SPEC_INFO.txt 1970-01-01 00:00:00 +0000
293+++ specs/full_stack/stable_deploy_tempest/newton/SPEC_INFO.txt 2017-02-06 14:16:58 +0000
294@@ -0,0 +1,2 @@
295+This spec performs a non-ha deploy using the stable charms and then runs tests
296+to validate the deployment
297
298=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/check_juju.py'
299=== target is u'../../../../helper/tests/check_juju.py'
300=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/collect-stable-xenial'
301=== target is u'../../../../helper/collect/collect-stable-xenial'
302=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/collect-stable-yakkety'
303=== target is u'../../../../helper/collect/collect-stable-yakkety'
304=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/full.yaml'
305=== target is u'../../../../helper/bundles/full.yaml'
306=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/git_checkout_stable.py'
307=== target is u'../../../../helper/setup/git_checkout_stable.py'
308=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/image_setup.py'
309=== target is u'../../../../helper/setup/image_setup.py'
310=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/images.yaml'
311=== target is u'../../../../helper/setup/images.yaml'
312=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/keystone_setup.py'
313=== target is u'../../../../helper/setup/keystone_setup.py'
314=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/keystone_users.yaml'
315=== target is u'../../../../helper/setup/keystone_users.yaml'
316=== added file 'specs/full_stack/stable_deploy_tempest/newton/manifest'
317--- specs/full_stack/stable_deploy_tempest/newton/manifest 1970-01-01 00:00:00 +0000
318+++ specs/full_stack/stable_deploy_tempest/newton/manifest 2017-02-06 14:16:58 +0000
319@@ -0,0 +1,27 @@
320+# Collect the charm branches from Launchpad
321+collect config=collect-stable-${MOJO_SERIES}
322+
323+# Checkout stable
324+script config=git_checkout_stable.py
325+
326+
327+# Use juju deployer with full.yaml bundle
328+deploy config=full.yaml delay=0 wait=True target=${MOJO_SERIES}-newton
329+
330+# Check juju statuses are green and that hooks have finished
331+verify config=check_juju.py
332+
333+# Create sdn on overcloud
334+script config=network_setup.py
335+
336+# Setup glance images
337+script config=image_setup.py
338+
339+# Setup keystone users
340+script config=keystone_setup.py
341+
342+# Create 1 * tiny cirros and 1 * small precise instances on the overcloud
343+verify config=simple_os_checks.py MACHINES='cirros:m1.tiny:1 precise:m1.small:1' CLOUDINIT_WAIT="300"
344+
345+verify config=tempest_test.py
346+# Success
347
348=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/network.yaml'
349=== target is u'../../../../helper/setup/network.yaml'
350=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/network_setup.py'
351=== target is u'../../../../helper/setup/network_setup.py'
352=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/simple_os_checks.py'
353=== target is u'../../../../helper/tests/simple_os_checks.py'
354=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/tempest_expected_results.yaml'
355=== target is u'../../../../helper/setup/tempest_expected_results.yaml'
356=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/tempest_test.py'
357=== target is u'../../../../helper/setup/tempest_test.py'
358=== added symlink 'specs/full_stack/stable_deploy_tempest/newton/utils'
359=== target is u'../../../../helper/utils'

Subscribers

People subscribed via source and target branches