aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud/check_status.py
diff options
context:
space:
mode:
authormichal.jagiello@t-mobile.pl <michal.jagiello@t-mobile.pl>2024-04-04 10:47:55 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2024-04-04 13:43:01 +0200
commitd0249740266842e4cc4febb3c47243c0b95f8f39 (patch)
tree1bad851acb7db44bf776d3ac8d1cd9974e57a6e8 /src/onaptests/steps/cloud/check_status.py
parent7e8c2a76266d0c5976183302d0cca21a1ab2df32 (diff)
Refactor code a bit to make status test able running on multiple namespaces
It's possible to run status on all tests and also exclude some namespaces from check Issue-ID: TEST-404 Change-Id: I33c54624f60b1c4db82a252d97a26e18464ed07f Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Diffstat (limited to 'src/onaptests/steps/cloud/check_status.py')
-rw-r--r--src/onaptests/steps/cloud/check_status.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/onaptests/steps/cloud/check_status.py b/src/onaptests/steps/cloud/check_status.py
index 359e830..5a4b962 100644
--- a/src/onaptests/steps/cloud/check_status.py
+++ b/src/onaptests/steps/cloud/check_status.py
@@ -66,7 +66,7 @@ class CheckK8sResourcesStep(BaseStep):
@property
def is_primary(self) -> bool:
"""Does step analyses primary namespace."""
- return self.namespace == settings.K8S_ONAP_NAMESPACE
+ return self.namespace == settings.K8S_TESTS_NAMESPACE
def _init_resources(self):
if self.resource_type != "":
@@ -772,7 +772,7 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
def __init__(self):
"""Init CheckNamespaceStatusStep."""
- super().__init__(namespace=settings.K8S_ONAP_NAMESPACE, resource_type="")
+ super().__init__(namespace=settings.K8S_TESTS_NAMESPACE, resource_type="")
self.__logger.debug("K8s namespaces status test init started")
self.job_list_step = None
@@ -792,7 +792,13 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
config.load_incluster_config()
else:
config.load_kube_config(config_file=settings.K8S_CONFIG)
- for namespace in ([self.namespace] + settings.EXTRA_NAMESPACE_LIST):
+ if settings.CHECK_ALL_NAMESPACES or settings.EXCLUDE_NAMESPACE_LIST:
+ self.namespaces_to_check_set = {namespace.metadata.name for namespace in
+ client.CoreV1Api().list_namespace().items} - set(
+ settings.EXCLUDE_NAMESPACE_LIST)
+ else:
+ self.namespaces_to_check_set = set([self.namespace] + settings.EXTRA_NAMESPACE_LIST)
+ for namespace in self.namespaces_to_check_set:
self._init_namespace_steps(namespace)
self.pods = []
self.services = []
@@ -827,7 +833,7 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
ingress_list_step = CheckK8sIngressesStep(namespace)
pvc_list_step = CheckK8sPvcsStep(namespace)
node_list_step = CheckK8sNodesStep(namespace)
- if namespace == settings.K8S_ONAP_NAMESPACE:
+ if namespace == settings.K8S_TESTS_NAMESPACE:
self.job_list_step = job_list_step
self.pod_list_step = pod_list_step
self.service_list_step = service_list_step
@@ -868,11 +874,10 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
"""Check status of all k8s resources in the selected namespaces.
Use settings values:
- - K8S_ONAP_NAMESPACE
+ - K8S_TESTS_NAMESPACE
- STATUS_RESULTS_DIRECTORY
- STORE_ARTIFACTS
- CHECK_POD_VERSIONS
- - EXTRA_NAMESPACE_LIST
- IGNORE_EMPTY_REPLICAS
- INCLUDE_ALL_RES_IN_DETAILS
"""
@@ -905,7 +910,7 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
self.res_dir))
details = {"namespace": {
- "all": settings.EXTRA_NAMESPACE_LIST,
+ "all": list(self.namespaces_to_check_set - set([self.namespace])),
"resources": {}
}}