3 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
5 # This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
12 Snaps test suite including openstack client tests, api tests and
14 add_openstack_client_tests: for connection_check
15 add_openstack_api_tests: for api_check
16 add_openstack_integration_tests: for snaps_smoke
21 from snaps.openstack.tests.create_flavor_tests import (
23 from snaps.openstack.tests.create_image_tests import (
24 CreateImageSuccessTests, CreateImageNegativeTests,
25 CreateMultiPartImageTests)
26 from snaps.openstack.tests.create_instance_tests import (
27 CreateInstanceOnComputeHost,
28 CreateInstanceSimpleTests, InstanceSecurityGroupTests,
29 CreateInstancePortManipulationTests, SimpleHealthCheck,
30 CreateInstanceFromThreePartImage, CreateInstanceTwoNetTests,
31 CreateInstanceVolumeTests)
32 from snaps.openstack.tests.create_keypairs_tests import (
33 CreateKeypairsTests, CreateKeypairsCleanupTests)
34 from snaps.openstack.tests.create_network_tests import (
35 CreateNetworkSuccessTests)
36 from snaps.openstack.tests.create_project_tests import (
37 CreateProjectSuccessTests, CreateProjectUserTests)
38 from snaps.openstack.tests.create_qos_tests import (
40 # from snaps.openstack.tests.create_router_tests import
41 # CreateRouterSuccessTests
42 from snaps.openstack.tests.create_router_tests import CreateRouterNegativeTests
43 from snaps.openstack.tests.create_security_group_tests import (
44 CreateSecurityGroupTests)
45 from snaps.openstack.tests.create_stack_tests import (
46 CreateStackSuccessTests, CreateStackNegativeTests,
47 CreateStackFlavorTests,
48 CreateStackKeypairTests, CreateStackVolumeTests,
49 CreateStackSecurityGroupTests)
50 from snaps.openstack.tests.create_user_tests import (
51 CreateUserSuccessTests)
52 from snaps.openstack.tests.create_volume_tests import (
53 CreateSimpleVolumeSuccessTests,
54 CreateVolumeWithTypeTests, CreateVolumeWithImageTests,
55 CreateSimpleVolumeFailureTests)
56 from snaps.openstack.tests.create_volume_type_tests import (
57 CreateSimpleVolumeTypeSuccessTests,
58 CreateVolumeTypeComplexTests)
59 from snaps.openstack.tests.os_source_file_test import (
60 OSComponentTestCase, OSIntegrationTestCase)
61 from snaps.openstack.utils.tests.cinder_utils_tests import (
62 CinderSmokeTests, CinderUtilsQoSTests, CinderUtilsSimpleVolumeTypeTests,
63 CinderUtilsAddEncryptionTests, CinderUtilsVolumeTypeCompleteTests,
64 CinderUtilsVolumeTests)
65 from snaps.openstack.utils.tests.glance_utils_tests import (
66 GlanceSmokeTests, GlanceUtilsTests)
67 from snaps.openstack.utils.tests.heat_utils_tests import (
68 HeatSmokeTests, HeatUtilsCreateSimpleStackTests,
70 HeatUtilsKeypairTests, HeatUtilsSecurityGroupTests)
71 from snaps.openstack.utils.tests.keystone_utils_tests import (
72 KeystoneSmokeTests, KeystoneUtilsTests)
73 from snaps.openstack.utils.tests.neutron_utils_tests import (
74 NeutronSmokeTests, NeutronUtilsNetworkTests, NeutronUtilsSubnetTests,
75 NeutronUtilsRouterTests, NeutronUtilsSecurityGroupTests,
76 NeutronUtilsFloatingIpTests)
77 from snaps.openstack.utils.tests.nova_utils_tests import (
78 NovaSmokeTests, NovaUtilsKeypairTests, NovaUtilsFlavorTests,
79 NovaUtilsInstanceTests, NovaUtilsInstanceVolumeTests)
80 from snaps.provisioning.tests.ansible_utils_tests import (
81 AnsibleProvisioningTests)
84 def add_openstack_client_tests(suite, os_creds, ext_net_name,
85 use_keystone=True, log_level=logging.INFO):
87 Adds tests written to exercise OpenStack client retrieval
89 :param suite: the unittest.TestSuite object to which to add the tests
90 :param os_creds: and instance of OSCreds that holds the credentials
92 :param ext_net_name: the name of an external network on the cloud under
94 :param use_keystone: when True, tests requiring direct access to Keystone
95 are added as these need to be running on a host that
96 has access to the cloud's private network
97 :param log_level: the logging level
98 :return: None as the tests will be adding to the 'suite' parameter object
100 # Basic connection tests
102 OSComponentTestCase.parameterize(
103 GlanceSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
104 log_level=log_level))
108 OSComponentTestCase.parameterize(
109 KeystoneSmokeTests, os_creds=os_creds,
110 ext_net_name=ext_net_name, log_level=log_level))
113 OSComponentTestCase.parameterize(
114 NeutronSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
115 log_level=log_level))
117 OSComponentTestCase.parameterize(
118 NovaSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
119 log_level=log_level))
121 OSComponentTestCase.parameterize(
122 HeatSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
123 log_level=log_level))
125 OSComponentTestCase.parameterize(
126 CinderSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
127 log_level=log_level))
130 def add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone=True,
131 image_metadata=None, log_level=logging.INFO):
132 # pylint: disable=too-many-arguments
134 Adds tests written to exercise all existing OpenStack APIs
136 :param suite: the unittest.TestSuite object to which to add the tests
137 :param os_creds: Instance of OSCreds that holds the credentials
138 required by OpenStack
139 :param ext_net_name: the name of an external network on the cloud under
141 :param use_keystone: when True, tests requiring direct access to Keystone
142 are added as these need to be running on a host that
143 has access to the cloud's private network
144 :param image_metadata: dict() object containing metadata for creating an
145 image with custom config
146 (see YAML files in examples/image-metadata)
147 :param log_level: the logging level
148 :return: None as the tests will be adding to the 'suite' parameter object
150 # Tests the OpenStack API calls
152 suite.addTest(OSComponentTestCase.parameterize(
153 KeystoneUtilsTests, os_creds=os_creds, ext_net_name=ext_net_name,
154 log_level=log_level))
155 suite.addTest(OSComponentTestCase.parameterize(
156 CreateUserSuccessTests, os_creds=os_creds,
157 ext_net_name=ext_net_name, log_level=log_level))
158 suite.addTest(OSComponentTestCase.parameterize(
159 CreateProjectSuccessTests, os_creds=os_creds,
160 ext_net_name=ext_net_name, log_level=log_level))
161 suite.addTest(OSComponentTestCase.parameterize(
162 CreateProjectUserTests, os_creds=os_creds,
163 ext_net_name=ext_net_name, log_level=log_level))
165 suite.addTest(OSComponentTestCase.parameterize(
166 GlanceUtilsTests, os_creds=os_creds, ext_net_name=ext_net_name,
167 image_metadata=image_metadata,
168 log_level=log_level))
169 suite.addTest(OSComponentTestCase.parameterize(
170 NeutronUtilsNetworkTests, os_creds=os_creds, ext_net_name=ext_net_name,
171 log_level=log_level))
172 suite.addTest(OSComponentTestCase.parameterize(
173 NeutronUtilsSubnetTests, os_creds=os_creds, ext_net_name=ext_net_name,
174 log_level=log_level))
175 suite.addTest(OSComponentTestCase.parameterize(
176 NeutronUtilsRouterTests, os_creds=os_creds, ext_net_name=ext_net_name,
177 log_level=log_level))
178 suite.addTest(OSComponentTestCase.parameterize(
179 NeutronUtilsSecurityGroupTests, os_creds=os_creds,
180 ext_net_name=ext_net_name, log_level=log_level))
181 suite.addTest(OSComponentTestCase.parameterize(
182 NeutronUtilsFloatingIpTests, os_creds=os_creds,
183 ext_net_name=ext_net_name, log_level=log_level))
184 suite.addTest(OSComponentTestCase.parameterize(
185 NovaUtilsKeypairTests, os_creds=os_creds, ext_net_name=ext_net_name,
186 log_level=log_level))
187 suite.addTest(OSComponentTestCase.parameterize(
188 NovaUtilsFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
189 log_level=log_level))
190 suite.addTest(OSComponentTestCase.parameterize(
191 NovaUtilsInstanceTests, os_creds=os_creds, ext_net_name=ext_net_name,
192 log_level=log_level, image_metadata=image_metadata))
193 suite.addTest(OSComponentTestCase.parameterize(
194 NovaUtilsInstanceVolumeTests, os_creds=os_creds,
195 ext_net_name=ext_net_name, log_level=log_level,
196 image_metadata=image_metadata))
197 suite.addTest(OSComponentTestCase.parameterize(
198 CreateFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
199 log_level=log_level))
200 suite.addTest(OSComponentTestCase.parameterize(
201 HeatUtilsCreateSimpleStackTests, os_creds=os_creds,
202 ext_net_name=ext_net_name, log_level=log_level,
203 image_metadata=image_metadata))
204 # https://gerrit.opnfv.org/gerrit/#/c/59801/
205 # suite.addTest(OSComponentTestCase.parameterize(
206 # HeatUtilsCreateComplexStackTests, os_creds=os_creds,
207 # ext_net_name=ext_net_name, log_level=log_level,
208 # image_metadata=image_metadata))
209 suite.addTest(OSComponentTestCase.parameterize(
210 HeatUtilsFlavorTests, os_creds=os_creds,
211 ext_net_name=ext_net_name, log_level=log_level,
212 image_metadata=image_metadata))
213 suite.addTest(OSComponentTestCase.parameterize(
214 HeatUtilsKeypairTests, os_creds=os_creds,
215 ext_net_name=ext_net_name, log_level=log_level,
216 image_metadata=image_metadata))
217 suite.addTest(OSComponentTestCase.parameterize(
218 HeatUtilsSecurityGroupTests, os_creds=os_creds,
219 ext_net_name=ext_net_name, log_level=log_level,
220 image_metadata=image_metadata))
221 suite.addTest(OSComponentTestCase.parameterize(
222 CinderUtilsQoSTests, os_creds=os_creds,
223 ext_net_name=ext_net_name, log_level=log_level,
224 image_metadata=image_metadata))
225 suite.addTest(OSComponentTestCase.parameterize(
226 CinderUtilsVolumeTests, os_creds=os_creds,
227 ext_net_name=ext_net_name, log_level=log_level,
228 image_metadata=image_metadata))
229 suite.addTest(OSComponentTestCase.parameterize(
230 CinderUtilsSimpleVolumeTypeTests, os_creds=os_creds,
231 ext_net_name=ext_net_name, log_level=log_level,
232 image_metadata=image_metadata))
233 suite.addTest(OSComponentTestCase.parameterize(
234 CinderUtilsAddEncryptionTests, os_creds=os_creds,
235 ext_net_name=ext_net_name, log_level=log_level,
236 image_metadata=image_metadata))
237 suite.addTest(OSComponentTestCase.parameterize(
238 CinderUtilsVolumeTypeCompleteTests, os_creds=os_creds,
239 ext_net_name=ext_net_name, log_level=log_level,
240 image_metadata=image_metadata))
243 def add_openstack_integration_tests(suite, os_creds, ext_net_name,
244 use_keystone=True, flavor_metadata=None,
245 image_metadata=None, use_floating_ips=True,
246 netconf_override=None,
247 log_level=logging.INFO):
248 # pylint: disable=too-many-arguments
250 Adds tests written to exercise all long-running OpenStack integration tests
251 meaning they will be creating VM instances and potentially performing some
252 SSH functions through floatingIPs
254 :param suite: the unittest.TestSuite object to which to add the tests
255 :param os_creds: and instance of OSCreds that holds the credentials
256 required by OpenStack
257 :param ext_net_name: the name of an external network on the cloud under
259 :param use_keystone: when True, tests requiring direct access to Keystone
260 are added as these need to be running on a host that
261 has access to the cloud's private network
262 :param image_metadata: dict() object containing metadata for creating an
263 image with custom config
264 (see YAML files in examples/image-metadata)
265 :param flavor_metadata: dict() object containing the metadata required by
266 your flavor based on your configuration:
267 (i.e. {'hw:mem_page_size': 'large'})
268 :param use_floating_ips: when true, all tests requiring Floating IPs will
269 be added to the suite
270 :param netconf_override: dict() containing the reconfigured network_type,
271 physical_network and segmentation_id
272 :param log_level: the logging level
273 :return: None as the tests will be adding to the 'suite' parameter object
275 # Tests the OpenStack API calls via a creator. If use_keystone, objects
276 # will be created with a custom user and project
278 # Creator Object tests
279 suite.addTest(OSIntegrationTestCase.parameterize(
280 CreateSecurityGroupTests, os_creds=os_creds, ext_net_name=ext_net_name,
281 use_keystone=use_keystone,
282 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
283 log_level=log_level))
284 suite.addTest(OSIntegrationTestCase.parameterize(
285 CreateImageSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
286 use_keystone=use_keystone,
287 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
288 log_level=log_level))
289 suite.addTest(OSIntegrationTestCase.parameterize(
290 CreateImageNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
291 use_keystone=use_keystone,
292 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
293 log_level=log_level))
294 suite.addTest(OSIntegrationTestCase.parameterize(
295 CreateMultiPartImageTests, os_creds=os_creds,
296 ext_net_name=ext_net_name, use_keystone=use_keystone,
297 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
298 log_level=log_level))
299 suite.addTest(OSIntegrationTestCase.parameterize(
300 CreateKeypairsTests, os_creds=os_creds, ext_net_name=ext_net_name,
301 use_keystone=use_keystone,
302 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
303 log_level=log_level))
304 suite.addTest(OSIntegrationTestCase.parameterize(
305 CreateKeypairsCleanupTests, os_creds=os_creds,
306 ext_net_name=ext_net_name,
307 use_keystone=use_keystone,
308 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
309 log_level=log_level))
310 suite.addTest(OSIntegrationTestCase.parameterize(
311 CreateNetworkSuccessTests, os_creds=os_creds,
312 ext_net_name=ext_net_name, use_keystone=use_keystone,
313 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
314 log_level=log_level))
315 # https://jira.opnfv.org/browse/SNAPS-320
316 # suite.addTest(OSIntegrationTestCase.parameterize(
317 # CreateRouterSuccessTests, os_creds=os_creds,
318 # ext_net_name=ext_net_name,
319 # use_keystone=use_keystone,
320 # flavor_metadata=flavor_metadata, image_metadata=image_metadata,
321 # log_level=log_level))
322 suite.addTest(OSIntegrationTestCase.parameterize(
323 CreateRouterNegativeTests, os_creds=os_creds,
324 ext_net_name=ext_net_name, use_keystone=use_keystone,
325 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
326 log_level=log_level))
327 suite.addTest(OSIntegrationTestCase.parameterize(
328 CreateQoSTests, os_creds=os_creds,
329 ext_net_name=ext_net_name, use_keystone=use_keystone,
330 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
331 log_level=log_level))
332 suite.addTest(OSIntegrationTestCase.parameterize(
333 CreateSimpleVolumeTypeSuccessTests, os_creds=os_creds,
334 ext_net_name=ext_net_name, use_keystone=use_keystone,
335 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
336 log_level=log_level))
337 suite.addTest(OSIntegrationTestCase.parameterize(
338 CreateVolumeTypeComplexTests, os_creds=os_creds,
339 ext_net_name=ext_net_name, use_keystone=use_keystone,
340 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
341 log_level=log_level))
342 suite.addTest(OSIntegrationTestCase.parameterize(
343 CreateSimpleVolumeSuccessTests, os_creds=os_creds,
344 ext_net_name=ext_net_name, use_keystone=use_keystone,
345 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
346 log_level=log_level))
347 suite.addTest(OSIntegrationTestCase.parameterize(
348 CreateSimpleVolumeFailureTests, os_creds=os_creds,
349 ext_net_name=ext_net_name, use_keystone=use_keystone,
350 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
351 log_level=log_level))
352 suite.addTest(OSIntegrationTestCase.parameterize(
353 CreateVolumeWithTypeTests, os_creds=os_creds,
354 ext_net_name=ext_net_name, use_keystone=use_keystone,
355 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
356 log_level=log_level))
357 suite.addTest(OSIntegrationTestCase.parameterize(
358 CreateVolumeWithImageTests, os_creds=os_creds,
359 ext_net_name=ext_net_name, use_keystone=use_keystone,
360 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
361 log_level=log_level))
364 suite.addTest(OSIntegrationTestCase.parameterize(
365 SimpleHealthCheck, os_creds=os_creds, ext_net_name=ext_net_name,
366 use_keystone=use_keystone,
367 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
368 log_level=log_level))
369 suite.addTest(OSIntegrationTestCase.parameterize(
370 CreateInstanceTwoNetTests, os_creds=os_creds,
371 ext_net_name=ext_net_name, use_keystone=use_keystone,
372 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
373 log_level=log_level))
374 suite.addTest(OSIntegrationTestCase.parameterize(
375 CreateInstanceSimpleTests, os_creds=os_creds,
376 ext_net_name=ext_net_name, use_keystone=use_keystone,
377 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
378 netconf_override=netconf_override, log_level=log_level))
379 suite.addTest(OSIntegrationTestCase.parameterize(
380 CreateInstancePortManipulationTests, os_creds=os_creds,
381 ext_net_name=ext_net_name, use_keystone=use_keystone,
382 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
383 netconf_override=netconf_override, log_level=log_level))
384 suite.addTest(OSIntegrationTestCase.parameterize(
385 InstanceSecurityGroupTests, os_creds=os_creds,
386 ext_net_name=ext_net_name, use_keystone=use_keystone,
387 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
388 netconf_override=netconf_override, log_level=log_level))
389 suite.addTest(OSIntegrationTestCase.parameterize(
390 CreateInstanceOnComputeHost, os_creds=os_creds,
391 ext_net_name=ext_net_name, use_keystone=use_keystone,
392 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
393 netconf_override=netconf_override, log_level=log_level))
394 suite.addTest(OSIntegrationTestCase.parameterize(
395 CreateInstanceFromThreePartImage, os_creds=os_creds,
396 ext_net_name=ext_net_name, use_keystone=use_keystone,
397 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
398 netconf_override=netconf_override, log_level=log_level))
399 suite.addTest(OSIntegrationTestCase.parameterize(
400 CreateInstanceVolumeTests, os_creds=os_creds,
401 ext_net_name=ext_net_name, use_keystone=use_keystone,
402 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
403 netconf_override=netconf_override, log_level=log_level))
404 suite.addTest(OSIntegrationTestCase.parameterize(
405 CreateStackSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
406 use_keystone=use_keystone,
407 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
408 log_level=log_level))
409 suite.addTest(OSIntegrationTestCase.parameterize(
410 CreateStackVolumeTests, os_creds=os_creds, ext_net_name=ext_net_name,
411 use_keystone=use_keystone,
412 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
413 log_level=log_level))
414 suite.addTest(OSIntegrationTestCase.parameterize(
415 CreateStackFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
416 use_keystone=use_keystone,
417 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
418 log_level=log_level))
419 suite.addTest(OSIntegrationTestCase.parameterize(
420 CreateStackKeypairTests, os_creds=os_creds, ext_net_name=ext_net_name,
421 use_keystone=use_keystone,
422 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
423 log_level=log_level))
424 suite.addTest(OSIntegrationTestCase.parameterize(
425 CreateStackSecurityGroupTests, os_creds=os_creds,
426 ext_net_name=ext_net_name, use_keystone=use_keystone,
427 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
428 log_level=log_level))
429 suite.addTest(OSIntegrationTestCase.parameterize(
430 CreateStackNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
431 use_keystone=use_keystone,
432 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
433 log_level=log_level))
436 # https://jira.opnfv.org/browse/SNAPS-322
437 # suite.addTest(OSIntegrationTestCase.parameterize(
438 # CreateInstanceSingleNetworkTests, os_creds=os_creds,
439 # ext_net_name=ext_net_name, use_keystone=use_keystone,
440 # flavor_metadata=flavor_metadata, image_metadata=image_metadata,
441 # log_level=log_level))
442 # https://gerrit.opnfv.org/gerrit/#/c/59801/
443 # suite.addTest(OSIntegrationTestCase.parameterize(
444 # CreateStackFloatingIpTests, os_creds=os_creds,
445 # ext_net_name=ext_net_name, use_keystone=use_keystone,
446 # flavor_metadata=flavor_metadata, image_metadata=image_metadata,
447 # log_level=log_level))
448 suite.addTest(OSIntegrationTestCase.parameterize(
449 AnsibleProvisioningTests, os_creds=os_creds,
450 ext_net_name=ext_net_name, use_keystone=use_keystone,
451 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
452 log_level=log_level))