summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-11-27 10:21:09 -0700
committerspisarski <s.pisarski@cablelabs.com>2017-11-27 10:21:09 -0700
commit0e06ebe62fcff9b491a0edd89bdf511f88d091e7 (patch)
treed84d597ffa618b97429790ef2ebf16bb7c02156f
parent8d64362faf1998bceae353da3d29883883a6c351 (diff)
Expanded the tests for ClusterTypes
JIRA: SNAPS-233 Change-Id: Ibba9b7046b95b5523cde525c4a4ed971f463a19d Signed-off-by: spisarski <s.pisarski@cablelabs.com>
-rw-r--r--docs/how-to-use/APITests.rst33
-rw-r--r--snaps/openstack/utils/tests/magnum_utils_tests.py137
-rw-r--r--snaps/test_suite_builder.py4
3 files changed, 165 insertions, 9 deletions
diff --git a/docs/how-to-use/APITests.rst b/docs/how-to-use/APITests.rst
index 6a7c317..86c855f 100644
--- a/docs/how-to-use/APITests.rst
+++ b/docs/how-to-use/APITests.rst
@@ -554,6 +554,39 @@ magnum_utils_tests.py - MagnumUtilsTests
| | | magnum_utils.create_cluster_template() to create a simple |
| | | cluster template OpenStack object with minimal config |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_all | 1 | Tests ability of the function |
+| | | magnum_utils.create_cluster_template() to create a |
+| | | cluster template OpenStack object with maximum config |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad_image| 1 | Ensures the function |
+| | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the image does not exist |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad_kp | 1 | Ensures the function |
+| | | magnum_utils.create_cluster_template() will raise a |
+| | | NotFound exception when the keypair does not exist |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad_ext | 1 | Ensures the function |
+| _net | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the external network does not |
+| | | exist |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad | 1 | Ensures the function |
+| _flavor | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the flavor does not exist |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad | 1 | Ensures the function |
+| _master_flavor | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the master flavor does not exist|
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad | 1 | Ensures the function |
+| _network_driver | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the network driver is invalid |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_cluster_template_bad | 1 | Ensures the function |
+| _volume_driver | | magnum_utils.create_cluster_template() will raise a |
+| | | BadRequest exception when the volume driver is invalid |
++---------------------------------------+---------------+-----------------------------------------------------------+
settings_utils_tests.py - SettingsUtilsNetworkingTests
------------------------------------------------------
diff --git a/snaps/openstack/utils/tests/magnum_utils_tests.py b/snaps/openstack/utils/tests/magnum_utils_tests.py
index 9e47900..f6da810 100644
--- a/snaps/openstack/utils/tests/magnum_utils_tests.py
+++ b/snaps/openstack/utils/tests/magnum_utils_tests.py
@@ -15,8 +15,14 @@
import logging
import uuid
-from snaps.config.cluster_template import ClusterTemplateConfig
+from magnumclient.common.apiclient.exceptions import BadRequest, NotFound
+
+from snaps.config.cluster_template import (
+ ClusterTemplateConfig, ServerType, ContainerOrchestrationEngine,
+ DockerStorageDriver)
+from snaps.config.flavor import FlavorConfig
from snaps.config.keypair import KeypairConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_keypairs import OpenStackKeypair
from snaps.openstack.os_credentials import OSCreds
@@ -56,7 +62,7 @@ class MagnumSmokeTests(OSComponentTestCase):
proxy_settings=self.os_creds.proxy_settings))
-class MagnumUtilsTests(OSComponentTestCase):
+class MagnumUtilsClusterTypeTests(OSComponentTestCase):
"""
Tests individual functions within magnum_utils.py
"""
@@ -78,6 +84,10 @@ class MagnumUtilsTests(OSComponentTestCase):
self.image_creator = OpenStackImage(self.os_creds, os_image_settings)
+ self.flavor_creator = OpenStackFlavor(
+ self.os_creds, FlavorConfig(
+ name=self.guid + '-flavor', ram=512, disk=10, vcpus=1))
+
keypair_priv_filepath = 'tmp/' + self.guid
keypair_pub_filepath = keypair_priv_filepath + '.pub'
@@ -91,6 +101,7 @@ class MagnumUtilsTests(OSComponentTestCase):
try:
self.image_creator.create()
+ self.flavor_creator.create()
self.keypair_creator.create()
except:
self.tearDown()
@@ -108,6 +119,11 @@ class MagnumUtilsTests(OSComponentTestCase):
self.keypair_creator.clean()
except:
pass
+ if self.flavor_creator:
+ try:
+ self.flavor_creator.clean()
+ except:
+ pass
if self.image_creator:
try:
self.image_creator.clean()
@@ -119,7 +135,32 @@ class MagnumUtilsTests(OSComponentTestCase):
name=self.cluster_type_name,
image=self.image_creator.image_settings.name,
keypair=self.keypair_creator.keypair_settings.name,
- external_net=self.ext_net_name)
+ external_net=self.ext_net_name,
+ flavor=self.flavor_creator.flavor_settings.name)
+
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+ self.assertIsNotNone(self.cluster_template)
+ self.assertTrue(
+ validate_cluster_template(config, self.cluster_template))
+
+ def test_create_cluster_template_all(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ network_driver='flannel', external_net=self.ext_net_name,
+ floating_ip_enabled=True, docker_volume_size=100,
+ server_type=ServerType.vm,
+ flavor=self.flavor_creator.flavor_settings.name,
+ master_flavor=self.flavor_creator.flavor_settings.name,
+ coe=ContainerOrchestrationEngine.kubernetes,
+ fixed_net='foo', fixed_subnet='bar',
+ registry_enabled=True, insecure_registry='localhost',
+ docker_storage_driver=DockerStorageDriver.overlay,
+ dns_nameserver='8.8.4.4', public=True, tls_disabled=True,
+ http_proxy=None, https_proxy=None, volume_driver='cinder',
+ master_lb_enabled=False, labels={'foo': 'bar'})
self.cluster_template = magnum_utils.create_cluster_template(
self.magnum, config)
@@ -127,6 +168,91 @@ class MagnumUtilsTests(OSComponentTestCase):
self.assertTrue(
validate_cluster_template(config, self.cluster_template))
+ def test_create_cluster_template_bad_image(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image='foo',
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net=self.ext_net_name,
+ flavor=self.flavor_creator.flavor_settings.name)
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_kp(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair='foo',
+ external_net=self.ext_net_name,
+ flavor=self.flavor_creator.flavor_settings.name)
+
+ with self.assertRaises(NotFound):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_ext_net(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net='foo',
+ flavor=self.flavor_creator.flavor_settings.name)
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_flavor(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net=self.ext_net_name,
+ flavor='foo')
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_master_flavor(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net=self.ext_net_name,
+ flavor=self.flavor_creator.flavor_settings.name,
+ master_flavor='foo')
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_network_driver(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net=self.ext_net_name,
+ network_driver='foo')
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
+ def test_create_cluster_template_bad_volume_driver(self):
+ config = ClusterTemplateConfig(
+ name=self.cluster_type_name,
+ image=self.image_creator.image_settings.name,
+ keypair=self.keypair_creator.keypair_settings.name,
+ external_net=self.ext_net_name,
+ volume_driver='foo')
+
+ with self.assertRaises(BadRequest):
+ self.cluster_template = magnum_utils.create_cluster_template(
+ self.magnum, config)
+
def validate_cluster_template(tmplt_config, tmplt_obj):
"""
@@ -144,7 +270,7 @@ def validate_cluster_template(tmplt_config, tmplt_obj):
tmplt_config.coe.value == tmplt_obj.coe and
tmplt_config.dns_nameserver == tmplt_obj.dns_nameserver and
tmplt_config.docker_storage_driver.value
- == tmplt_obj.docker_storage_driver and
+ == tmplt_obj.docker_storage_driver and
tmplt_config.docker_volume_size == tmplt_obj.docker_volume_size and
tmplt_config.external_net == tmplt_obj.external_net and
tmplt_config.fixed_net == tmplt_obj.fixed_net and
@@ -169,6 +295,3 @@ def validate_cluster_template(tmplt_config, tmplt_obj):
tmplt_config.tls_disabled == tmplt_obj.tls_disabled and
tmplt_config.volume_driver == tmplt_obj.volume_driver
)
- # def test_create_cluster_simple(self):
- # cluster = magnum_utils.create_cluster(self.magnum, 'foo')
- # self.assertIsNotNone(cluster)
diff --git a/snaps/test_suite_builder.py b/snaps/test_suite_builder.py
index 496caf7..27d4f85 100644
--- a/snaps/test_suite_builder.py
+++ b/snaps/test_suite_builder.py
@@ -124,7 +124,7 @@ from snaps.openstack.utils.tests.nova_utils_tests import (
from snaps.openstack.utils.tests.settings_utils_tests import (
SettingsUtilsUnitTests)
from snaps.openstack.utils.tests.magnum_utils_tests import (
- MagnumSmokeTests, MagnumUtilsTests)
+ MagnumSmokeTests, MagnumUtilsClusterTypeTests)
from snaps.provisioning.tests.ansible_utils_tests import (
AnsibleProvisioningTests)
from snaps.tests.file_utils_tests import FileUtilsTests
@@ -727,5 +727,5 @@ def add_openstack_staging_tests(suite, os_creds, ext_net_name,
MagnumSmokeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))
suite.addTest(OSComponentTestCase.parameterize(
- MagnumUtilsTests, os_creds=os_creds,
+ MagnumUtilsClusterTypeTests, os_creds=os_creds,
ext_net_name=ext_net_name, log_level=log_level))