aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps/cloud')
-rw-r--r--src/onaptests/steps/cloud/check_status.py79
-rw-r--r--src/onaptests/steps/cloud/cloud_region_create.py4
-rw-r--r--src/onaptests/steps/cloud/complex_create.py4
-rw-r--r--src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py12
-rw-r--r--src/onaptests/steps/cloud/customer_create.py4
-rw-r--r--src/onaptests/steps/cloud/customer_service_subscription_create.py6
-rw-r--r--src/onaptests/steps/cloud/k8s_connectivity_info_create.py4
-rw-r--r--src/onaptests/steps/cloud/link_cloud_to_complex.py6
-rw-r--r--src/onaptests/steps/cloud/register_cloud.py6
9 files changed, 62 insertions, 63 deletions
diff --git a/src/onaptests/steps/cloud/check_status.py b/src/onaptests/steps/cloud/check_status.py
index 168c212..5b572f1 100644
--- a/src/onaptests/steps/cloud/check_status.py
+++ b/src/onaptests/steps/cloud/check_status.py
@@ -29,9 +29,9 @@ class CheckK8sResourcesStep(BaseStep):
__logger = logging.getLogger(__name__)
- def __init__(self, resource_type: str, **kwargs):
+ def __init__(self, resource_type: str, break_on_error=False):
"""Init CheckK8sResourcesStep."""
- super().__init__(cleanup=False)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP, break_on_error=break_on_error)
self.core = client.CoreV1Api()
self.batch = client.BatchV1Api()
self.app = client.AppsV1Api()
@@ -61,7 +61,9 @@ class CheckK8sResourcesStep(BaseStep):
return f"Check status of all k8s {self.resource_type}s in the {NAMESPACE} namespace."
def _init_resources(self):
- self.__logger.debug(f"Loading all k8s {self.resource_type}s in the {NAMESPACE} namespace")
+ if self.resource_type != "":
+ self.__logger.debug(f"Loading all k8s {self.resource_type}s"
+ " in the {NAMESPACE} namespace")
def _parse_resources(self):
"""Parse the resources."""
@@ -92,16 +94,17 @@ class CheckK8sResourcesStep(BaseStep):
len(self.all_resources),
self.resource_type,
len(self.failing_resources))
- except (ConnectionRefusedError, MaxRetryError, NewConnectionError):
+ if self.failing:
+ raise StatusCheckException(f"{self.resource_type} test failed")
+ except (ConnectionRefusedError, MaxRetryError, NewConnectionError) as e:
self.__logger.error("Test of k8s %ss failed.", self.resource_type)
self.__logger.error("Cannot connect to Kubernetes.")
+ raise StatusCheckException from e
class CheckBasicK8sResourcesStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, resource_type: str, k8s_res_class, cleanup: bool = False, **kwargs):
+ def __init__(self, resource_type: str, k8s_res_class):
"""Init CheckBasicK8sResourcesStep."""
super().__init__(resource_type)
self.k8s_res_class = k8s_res_class
@@ -120,9 +123,7 @@ class CheckBasicK8sResourcesStep(CheckK8sResourcesStep):
class CheckK8sConfigMapsStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sConfigMapsStep."""
super().__init__("configmap", ConfigMap)
@@ -133,9 +134,7 @@ class CheckK8sConfigMapsStep(CheckBasicK8sResourcesStep):
class CheckK8sSecretsStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sSecretsStep."""
super().__init__("secret", Secret)
@@ -146,9 +145,7 @@ class CheckK8sSecretsStep(CheckBasicK8sResourcesStep):
class CheckK8sIngressesStep(CheckBasicK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sIngressesStep."""
super().__init__("ingress", Ingress)
@@ -159,9 +156,7 @@ class CheckK8sIngressesStep(CheckBasicK8sResourcesStep):
class CheckK8sPvcsStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sPvcsStep."""
super().__init__("pvc")
@@ -193,9 +188,7 @@ class CheckK8sPvcsStep(CheckK8sResourcesStep):
class CheckK8sResourcesUsingPodsStep(CheckK8sResourcesStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, resource_type: str, pods_source, cleanup: bool = False, **kwargs):
+ def __init__(self, resource_type: str, pods_source):
"""Init CheckK8sResourcesUsingPodsStep."""
super().__init__(resource_type)
self.pods_source = pods_source
@@ -232,9 +225,7 @@ class CheckK8sResourcesUsingPodsStep(CheckK8sResourcesStep):
class CheckK8sJobsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckK8sJobsStep."""
super().__init__("job", None)
@@ -279,7 +270,7 @@ class CheckK8sPodsStep(CheckK8sResourcesUsingPodsStep):
__logger = logging.getLogger(__name__)
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sPodsStep."""
super().__init__("pod", pods)
@@ -516,9 +507,7 @@ class CheckK8sPodsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sServicesStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sServicesStep."""
super().__init__("service", pods)
@@ -543,9 +532,7 @@ class CheckK8sServicesStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sDeploymentsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sDeploymentsStep."""
super().__init__("deployment", pods)
@@ -581,12 +568,10 @@ class CheckK8sDeploymentsStep(CheckK8sResourcesUsingPodsStep):
self.all_resources.append(deployment)
-class CheckK8sResplicaSetsStep(CheckK8sResourcesUsingPodsStep):
-
- __logger = logging.getLogger(__name__)
+class CheckK8sReplicaSetsStep(CheckK8sResourcesUsingPodsStep):
- def __init__(self, pods, cleanup: bool = False, **kwargs):
- """Init CheckK8sResplicaSetsStep."""
+ def __init__(self, pods):
+ """Init CheckK8sReplicaSetsStep."""
super().__init__("replicaset", pods)
def _init_resources(self):
@@ -625,9 +610,7 @@ class CheckK8sResplicaSetsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sStatefulSetsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sStatefulSetsStep."""
super().__init__("statefulset", pods)
@@ -667,9 +650,7 @@ class CheckK8sStatefulSetsStep(CheckK8sResourcesUsingPodsStep):
class CheckK8sDaemonSetsStep(CheckK8sResourcesUsingPodsStep):
- __logger = logging.getLogger(__name__)
-
- def __init__(self, pods, cleanup: bool = False, **kwargs):
+ def __init__(self, pods):
"""Init CheckK8sDaemonSetsStep."""
super().__init__("daemonset", pods)
@@ -711,9 +692,9 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
__logger = logging.getLogger(__name__)
- def __init__(self, cleanup: bool = False, **kwargs):
+ def __init__(self):
"""Init CheckNamespaceStatusStep."""
- super().__init__("")
+ super().__init__(resource_type="")
self.__logger.debug("%s namespace status test init started", NAMESPACE)
if settings.IN_CLUSTER:
config.load_incluster_config()
@@ -724,7 +705,7 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
self.pod_list_step = CheckK8sPodsStep(self.job_list_step)
self.service_list_step = CheckK8sServicesStep(self.pod_list_step)
self.deployment_list_step = CheckK8sDeploymentsStep(self.pod_list_step)
- self.replicaset_list_step = CheckK8sResplicaSetsStep(self.pod_list_step)
+ self.replicaset_list_step = CheckK8sReplicaSetsStep(self.pod_list_step)
self.statefulset_list_step = CheckK8sStatefulSetsStep(self.pod_list_step)
self.daemonset_list_step = CheckK8sDaemonSetsStep(self.pod_list_step)
self.configmap_list_step = CheckK8sConfigMapsStep()
@@ -799,11 +780,13 @@ class CheckNamespaceStatusStep(CheckK8sResourcesStep):
step.resource_type,
len(step.failing_resources))
details[step.resource_type] = {
- 'number_all': len(step.all_resources),
'number_failing': len(step.failing_resources),
- 'all': self.map_by_name(step.all_resources),
'failing': self.map_by_name(step.failing_resources)
}
+ if settings.INCLUDE_ALL_RES_IN_DETAILS:
+ details[step.resource_type]['all'] = self.map_by_name(step.all_resources)
+ details[step.resource_type]['number_all'] = len(step.all_resources)
+
with (Path(self.res_dir).joinpath(settings.STATUS_DETAILS_JSON)).open('w') as file:
json.dump(details, file, indent=4)
if self.failing:
diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py
index 21c846f..fcda251 100644
--- a/src/onaptests/steps/cloud/cloud_region_create.py
+++ b/src/onaptests/steps/cloud/cloud_region_create.py
@@ -9,6 +9,10 @@ from ..base import BaseStep
class CloudRegionCreateStep(BaseStep):
"""Cloud region creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/complex_create.py b/src/onaptests/steps/cloud/complex_create.py
index 60565f4..96d8e7f 100644
--- a/src/onaptests/steps/cloud/complex_create.py
+++ b/src/onaptests/steps/cloud/complex_create.py
@@ -8,6 +8,10 @@ from ..base import BaseStep
class ComplexCreateStep(BaseStep):
"""Complex creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
index 3bb08c7..8307b45 100644
--- a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
+++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
@@ -12,7 +12,7 @@ from .k8s_connectivity_info_create import K8SConnectivityInfoStep
class ConnectServiceSubToCloudRegionStep(BaseStep):
"""Connect service subscription to cloud region step."""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
@@ -21,12 +21,12 @@ class ConnectServiceSubToCloudRegionStep(BaseStep):
- CustomerServiceSubscriptionCreateStep.
"""
- super().__init__(cleanup=cleanup)
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
if settings.CLOUD_REGION_TYPE == settings.K8S_REGION_TYPE:
- self.add_step(K8SConnectivityInfoStep(cleanup=cleanup))
- self.add_step(RegisterCloudRegionStep(cleanup=cleanup))
- self.add_step(LinkCloudRegionToComplexStep(cleanup=cleanup))
- self.add_step(CustomerServiceSubscriptionCreateStep(cleanup=cleanup))
+ self.add_step(K8SConnectivityInfoStep())
+ self.add_step(RegisterCloudRegionStep())
+ self.add_step(LinkCloudRegionToComplexStep())
+ self.add_step(CustomerServiceSubscriptionCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/customer_create.py b/src/onaptests/steps/cloud/customer_create.py
index 1cc0879..96d192a 100644
--- a/src/onaptests/steps/cloud/customer_create.py
+++ b/src/onaptests/steps/cloud/customer_create.py
@@ -8,6 +8,10 @@ from ..base import BaseStep
class CustomerCreateStep(BaseStep):
"""Customer creation step."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/customer_service_subscription_create.py b/src/onaptests/steps/cloud/customer_service_subscription_create.py
index 67de141..533b2b8 100644
--- a/src/onaptests/steps/cloud/customer_service_subscription_create.py
+++ b/src/onaptests/steps/cloud/customer_service_subscription_create.py
@@ -9,14 +9,14 @@ from .customer_create import CustomerCreateStep
class CustomerServiceSubscriptionCreateStep(BaseStep):
"""Cutomer service subsription creation step"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- CustomerCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CustomerCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CustomerCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
index adcf862..c22df47 100644
--- a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
+++ b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
@@ -10,6 +10,10 @@ from onaptests.steps.base import BaseStep
class K8SConnectivityInfoStep(BaseStep):
"""CreateConnnectivityInfoStep."""
+ def __init__(self):
+ """Initialize step."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
@property
def description(self) -> str:
"""Step description."""
diff --git a/src/onaptests/steps/cloud/link_cloud_to_complex.py b/src/onaptests/steps/cloud/link_cloud_to_complex.py
index fcfa711..8f5dad6 100644
--- a/src/onaptests/steps/cloud/link_cloud_to_complex.py
+++ b/src/onaptests/steps/cloud/link_cloud_to_complex.py
@@ -8,15 +8,15 @@ from .complex_create import ComplexCreateStep
class LinkCloudRegionToComplexStep(BaseStep):
"""Link cloud region to complex step"""
- def __init__(self, cleanup=False):
+ def __init__(self):
"""Initialize step.
Substeps:
- ComplexCreateStep,
- CloudRegionCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(ComplexCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(ComplexCreateStep())
@property
def description(self) -> str:
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py
index c6b440f..fbfb6f3 100644
--- a/src/onaptests/steps/cloud/register_cloud.py
+++ b/src/onaptests/steps/cloud/register_cloud.py
@@ -13,14 +13,14 @@ from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep
class RegisterCloudRegionStep(BaseStep):
"""Cloud region registration step."""
- def __init__(self, cleanup: bool) -> None:
+ def __init__(self) -> None:
"""Initialize step.
Substeps:
- CloudRegionCreateStep.
"""
- super().__init__(cleanup=cleanup)
- self.add_step(CloudRegionCreateStep(cleanup=cleanup))
+ super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
+ self.add_step(CloudRegionCreateStep())
@property
def description(self) -> str: