1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
# and others. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import unittest
from snaps.domain.test.flavor_tests import FlavorDomainObjectTests
from snaps.domain.test.image_tests import ImageDomainObjectTests
from snaps.domain.test.keypair_tests import KeypairDomainObjectTests
from snaps.domain.test.network_tests import (
SecurityGroupDomainObjectTests, SecurityGroupRuleDomainObjectTests,
PortDomainObjectTests, RouterDomainObjectTests,
InterfaceRouterDomainObjectTests, NetworkObjectTests, SubnetObjectTests)
from snaps.domain.test.project_tests import (
ProjectDomainObjectTests, DomainDomainObjectTests,
ComputeQuotasDomainObjectTests, NetworkQuotasDomainObjectTests)
from snaps.domain.test.role_tests import RoleDomainObjectTests
from snaps.domain.test.stack_tests import (
StackDomainObjectTests, ResourceDomainObjectTests)
from snaps.domain.test.user_tests import UserDomainObjectTests
from snaps.domain.test.vm_inst_tests import (
VmInstDomainObjectTests, FloatingIpDomainObjectTests)
from snaps.domain.test.volume_tests import (
QoSSpecDomainObjectTests, VolumeTypeDomainObjectTests,
VolumeTypeEncryptionObjectTests, VolumeDomainObjectTests)
from snaps.openstack.tests.conf.os_credentials_tests import (
ProxySettingsUnitTests, OSCredsUnitTests)
from snaps.openstack.tests.create_flavor_tests import (
CreateFlavorTests, FlavorSettingsUnitTests)
from snaps.openstack.tests.create_image_tests import (
CreateImageSuccessTests, CreateImageNegativeTests, ImageSettingsUnitTests,
CreateMultiPartImageTests)
from snaps.openstack.tests.create_instance_tests import (
CreateInstanceSingleNetworkTests, CreateInstancePubPrivNetTests,
CreateInstanceOnComputeHost, CreateInstanceSimpleTests,
FloatingIpSettingsUnitTests, InstanceSecurityGroupTests,
VmInstanceSettingsUnitTests, CreateInstancePortManipulationTests,
SimpleHealthCheck, CreateInstanceFromThreePartImage,
CreateInstanceMockOfflineTests, CreateInstanceTwoNetTests,
CreateInstanceVolumeTests)
from snaps.openstack.tests.create_keypairs_tests import (
CreateKeypairsTests, KeypairSettingsUnitTests, CreateKeypairsCleanupTests)
from snaps.openstack.tests.create_network_tests import (
CreateNetworkSuccessTests, NetworkSettingsUnitTests, PortSettingsUnitTests,
SubnetSettingsUnitTests, CreateNetworkTypeTests)
from snaps.openstack.tests.create_project_tests import (
CreateProjectSuccessTests, ProjectSettingsUnitTests,
CreateProjectUserTests)
from snaps.openstack.tests.create_qos_tests import (
QoSSettingsUnitTests, CreateQoSTests)
from snaps.openstack.tests.create_router_tests import (
CreateRouterSuccessTests, CreateRouterNegativeTests,
RouterSettingsUnitTests)
from snaps.openstack.tests.create_security_group_tests import (
CreateSecurityGroupTests, SecurityGroupRuleSettingsUnitTests,
SecurityGroupSettingsUnitTests)
from snaps.openstack.tests.create_stack_tests import (
StackSettingsUnitTests, CreateStackSuccessTests, CreateStackNegativeTests,
CreateStackFloatingIpTests, CreateStackVolumeTests)
from snaps.openstack.tests.create_user_tests import (
UserSettingsUnitTests, CreateUserSuccessTests)
from snaps.openstack.tests.create_volume_tests import (
VolumeSettingsUnitTests, CreateSimpleVolumeSuccessTests,
CreateVolumeWithTypeTests, CreateVolumeWithImageTests,
CreateSimpleVolumeFailureTests)
from snaps.openstack.tests.create_volume_type_tests import (
VolumeTypeSettingsUnitTests, CreateSimpleVolumeTypeSuccessTests,
CreateVolumeTypeComplexTests)
from snaps.openstack.tests.os_source_file_test import (
OSComponentTestCase, OSIntegrationTestCase)
from snaps.openstack.utils.tests.cinder_utils_tests import (
CinderSmokeTests, CinderUtilsQoSTests, CinderUtilsSimpleVolumeTypeTests,
CinderUtilsAddEncryptionTests, CinderUtilsVolumeTypeCompleteTests,
CinderUtilsVolumeTests)
from snaps.openstack.utils.tests.glance_utils_tests import (
GlanceSmokeTests, GlanceUtilsTests)
from snaps.openstack.utils.tests.heat_utils_tests import (
HeatSmokeTests, HeatUtilsCreateSimpleStackTests,
HeatUtilsCreateComplexStackTests, HeatUtilsVolumeTests)
from snaps.openstack.utils.tests.keystone_utils_tests import (
KeystoneSmokeTests, KeystoneUtilsTests)
from snaps.openstack.utils.tests.neutron_utils_tests import (
NeutronSmokeTests, NeutronUtilsNetworkTests, NeutronUtilsSubnetTests,
NeutronUtilsRouterTests, NeutronUtilsSecurityGroupTests,
NeutronUtilsFloatingIpTests)
from snaps.openstack.utils.tests.nova_utils_tests import (
NovaSmokeTests, NovaUtilsKeypairTests, NovaUtilsFlavorTests,
NovaUtilsInstanceTests, NovaUtilsInstanceVolumeTests)
from snaps.openstack.utils.tests.settings_utils_tests import (
SettingsUtilsVolumeTests)
from snaps.provisioning.tests.ansible_utils_tests import (
AnsibleProvisioningTests)
from snaps.tests.file_utils_tests import FileUtilsTests
__author__ = 'spisarski'
def add_unit_tests(suite):
"""
Adds tests that do not require external resources
:param suite: the unittest.TestSuite object to which to add the tests
:return: None as the tests will be adding to the 'suite' parameter object
"""
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(FileUtilsTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SecurityGroupRuleSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ProxySettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
OSCredsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SecurityGroupSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SecurityGroupDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SecurityGroupRuleDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ImageSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ImageDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FlavorSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FlavorDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
KeypairSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
KeypairDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
UserSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
UserDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ProjectSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ProjectDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
DomainDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ComputeQuotasDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
NetworkQuotasDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
RoleDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
NetworkSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
NetworkObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SubnetSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SubnetObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
PortSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
PortDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
RouterSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
RouterDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
InterfaceRouterDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FloatingIpSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VmInstanceSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
StackDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ResourceDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
StackSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VolumeTypeDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VolumeTypeEncryptionObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VolumeDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
QoSSpecDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VmInstDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FloatingIpDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
QoSSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VolumeTypeSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
VolumeSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
SettingsUtilsVolumeTests))
def add_openstack_client_tests(suite, os_creds, ext_net_name,
use_keystone=True, log_level=logging.INFO):
"""
Adds tests written to exercise OpenStack client retrieval
:param suite: the unittest.TestSuite object to which to add the tests
:param os_creds: and instance of OSCreds that holds the credentials
required by OpenStack
:param ext_net_name: the name of an external network on the cloud under
test
:param use_keystone: when True, tests requiring direct access to Keystone
are added as these need to be running on a host that
has access to the cloud's private network
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
# Basic connection tests
suite.addTest(
OSComponentTestCase.parameterize(
GlanceSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
if use_keystone:
suite.addTest(
OSComponentTestCase.parameterize(
KeystoneSmokeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(
OSComponentTestCase.parameterize(
NeutronSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(
OSComponentTestCase.parameterize(
NovaSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(
OSComponentTestCase.parameterize(
HeatSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(
OSComponentTestCase.parameterize(
CinderSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
def add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone=True,
image_metadata=None, log_level=logging.INFO):
"""
Adds tests written to exercise all existing OpenStack APIs
:param suite: the unittest.TestSuite object to which to add the tests
:param os_creds: Instance of OSCreds that holds the credentials
required by OpenStack
:param ext_net_name: the name of an external network on the cloud under
test
:param use_keystone: when True, tests requiring direct access to Keystone
are added as these need to be running on a host that
has access to the cloud's private network
:param image_metadata: dict() object containing metadata for creating an
image with custom config
(see YAML files in examples/image-metadata)
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
# Tests the OpenStack API calls
if use_keystone:
suite.addTest(OSComponentTestCase.parameterize(
KeystoneUtilsTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
CreateUserSuccessTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
CreateProjectSuccessTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
CreateProjectUserTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
GlanceUtilsTests, os_creds=os_creds, ext_net_name=ext_net_name,
image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NeutronUtilsNetworkTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NeutronUtilsSubnetTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NeutronUtilsRouterTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NeutronUtilsSecurityGroupTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NeutronUtilsFloatingIpTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NovaUtilsKeypairTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NovaUtilsFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
NovaUtilsInstanceTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level, image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
NovaUtilsInstanceVolumeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CreateFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
HeatUtilsCreateSimpleStackTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
HeatUtilsCreateComplexStackTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
HeatUtilsVolumeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CinderUtilsQoSTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CinderUtilsVolumeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CinderUtilsSimpleVolumeTypeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CinderUtilsAddEncryptionTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
suite.addTest(OSComponentTestCase.parameterize(
CinderUtilsVolumeTypeCompleteTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level,
image_metadata=image_metadata))
def add_openstack_integration_tests(suite, os_creds, ext_net_name,
use_keystone=True, flavor_metadata=None,
image_metadata=None, use_floating_ips=True,
log_level=logging.INFO):
"""
Adds tests written to exercise all long-running OpenStack integration tests
meaning they will be creating VM instances and potentially performing some
SSH functions through floatingIPs
:param suite: the unittest.TestSuite object to which to add the tests
:param os_creds: and instance of OSCreds that holds the credentials
required by OpenStack
:param ext_net_name: the name of an external network on the cloud under
test
:param use_keystone: when True, tests requiring direct access to Keystone
are added as these need to be running on a host that
has access to the cloud's private network
:param image_metadata: dict() object containing metadata for creating an
image with custom config
(see YAML files in examples/image-metadata)
:param flavor_metadata: dict() object containing the metadata required by
your flavor based on your configuration:
(i.e. {'hw:mem_page_size': 'large'})
:param use_floating_ips: when true, all tests requiring Floating IPs will
be added to the suite
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
# Tests the OpenStack API calls via a creator. If use_keystone, objects
# will be created with a custom user and project
# Creator Object tests
suite.addTest(OSIntegrationTestCase.parameterize(
CreateSecurityGroupTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateImageSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateImageNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateMultiPartImageTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateKeypairsTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateKeypairsCleanupTests, os_creds=os_creds,
ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateNetworkSuccessTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateRouterSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateRouterNegativeTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateQoSTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateSimpleVolumeTypeSuccessTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateVolumeTypeComplexTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateSimpleVolumeSuccessTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateSimpleVolumeFailureTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateVolumeWithTypeTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateVolumeWithImageTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
# VM Instances
suite.addTest(OSIntegrationTestCase.parameterize(
SimpleHealthCheck, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceTwoNetTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceSimpleTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstancePortManipulationTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
InstanceSecurityGroupTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceOnComputeHost, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceFromThreePartImage, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceVolumeTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackVolumeTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
if use_floating_ips:
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceSingleNetworkTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackFloatingIpTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
AnsibleProvisioningTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
def add_openstack_ci_tests(
suite, os_creds, ext_net_name, use_keystone=True, flavor_metadata=None,
image_metadata=None, use_floating_ips=True, log_level=logging.INFO):
"""
Adds tests written for a CI server to run the tests to validate code
changes
:param suite: the unittest.TestSuite object to which to add the tests
:param os_creds: and instance of OSCreds that holds the credentials
required by OpenStack
:param ext_net_name: the name of an external network on the cloud under
test
:param use_keystone: when True, tests requiring direct access to Keystone
are added as these need to be running on a host that
has access to the cloud's private network
:param image_metadata: dict() object containing metadata for creating an
image with custom config
(see YAML files in examples/image-metadata)
:param flavor_metadata: dict() object containing the metadata required by
your flavor based on your configuration:
(i.e. {'hw:mem_page_size': 'large'})
:param use_floating_ips: when true, all tests requiring Floating IPs will
be added to the suite
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
add_unit_tests(suite)
add_openstack_client_tests(suite, os_creds, ext_net_name, use_keystone,
log_level)
add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone,
image_metadata, log_level)
suite.addTest(OSIntegrationTestCase.parameterize(
SimpleHealthCheck, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
if use_floating_ips:
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceSingleNetworkTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackNegativeTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
def add_openstack_staging_tests(suite, os_creds, ext_net_name,
log_level=logging.INFO):
"""
Adds tests that are still in development have not been designed to run
successfully against all OpenStack pods
:param suite: the unittest.TestSuite object to which to add the tests
:param os_creds: Instance of OSCreds that holds the credentials
required by OpenStack
:param ext_net_name: the name of an external network on the cloud under
test
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
suite.addTest(OSComponentTestCase.parameterize(
CreateNetworkTypeTests, os_creds=os_creds, ext_net_name=ext_net_name,
log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
CreateInstanceMockOfflineTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstancePubPrivNetTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
|