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, CreateStackFloatingIpTests,
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,
69 HeatUtilsCreateComplexStackTests, HeatUtilsFlavorTests,
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 suite.addTest(OSComponentTestCase.parameterize(
205 HeatUtilsCreateComplexStackTests, os_creds=os_creds,
206 ext_net_name=ext_net_name, log_level=log_level,
207 image_metadata=image_metadata))
208 suite.addTest(OSComponentTestCase.parameterize(
209 HeatUtilsFlavorTests, os_creds=os_creds,
210 ext_net_name=ext_net_name, log_level=log_level,
211 image_metadata=image_metadata))
212 suite.addTest(OSComponentTestCase.parameterize(
213 HeatUtilsKeypairTests, os_creds=os_creds,
214 ext_net_name=ext_net_name, log_level=log_level,
215 image_metadata=image_metadata))
216 suite.addTest(OSComponentTestCase.parameterize(
217 HeatUtilsSecurityGroupTests, os_creds=os_creds,
218 ext_net_name=ext_net_name, log_level=log_level,
219 image_metadata=image_metadata))
220 suite.addTest(OSComponentTestCase.parameterize(
221 CinderUtilsQoSTests, os_creds=os_creds,
222 ext_net_name=ext_net_name, log_level=log_level,
223 image_metadata=image_metadata))
224 suite.addTest(OSComponentTestCase.parameterize(
225 CinderUtilsVolumeTests, os_creds=os_creds,
226 ext_net_name=ext_net_name, log_level=log_level,
227 image_metadata=image_metadata))
228 suite.addTest(OSComponentTestCase.parameterize(
229 CinderUtilsSimpleVolumeTypeTests, os_creds=os_creds,
230 ext_net_name=ext_net_name, log_level=log_level,
231 image_metadata=image_metadata))
232 suite.addTest(OSComponentTestCase.parameterize(
233 CinderUtilsAddEncryptionTests, os_creds=os_creds,
234 ext_net_name=ext_net_name, log_level=log_level,
235 image_metadata=image_metadata))
236 suite.addTest(OSComponentTestCase.parameterize(
237 CinderUtilsVolumeTypeCompleteTests, os_creds=os_creds,
238 ext_net_name=ext_net_name, log_level=log_level,
239 image_metadata=image_metadata))
242 def add_openstack_integration_tests(suite, os_creds, ext_net_name,
243 use_keystone=True, flavor_metadata=None,
244 image_metadata=None, use_floating_ips=True,
245 netconf_override=None,
246 log_level=logging.INFO):
247 # pylint: disable=too-many-arguments
249 Adds tests written to exercise all long-running OpenStack integration tests
250 meaning they will be creating VM instances and potentially performing some
251 SSH functions through floatingIPs
253 :param suite: the unittest.TestSuite object to which to add the tests
254 :param os_creds: and instance of OSCreds that holds the credentials
255 required by OpenStack
256 :param ext_net_name: the name of an external network on the cloud under
258 :param use_keystone: when True, tests requiring direct access to Keystone
259 are added as these need to be running on a host that
260 has access to the cloud's private network
261 :param image_metadata: dict() object containing metadata for creating an
262 image with custom config
263 (see YAML files in examples/image-metadata)
264 :param flavor_metadata: dict() object containing the metadata required by
265 your flavor based on your configuration:
266 (i.e. {'hw:mem_page_size': 'large'})
267 :param use_floating_ips: when true, all tests requiring Floating IPs will
268 be added to the suite
269 :param netconf_override: dict() containing the reconfigured network_type,
270 physical_network and segmentation_id
271 :param log_level: the logging level
272 :return: None as the tests will be adding to the 'suite' parameter object
274 # Tests the OpenStack API calls via a creator. If use_keystone, objects
275 # will be created with a custom user and project
277 # Creator Object tests
278 suite.addTest(OSIntegrationTestCase.parameterize(
279 CreateSecurityGroupTests, os_creds=os_creds, ext_net_name=ext_net_name,
280 use_keystone=use_keystone,
281 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
282 log_level=log_level))
283 suite.addTest(OSIntegrationTestCase.parameterize(
284 CreateImageSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
285 use_keystone=use_keystone,
286 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
287 log_level=log_level))
288 suite.addTest(OSIntegrationTestCase.parameterize(
289 CreateImageNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
290 use_keystone=use_keystone,
291 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
292 log_level=log_level))
293 suite.addTest(OSIntegrationTestCase.parameterize(
294 CreateMultiPartImageTests, os_creds=os_creds,
295 ext_net_name=ext_net_name, use_keystone=use_keystone,
296 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
297 log_level=log_level))
298 suite.addTest(OSIntegrationTestCase.parameterize(
299 CreateKeypairsTests, os_creds=os_creds, ext_net_name=ext_net_name,
300 use_keystone=use_keystone,
301 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
302 log_level=log_level))
303 suite.addTest(OSIntegrationTestCase.parameterize(
304 CreateKeypairsCleanupTests, os_creds=os_creds,
305 ext_net_name=ext_net_name,
306 use_keystone=use_keystone,
307 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
308 log_level=log_level))
309 suite.addTest(OSIntegrationTestCase.parameterize(
310 CreateNetworkSuccessTests, os_creds=os_creds,
311 ext_net_name=ext_net_name, use_keystone=use_keystone,
312 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
313 log_level=log_level))
314 # https://jira.opnfv.org/browse/SNAPS-320
315 # suite.addTest(OSIntegrationTestCase.parameterize(
316 # CreateRouterSuccessTests, os_creds=os_creds,
317 # ext_net_name=ext_net_name,
318 # use_keystone=use_keystone,
319 # flavor_metadata=flavor_metadata, image_metadata=image_metadata,
320 # log_level=log_level))
321 suite.addTest(OSIntegrationTestCase.parameterize(
322 CreateRouterNegativeTests, os_creds=os_creds,
323 ext_net_name=ext_net_name, use_keystone=use_keystone,
324 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
325 log_level=log_level))
326 suite.addTest(OSIntegrationTestCase.parameterize(
327 CreateQoSTests, os_creds=os_creds,
328 ext_net_name=ext_net_name, use_keystone=use_keystone,
329 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
330 log_level=log_level))
331 suite.addTest(OSIntegrationTestCase.parameterize(
332 CreateSimpleVolumeTypeSuccessTests, os_creds=os_creds,
333 ext_net_name=ext_net_name, use_keystone=use_keystone,
334 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
335 log_level=log_level))
336 suite.addTest(OSIntegrationTestCase.parameterize(
337 CreateVolumeTypeComplexTests, os_creds=os_creds,
338 ext_net_name=ext_net_name, use_keystone=use_keystone,
339 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
340 log_level=log_level))
341 suite.addTest(OSIntegrationTestCase.parameterize(
342 CreateSimpleVolumeSuccessTests, os_creds=os_creds,
343 ext_net_name=ext_net_name, use_keystone=use_keystone,
344 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
345 log_level=log_level))
346 suite.addTest(OSIntegrationTestCase.parameterize(
347 CreateSimpleVolumeFailureTests, os_creds=os_creds,
348 ext_net_name=ext_net_name, use_keystone=use_keystone,
349 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
350 log_level=log_level))
351 suite.addTest(OSIntegrationTestCase.parameterize(
352 CreateVolumeWithTypeTests, os_creds=os_creds,
353 ext_net_name=ext_net_name, use_keystone=use_keystone,
354 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
355 log_level=log_level))
356 suite.addTest(OSIntegrationTestCase.parameterize(
357 CreateVolumeWithImageTests, os_creds=os_creds,
358 ext_net_name=ext_net_name, use_keystone=use_keystone,
359 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
360 log_level=log_level))
363 suite.addTest(OSIntegrationTestCase.parameterize(
364 SimpleHealthCheck, os_creds=os_creds, ext_net_name=ext_net_name,
365 use_keystone=use_keystone,
366 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
367 log_level=log_level))
368 suite.addTest(OSIntegrationTestCase.parameterize(
369 CreateInstanceTwoNetTests, os_creds=os_creds,
370 ext_net_name=ext_net_name, use_keystone=use_keystone,
371 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
372 log_level=log_level))
373 suite.addTest(OSIntegrationTestCase.parameterize(
374 CreateInstanceSimpleTests, os_creds=os_creds,
375 ext_net_name=ext_net_name, use_keystone=use_keystone,
376 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
377 netconf_override=netconf_override, log_level=log_level))
378 suite.addTest(OSIntegrationTestCase.parameterize(
379 CreateInstancePortManipulationTests, os_creds=os_creds,
380 ext_net_name=ext_net_name, use_keystone=use_keystone,
381 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
382 netconf_override=netconf_override, log_level=log_level))
383 suite.addTest(OSIntegrationTestCase.parameterize(
384 InstanceSecurityGroupTests, os_creds=os_creds,
385 ext_net_name=ext_net_name, use_keystone=use_keystone,
386 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
387 netconf_override=netconf_override, log_level=log_level))
388 suite.addTest(OSIntegrationTestCase.parameterize(
389 CreateInstanceOnComputeHost, os_creds=os_creds,
390 ext_net_name=ext_net_name, use_keystone=use_keystone,
391 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
392 netconf_override=netconf_override, log_level=log_level))
393 suite.addTest(OSIntegrationTestCase.parameterize(
394 CreateInstanceFromThreePartImage, os_creds=os_creds,
395 ext_net_name=ext_net_name, use_keystone=use_keystone,
396 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
397 netconf_override=netconf_override, log_level=log_level))
398 suite.addTest(OSIntegrationTestCase.parameterize(
399 CreateInstanceVolumeTests, os_creds=os_creds,
400 ext_net_name=ext_net_name, use_keystone=use_keystone,
401 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
402 netconf_override=netconf_override, log_level=log_level))
403 suite.addTest(OSIntegrationTestCase.parameterize(
404 CreateStackSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
405 use_keystone=use_keystone,
406 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
407 log_level=log_level))
408 suite.addTest(OSIntegrationTestCase.parameterize(
409 CreateStackVolumeTests, os_creds=os_creds, ext_net_name=ext_net_name,
410 use_keystone=use_keystone,
411 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
412 log_level=log_level))
413 suite.addTest(OSIntegrationTestCase.parameterize(
414 CreateStackFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
415 use_keystone=use_keystone,
416 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
417 log_level=log_level))
418 suite.addTest(OSIntegrationTestCase.parameterize(
419 CreateStackKeypairTests, os_creds=os_creds, ext_net_name=ext_net_name,
420 use_keystone=use_keystone,
421 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
422 log_level=log_level))
423 suite.addTest(OSIntegrationTestCase.parameterize(
424 CreateStackSecurityGroupTests, os_creds=os_creds,
425 ext_net_name=ext_net_name, use_keystone=use_keystone,
426 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
427 log_level=log_level))
428 suite.addTest(OSIntegrationTestCase.parameterize(
429 CreateStackNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
430 use_keystone=use_keystone,
431 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
432 log_level=log_level))
435 # https://jira.opnfv.org/browse/SNAPS-322
436 # suite.addTest(OSIntegrationTestCase.parameterize(
437 # CreateInstanceSingleNetworkTests, os_creds=os_creds,
438 # ext_net_name=ext_net_name, use_keystone=use_keystone,
439 # flavor_metadata=flavor_metadata, image_metadata=image_metadata,
440 # log_level=log_level))
441 suite.addTest(OSIntegrationTestCase.parameterize(
442 CreateStackFloatingIpTests, os_creds=os_creds,
443 ext_net_name=ext_net_name, use_keystone=use_keystone,
444 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
445 log_level=log_level))
446 suite.addTest(OSIntegrationTestCase.parameterize(
447 AnsibleProvisioningTests, os_creds=os_creds,
448 ext_net_name=ext_net_name, use_keystone=use_keystone,
449 flavor_metadata=flavor_metadata, image_metadata=image_metadata,
450 log_level=log_level))