diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2020-08-13 10:34:48 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2020-08-13 12:09:51 +0200 |
commit | 019101492b51aa74412265cd99ba1a9e27a3de8c (patch) | |
tree | 62a0d91725468394a54b52791fb36b6abf483607 /functest_kubernetes/ims | |
parent | fac999583784f6e3b2c64294f2347fdf8a7a64f0 (diff) |
Make K8s_vims namespace aware
It now creates a namespace to allow running the test case twice in
parallel (see DNS requests).
Change-Id: Ib47b3fb2d753f8259d9224cb79168cde68d8e854
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest_kubernetes/ims')
-rw-r--r-- | functest_kubernetes/ims/ims.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py index 3ff2d6b5..aafeacd4 100644 --- a/functest_kubernetes/ims/ims.py +++ b/functest_kubernetes/ims/ims.py @@ -24,7 +24,7 @@ import pkg_resources from xtesting.core import testcase -class Vims(testcase.TestCase): +class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes """Deploy and test Clearwater vIMS using Kubernetes It leverage on the Python kubernetes client to apply operation proposed by @@ -32,8 +32,6 @@ class Vims(testcase.TestCase): See https://github.com/Metaswitch/clearwater-docker for more details """ - namespace = 'default' - zone = 'default.svc.cluster.local' watch_timeout = 1200 metadata_name = "env-vars" test_image_name = "ollivier/clearwater-live-test:latest" @@ -52,6 +50,8 @@ class Vims(testcase.TestCase): self.appsv1 = client.AppsV1Api() self.output_log_name = 'functest-kubernetes.log' self.output_debug_log_name = 'functest-kubernetes.debug.log' + self.namespace = "" + self.zone = "" def deploy_vnf(self): """Deploy vIMS as proposed by clearwater-docker @@ -61,8 +61,14 @@ class Vims(testcase.TestCase): See https://github.com/Metaswitch/clearwater-docker for more details """ + api_response = self.corev1.create_namespace( + client.V1Namespace(metadata=client.V1ObjectMeta( + generate_name="ims-"))) + self.namespace = api_response.metadata.name + self.__logger.debug("create_namespace: %s", api_response) metadata = client.V1ObjectMeta( name=self.metadata_name, namespace=self.namespace) + self.zone = '{}.svc.cluster.local'.format(self.namespace) body = client.V1ConfigMap( metadata=metadata, data={"ADDITIONAL_SHARED_CONFIG": "", "ZONE": self.zone}) @@ -75,7 +81,7 @@ class Vims(testcase.TestCase): 'ims/{}-depl.yaml'.format(deployment))) as yfile: body = yaml.safe_load(yfile) resp = self.appsv1.create_namespaced_deployment( - body=body, namespace="default") + body=body, namespace=self.namespace) self.__logger.info("Deployment %s created", resp.metadata.name) self.__logger.debug( "create_namespaced_deployment: %s", api_response) @@ -85,7 +91,7 @@ class Vims(testcase.TestCase): 'ims/{}-svc.yaml'.format(service))) as yfile: body = yaml.safe_load(yfile) resp = self.corev1.create_namespaced_service( - body=body, namespace="default") + body=body, namespace=self.namespace) self.__logger.info("Service %s created", resp.metadata.name) self.__logger.debug( "create_namespaced_service: %s", api_response) @@ -115,7 +121,11 @@ class Vims(testcase.TestCase): See https://github.com/Metaswitch/clearwater-live-test for more details """ container = client.V1Container( - name=self.test_container_name, image=self.test_image_name) + name=self.test_container_name, image=self.test_image_name, + command=["rake", "test[{}]".format(self.zone), + "PROXY=bono.{}".format(self.zone), + "ELLIS=ellis.{}".format(self.zone), + "SIGNUP_CODE=secret", "--trace"]) spec = client.V1PodSpec(containers=[container], restart_policy="Never") metadata = client.V1ObjectMeta(name=self.test_container_name) body = client.V1Pod(metadata=metadata, spec=spec) @@ -191,3 +201,8 @@ class Vims(testcase.TestCase): "delete_namespaced_service: %s", api_response) except client.rest.ApiException: pass + try: + api_response = self.corev1.delete_namespace(self.namespace) + self.__logger.debug("delete_namespace: %s", self.namespace) + except client.rest.ApiException: + pass |