aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2024-01-17 15:00:55 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2024-01-17 15:05:24 +0100
commit0810d1a2e98d6e811f7980cb692f4909dcab94a5 (patch)
tree5fd817837fa1d293d4462bd08470eeaed0c12e7d /functest_kubernetes
parent2a2111aa615b77c5c8ffd8390f3a90f675f5f99b (diff)
Patch cnf_testsuite namespaces if they exist
Change-Id: Ibace5356cb1f458fa8b929c0c84b2f06e5852ea0 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 9cb990f8f874f395fe6aa7f045fa9dcc3fdb35c4)
Diffstat (limited to 'functest_kubernetes')
-rw-r--r--functest_kubernetes/cnf_conformance/conformance.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/functest_kubernetes/cnf_conformance/conformance.py b/functest_kubernetes/cnf_conformance/conformance.py
index 7832e5c8..1c72a05d 100644
--- a/functest_kubernetes/cnf_conformance/conformance.py
+++ b/functest_kubernetes/cnf_conformance/conformance.py
@@ -63,13 +63,27 @@ class CNFConformance(testcase.TestCase):
"""Implement initialization and pre-reqs steps"""
if os.path.exists(os.path.join(self.src_dir, "results")):
shutil.rmtree(os.path.join(self.src_dir, "results"))
+ api_response = self.corev1.list_namespace()
for namespace in ["cnf-testsuite", "default", "litmus"]:
- api_response = self.corev1.create_namespace(
- client.V1Namespace(metadata=client.V1ObjectMeta(
- generate_name=namespace, labels={
- "pod-security.kubernetes.io/enforce": "baseline"})))
- self.__logger.debug(
- "create_namespace: %s", api_response.metadata.name)
+ for ns in api_response.items:
+ if ns.metadata.name == namespace:
+ self.corev1.patch_namespace(
+ namespace,
+ client.V1Namespace(metadata=client.V1ObjectMeta(
+ labels={
+ "pod-security.kubernetes.io/enforce":
+ "baseline"})))
+ self.__logger.debug(
+ "patch_namespace: %s", namespace)
+ break
+ else:
+ self.corev1.create_namespace(
+ client.V1Namespace(metadata=client.V1ObjectMeta(
+ name=namespace, labels={
+ "pod-security.kubernetes.io/enforce":
+ "baseline"})))
+ self.__logger.debug(
+ "create_namespace: %s", namespace)
os.chdir(self.src_dir)
cmd = ['cnf-testsuite', 'setup', '-l', 'debug']
try: