diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2021-05-12 15:52:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-05-12 15:52:48 +0000 |
commit | fa5a450766a95644af70bb3a648dcab936fc97e0 (patch) | |
tree | ab29d12600cb26d0c5392001f18a8fde12bcb601 /src/onaptests/steps/onboard/cds.py | |
parent | 7ad3d1fd3b3f85c1a3154630da3ef00ce0e439a5 (diff) | |
parent | 0e02e3c314f6787cfbddee6f32b9776225ddec16 (diff) |
Merge "[TEST] Catch k8s connection exceptions"
Diffstat (limited to 'src/onaptests/steps/onboard/cds.py')
-rw-r--r-- | src/onaptests/steps/onboard/cds.py | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py index f137adb..3ef37f2 100644 --- a/src/onaptests/steps/onboard/cds.py +++ b/src/onaptests/steps/onboard/cds.py @@ -9,8 +9,10 @@ from kubernetes import client, config from onapsdk.cds import Blueprint, DataDictionarySet from onapsdk.cds.blueprint_processor import Blueprintprocessor from onapsdk.configuration import settings +import urllib3 from ..base import BaseStep +from onaptests.utils.exceptions import OnapTestException class CDSBaseStep(BaseStep, ABC): @@ -48,11 +50,15 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep): super().execute() config.load_kube_config(settings.K8S_CONFIG) self.k8s_client = client.CoreV1Api() - self.k8s_client.patch_namespaced_service( - self.service_name, - settings.K8S_NAMESPACE, - {"spec": {"ports": [{"port": 8080, "nodePort": 30449}], "type": "NodePort"}} - ) + try: + self.k8s_client.patch_namespaced_service( + self.service_name, + settings.K8S_NAMESPACE, + {"spec": {"ports": [{"port": 8080, "nodePort": 30449}], "type": "NodePort"}} + ) + except urllib3.exceptions.HTTPError: + self._logger.exception("Can't connect with k8s") + raise OnapTestException def cleanup(self) -> None: """Step cleanup. @@ -60,22 +66,26 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep): Restore CDS blueprintprocessor service. """ - self.k8s_client.patch_namespaced_service( - self.service_name, - settings.K8S_NAMESPACE, - [ - { - "op": "remove", - "path": "/spec/ports/0/nodePort" - }, - { - "op": "replace", - "path": "/spec/type", - "value": "ClusterIP" - } - ] - ) - return super().cleanup() + try: + self.k8s_client.patch_namespaced_service( + self.service_name, + settings.K8S_NAMESPACE, + [ + { + "op": "remove", + "path": "/spec/ports/0/nodePort" + }, + { + "op": "replace", + "path": "/spec/type", + "value": "ClusterIP" + } + ] + ) + return super().cleanup() + except urllib3.exceptions.HTTPError: + self._logger.exception("Can't connect with k8s") + raise OnapTestException class BootstrapBlueprintprocessor(CDSBaseStep): |