diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-03-22 09:05:21 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-05-11 14:11:07 +0000 |
commit | 71d5c093ccbd7e1efe2bc1226a74b8f592ea9199 (patch) | |
tree | 64570d495dbe0e2c0bd9fc0cc0e18f69dc81b59b | |
parent | ffb3846eac55aac7a50805f18c116ffcfdf2b0bd (diff) |
Nodeport cleanup in basic_cds test
Issue-ID: TEST-317
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I21fe3e4a30c9fed14e05b9f14523de46798466b0
(cherry picked from commit dad0aa604954891777cab4d777106bcfd62e29c7)
-rw-r--r-- | src/onaptests/steps/onboard/cds.py | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py index ed381ad..83579ec 100644 --- a/src/onaptests/steps/onboard/cds.py +++ b/src/onaptests/steps/onboard/cds.py @@ -3,6 +3,7 @@ from abc import ABC from pathlib import Path +from typing import Optional from kubernetes import client, config from onapsdk.cds import Blueprint, DataDictionarySet @@ -24,6 +25,12 @@ class CDSBaseStep(BaseStep, ABC): class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep): """Expose CDS blueprintsprocessor port.""" + def __init__(self, cleanup: bool) -> None: + """Initialize step.""" + super().__init__(cleanup=cleanup) + self.service_name: str = "cds-blueprints-processor-http" + self.client: Optional[client.CoreV1Api] = None + @property def description(self) -> str: """Step description.""" @@ -40,13 +47,36 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep): """ super().execute() config.load_kube_config(settings.K8S_CONFIG) - k8s_client = client.CoreV1Api() - k8s_client.patch_namespaced_service( - "cds-blueprints-processor-http", + 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"}} ) + def cleanup(self) -> None: + """Step cleanup. + + 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() + class BootstrapBlueprintprocessor(CDSBaseStep): """Bootstrap blueprintsprocessor.""" |