Modify the unit test for auto generated releases
1. Render the templates from the operator config. 2. Check if the manifest has openstack namespace Change-Id: I978c915d10fadcb094118662e7699e7657f9dfba
This commit is contained in:
parent
fab3313431
commit
738584ddb8
14
config/samples/operator-config.yaml
Normal file
14
config/samples/operator-config.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: operator-config
|
||||||
|
data:
|
||||||
|
operator-config.yaml: |
|
||||||
|
horizon:
|
||||||
|
ingress:
|
||||||
|
host: "horizon.vexxhost.com"
|
||||||
|
keystone:
|
||||||
|
configDir: /etc/keystone
|
||||||
|
heat:
|
||||||
|
configDir: /etc/heat
|
||||||
|
chronyd: {}
|
@ -34,10 +34,23 @@ class KubernetesObjectTestCase(testtools.TestCase):
|
|||||||
SAMPLES_PATH = 'config/samples'
|
SAMPLES_PATH = 'config/samples'
|
||||||
SAMPLE_FILE = ''
|
SAMPLE_FILE = ''
|
||||||
TEMPLATE_FILE = ''
|
TEMPLATE_FILE = ''
|
||||||
NAMESPACE_CHECK = True
|
# If auto generated, or no CR exists
|
||||||
|
AUTO_GENERATED = True
|
||||||
|
RELEASE_TYPE = ''
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
if cls.AUTO_GENERATED:
|
||||||
|
config_path = "%s/%s" % (cls.SAMPLES_PATH, "operator-config.yaml")
|
||||||
|
with open(config_path) as config_fd:
|
||||||
|
sample = yaml.load(config_fd, Loader=yaml.FullLoader)
|
||||||
|
name = sample['metadata']['name']
|
||||||
|
spec = utils.to_dict(
|
||||||
|
sample['data']['operator-config.yaml'])[cls.RELEASE_TYPE]
|
||||||
|
cls.object = utils.render_template(cls.TEMPLATE_FILE,
|
||||||
|
name=cls.RELEASE_TYPE,
|
||||||
|
spec=spec)
|
||||||
|
else:
|
||||||
sample_path = "%s/%s" % (cls.SAMPLES_PATH, cls.SAMPLE_FILE)
|
sample_path = "%s/%s" % (cls.SAMPLES_PATH, cls.SAMPLE_FILE)
|
||||||
with open(sample_path) as sample_fd:
|
with open(sample_path) as sample_fd:
|
||||||
sample = yaml.load(sample_fd, Loader=yaml.FullLoader)
|
sample = yaml.load(sample_fd, Loader=yaml.FullLoader)
|
||||||
@ -47,9 +60,16 @@ class KubernetesObjectTestCase(testtools.TestCase):
|
|||||||
cls.object = utils.render_template(cls.TEMPLATE_FILE,
|
cls.object = utils.render_template(cls.TEMPLATE_FILE,
|
||||||
name=name, spec=spec)
|
name=name, spec=spec)
|
||||||
|
|
||||||
def test_metadata_has_no_namespace(self):
|
def auto_generation_test_metadata_has_openstack_namespace(self):
|
||||||
"""Ensure that the metadata does not specify the namespace."""
|
"""Ensure that the metadata for auto-generated releases
|
||||||
if self.NAMESPACE_CHECK:
|
has openstack namespace."""
|
||||||
|
if self.AUTO_GENERATED:
|
||||||
|
self.assertIn("namespace", self.object["metadata"])
|
||||||
|
self.assertEqual("openstack", self.object["metadata"]["namespace"])
|
||||||
|
|
||||||
|
def cr_test_metadata_has_no_specific_namespace(self):
|
||||||
|
"""Ensure that the CR metadata has no specific namespace."""
|
||||||
|
if not self.AUTO_GENERATED:
|
||||||
self.assertNotIn("namespace", self.object["metadata"])
|
self.assertNotIn("namespace", self.object["metadata"])
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,5 @@ from openstack_operator.tests.unit import base
|
|||||||
class HeatAPIDeploymentTestCase(base.DeploymentTestCase):
|
class HeatAPIDeploymentTestCase(base.DeploymentTestCase):
|
||||||
"""Basic tests for the Deployment."""
|
"""Basic tests for the Deployment."""
|
||||||
|
|
||||||
SAMPLE_FILE = 'orchestration_v1alpha1_heat.yaml'
|
RELEASE_TYPE = 'heat'
|
||||||
TEMPLATE_FILE = 'heat/deployment.yml.j2'
|
TEMPLATE_FILE = 'heat/deployment.yml.j2'
|
||||||
NAMESPACE_CHECK = False
|
|
||||||
|
@ -23,6 +23,5 @@ from openstack_operator.tests.unit import base
|
|||||||
class HorizonDeploymentTestCase(base.DeploymentTestCase):
|
class HorizonDeploymentTestCase(base.DeploymentTestCase):
|
||||||
"""Basic tests for the Deployment."""
|
"""Basic tests for the Deployment."""
|
||||||
|
|
||||||
SAMPLE_FILE = 'dashboard_v1alpha1_horizon.yaml'
|
RELEASE_TYPE = 'horizon'
|
||||||
TEMPLATE_FILE = 'horizon/deployment.yml.j2'
|
TEMPLATE_FILE = 'horizon/deployment.yml.j2'
|
||||||
NAMESPACE_CHECK = False
|
|
||||||
|
@ -23,6 +23,5 @@ from openstack_operator.tests.unit import base
|
|||||||
class KeystoneDeploymentTestCase(base.DeploymentTestCase):
|
class KeystoneDeploymentTestCase(base.DeploymentTestCase):
|
||||||
"""Basic tests for the Deployment."""
|
"""Basic tests for the Deployment."""
|
||||||
|
|
||||||
SAMPLE_FILE = 'identity_v1alpha1_keystone.yaml'
|
RELEASE_TYPE = 'keystone'
|
||||||
TEMPLATE_FILE = 'keystone/deployment.yml.j2'
|
TEMPLATE_FILE = 'keystone/deployment.yml.j2'
|
||||||
NAMESPACE_CHECK = False
|
|
||||||
|
@ -25,3 +25,4 @@ class McrouterDeploymentTestCase(base.StatefulSetTestCase):
|
|||||||
|
|
||||||
SAMPLE_FILE = 'infrastructure_v1alpha1_mcrouter.yaml'
|
SAMPLE_FILE = 'infrastructure_v1alpha1_mcrouter.yaml'
|
||||||
TEMPLATE_FILE = 'mcrouter/deployment.yml.j2'
|
TEMPLATE_FILE = 'mcrouter/deployment.yml.j2'
|
||||||
|
AUTO_GENERATED = False
|
||||||
|
@ -43,3 +43,4 @@ class MemcachedStatefulSetTestCase(base.StatefulSetTestCase):
|
|||||||
|
|
||||||
SAMPLE_FILE = 'infrastructure_v1alpha1_memcached.yaml'
|
SAMPLE_FILE = 'infrastructure_v1alpha1_memcached.yaml'
|
||||||
TEMPLATE_FILE = 'memcached/statefulset.yml.j2'
|
TEMPLATE_FILE = 'memcached/statefulset.yml.j2'
|
||||||
|
AUTO_GENERATED = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user