aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2023-01-16 15:17:01 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2023-03-15 10:18:22 +0000
commitd6d052a5f1ce0ae0f0debcbb11220fce1c1dfdc5 (patch)
tree13c6f43901458af1e66c1e149e43c324f2e19043
parentef50809c847aca4a198c89fb846eb44046036032 (diff)
Add cleanup to sdc resources ondboarding step
Delete SDC resources on cleanup Bump onapsdk requirements to 10.4.2 Issue-ID: INT-2193 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: Id9e51f07a9c91a02b67a87eb897a2a4d19fa6738
-rw-r--r--requirements.txt2
-rw-r--r--run_basic_onboard.py1
-rw-r--r--src/onaptests/configuration/basic_onboard_settings.py5
-rw-r--r--src/onaptests/configuration/settings.py4
-rw-r--r--src/onaptests/scenario/basic_onboard.py1
-rw-r--r--src/onaptests/steps/onboard/pnf.py14
-rw-r--r--src/onaptests/steps/onboard/service.py14
-rw-r--r--src/onaptests/steps/onboard/vendor.py7
-rw-r--r--src/onaptests/steps/onboard/vf.py14
-rw-r--r--src/onaptests/steps/onboard/vsp.py21
10 files changed, 79 insertions, 4 deletions
diff --git a/requirements.txt b/requirements.txt
index 3ff4276..ed997bd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,6 @@ cryptography==38.0.4
xtesting==0.91.0
avionix>=0.4.5
openstacksdk>=0.61.0
-onapsdk==10.4.1
+onapsdk==10.4.2
jinja2>3
kubernetes>=22.6.0
diff --git a/run_basic_onboard.py b/run_basic_onboard.py
index 835c661..8b00699 100644
--- a/run_basic_onboard.py
+++ b/run_basic_onboard.py
@@ -15,6 +15,7 @@ if __name__ == "__main__":
cleanup=settings.CLEANUP_FLAG)
try:
basic_vm_onboard.execute()
+ basic_vm_onboard.cleanup()
except onap_test_exceptions.TestConfigurationException:
logger.error("Basic Onboard configuration error")
basic_vm_onboard.reports_collection.generate_report()
diff --git a/src/onaptests/configuration/basic_onboard_settings.py b/src/onaptests/configuration/basic_onboard_settings.py
index 8975fa8..de8d95c 100644
--- a/src/onaptests/configuration/basic_onboard_settings.py
+++ b/src/onaptests/configuration/basic_onboard_settings.py
@@ -63,7 +63,6 @@ except (FileNotFoundError, ValueError):
#CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set
VENDOR_NAME = "basic_onboard_vendor"
-VF_NAME = "basic_onboard_vf"
-VSP_NAME = "basic_onboard_vsp"
-
MODEL_YAML_TEMPLATE = None
+CLEANUP_FLAG = True
+SDC_CLEANUP = True
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index e6f894d..482be9e 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -38,6 +38,10 @@ LOG_CONFIG = {
}
}
CLEANUP_FLAG = False
+# Additional flag to enable SDC resources cleanup
+# Added as SDC's VSP deletion is broken and most tests fail due to that
+# Should be removed as soon as SDC resource deletion is fixed
+SDC_CLEANUP = False
REPORTING_FILE_PATH = "/tmp/reporting.html"
K8S_REGION_TYPE = "k8s"
diff --git a/src/onaptests/scenario/basic_onboard.py b/src/onaptests/scenario/basic_onboard.py
index ac4c933..37947f0 100644
--- a/src/onaptests/scenario/basic_onboard.py
+++ b/src/onaptests/scenario/basic_onboard.py
@@ -32,6 +32,7 @@ class BasicOnboard(testcase.TestCase):
self.__logger.debug("start time")
try:
self.test.execute()
+ self.test.cleanup()
self.__logger.info("VNF basic_vm successfully onboarded")
self.result = 100
except OnapTestException as exc:
diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py
index 4e3303e..75fdbcf 100644
--- a/src/onaptests/steps/onboard/pnf.py
+++ b/src/onaptests/steps/onboard/pnf.py
@@ -60,6 +60,12 @@ class PnfOnboardStep(BaseStep):
)
pnf.onboard()
+ @BaseStep.store_state(cleanup=True)
+ def cleanup(self):
+ pnf: Pnf = Pnf(name=settings.PNF_NAME)
+ pnf.delete()
+ super().cleanup()
+
class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
"""PNF onboard using YAML template step."""
@@ -124,3 +130,11 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep):
artifact=pnf["pnf_artifact_file_path"]
)
pnf_obj.onboard()
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self):
+ if "pnfs" in self.yaml_template:
+ for pnf in self.yaml_template["pnfs"]:
+ pnf_obj: Pnf = Pnf(name=pnf["pnf_name"])
+ pnf_obj.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index fa21d2c..60ac279 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -82,6 +82,13 @@ class ServiceOnboardStep(BaseStep):
service.checkin()
service.onboard()
+ @BaseStep.store_state
+ def cleanup(self) -> None:
+ """Cleanup service onboard step."""
+ service: Service = Service(name=settings.SERVICE_NAME)
+ service.delete()
+ super().cleanup()
+
class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Service onboard using YAML template step."""
@@ -253,3 +260,10 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
for property_name, property_value in component_properties.items():
prop: ComponentProperty = component.get_property(property_name)
prop.value = property_value
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self) -> None:
+ """Cleanup service onboard step."""
+ service: Service = Service(name=self.service_name)
+ service.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/vendor.py b/src/onaptests/steps/onboard/vendor.py
index 71b28b9..980a245 100644
--- a/src/onaptests/steps/onboard/vendor.py
+++ b/src/onaptests/steps/onboard/vendor.py
@@ -28,3 +28,10 @@ class VendorOnboardStep(BaseStep):
super().execute()
vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
vendor.onboard()
+
+ @BaseStep.store_state(cleanup=True)
+ def cleanup(self) -> None:
+ vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
+ vendor.archive()
+ vendor.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py
index 852cb82..f77f9af 100644
--- a/src/onaptests/steps/onboard/vf.py
+++ b/src/onaptests/steps/onboard/vf.py
@@ -47,6 +47,12 @@ class VfOnboardStep(BaseStep):
if not vf.created():
vf.onboard()
+ @BaseStep.store_state(cleanup=True)
+ def cleanup(self):
+ vf: Vf = Vf(name=settings.VF_NAME)
+ vf.delete()
+ super().cleanup()
+
class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
"""Vf onboard using YAML template step."""
@@ -122,3 +128,11 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
)
time.sleep(10)
vf.onboard()
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self):
+ if "vnfs" in self.yaml_template:
+ for vnf in self.yaml_template["vnfs"]:
+ vf_obj: Vf = Vf(name=vnf["vnf_name"])
+ vf_obj.delete()
+ super().cleanup()
diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py
index f898268..a7fcf9f 100644
--- a/src/onaptests/steps/onboard/vsp.py
+++ b/src/onaptests/steps/onboard/vsp.py
@@ -44,6 +44,13 @@ class VspOnboardStep(BaseStep):
vsp: Vsp = Vsp(name=settings.VSP_NAME, vendor=vendor, package=open(settings.VSP_FILE_PATH, "rb"))
vsp.onboard()
+ @BaseStep.store_state(cleanup=True)
+ def cleanup(self):
+ vsp: Vsp = Vsp(name=settings.VSP_NAME)
+ vsp.archive()
+ vsp.delete()
+ super().cleanup()
+
class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
"""Vsp onboard using YAML template step."""
@@ -118,3 +125,17 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep):
vendor=vendor,
package=package)
vsp.onboard()
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self) -> None:
+ if "vnfs" in self.yaml_template:
+ for vnf in self.yaml_template["vnfs"]:
+ vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP")
+ vsp.archive()
+ vsp.delete()
+ elif "pnfs" in self.yaml_template:
+ for pnf in self.yaml_template["pnfs"]:
+ vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP")
+ vsp.archive()
+ vsp.delete()
+ super().cleanup()