[TEST] Basic macro stability scenario 28/122428/3
authorMichal Jagiello <michal.jagiello@t-mobile.pl>
Mon, 5 Jul 2021 10:45:05 +0000 (10:45 +0000)
committerMichal Jagiello <michal.jagiello@t-mobile.pl>
Mon, 5 Jul 2021 14:41:55 +0000 (14:41 +0000)
Issue-ID: TEST-349
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I951e9720668de9bf00136d4e043c9fe8950061f1

setup.cfg
src/onaptests/configuration/basic_vm_macro_stability_settings.py [new file with mode: 0644]
src/onaptests/scenario/basic_vm_macro_stability.py [new file with mode: 0644]
src/onaptests/steps/onboard/vf.py
src/onaptests/templates/artifacts/basic_vm_cba_enriched.zip [new file with mode: 0644]
src/onaptests/templates/vnf-services/basic_vm_macro_stability-service.yaml [new file with mode: 0644]

index a2a0d45..3b9c670 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -46,6 +46,7 @@ testpaths = tests
 xtesting.testcase =
   basic_vm = onaptests.scenario.basic_vm:BasicVm
   basic_vm_macro = onaptests.scenario.basic_vm_macro:BasicVmMacro
+  basic_vm_macro_stability = onaptests.scenario.basic_vm_macro_stability:BasicVmMacroStability
   basic_network = onaptests.scenario.basic_network:BasicNetwork
   basic_cnf = onaptests.scenario.basic_cnf:BasicCnf
   basic_cds =  onaptests.scenario.cds_blueprint_enrichment:CDSBlueprintEnrichment
diff --git a/src/onaptests/configuration/basic_vm_macro_stability_settings.py b/src/onaptests/configuration/basic_vm_macro_stability_settings.py
new file mode 100644 (file)
index 0000000..06938c4
--- /dev/null
@@ -0,0 +1,4 @@
+from .basic_vm_macro_settings import *   # pylint: disable=W0614
+
+SERVICE_YAML_TEMPLATE = Path(Path(__file__).parent.parent, "templates/vnf-services/" +
+                         "basic_vm_macro_stability-service.yaml")
diff --git a/src/onaptests/scenario/basic_vm_macro_stability.py b/src/onaptests/scenario/basic_vm_macro_stability.py
new file mode 100644 (file)
index 0000000..552a331
--- /dev/null
@@ -0,0 +1,44 @@
+"""Instantiate basic vm using SO macro flow."""
+import logging
+import time
+
+from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException
+from xtesting.core import testcase
+
+from onaptests.utils.exceptions import OnapTestException
+from onaptests.steps.instantiate.service_macro import YamlTemplateServiceMacroInstantiateStep
+
+
+class BasicVmMacroStability(testcase.TestCase):
+    """Instantiate a basic vm macro."""
+
+    __logger = logging.getLogger(__name__)
+
+    def __init__(self, **kwargs):
+        """Init Basic Macro use case."""
+        if "case_name" not in kwargs:
+            kwargs["case_name"] = 'basic_vm_macro_stability'
+        super().__init__(**kwargs)
+        self.__logger.debug("Basic VM macro stability init started")
+        self.test = YamlTemplateServiceMacroInstantiateStep(cleanup=settings.CLEANUP_FLAG)
+
+    def run(self):
+        """Run basic vm macro test."""
+        self.start_time = time.time()
+        try:
+            self.test.execute()
+            self.test.cleanup()
+            self.result = 100
+        except OnapTestException as exc:
+            self.result = 0
+            self.__logger.error(exc.error_message)
+        except SDKException:
+            self.result = 0
+            self.__logger.error("SDK Exception")
+        finally:
+            self.stop_time = time.time()
+
+    def clean(self):
+        """Generate report."""
+        self.test.reports_collection.generate_report()
index 7e4882e..76aaf2e 100644 (file)
@@ -1,3 +1,5 @@
+from pathlib import Path
+import sys
 import time
 
 from onapsdk.configuration import settings
@@ -94,11 +96,14 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep):
                                                "vnf_artifact_label",
                                                "vnf_artifact_file_path"]]):
                         vf.create()
+                        artifact_file_path: Path = Path(vnf["vnf_artifact_file_path"])
+                        if not artifact_file_path.exists():
+                            artifact_file_path = Path(sys.path[-1], artifact_file_path)
                         vf.add_deployment_artifact(
                             artifact_type=vnf["vnf_artifact_type"],
                             artifact_name=vnf["vnf_artifact_name"],
                             artifact_label=vnf["vnf_artifact_label"],
-                            artifact=vnf["vnf_artifact_file_path"]
+                            artifact=str(artifact_file_path)
                         )
                     time.sleep(10)
                     vf.onboard()
diff --git a/src/onaptests/templates/artifacts/basic_vm_cba_enriched.zip b/src/onaptests/templates/artifacts/basic_vm_cba_enriched.zip
new file mode 100644 (file)
index 0000000..eb63639
Binary files /dev/null and b/src/onaptests/templates/artifacts/basic_vm_cba_enriched.zip differ
diff --git a/src/onaptests/templates/vnf-services/basic_vm_macro_stability-service.yaml b/src/onaptests/templates/vnf-services/basic_vm_macro_stability-service.yaml
new file mode 100644 (file)
index 0000000..fd56a37
--- /dev/null
@@ -0,0 +1,54 @@
+---
+basic_vm_macro:
+    instantiation_type: "Macro"
+    vnfs:
+        - vnf_name: basic_vm_macro
+          properties:
+              controller_actor: "CDS"
+              skip_post_instantiation_configuration: False
+              sdnc_artifact_name: "vnf"
+              sdnc_model_version: "1.0.0"
+              sdnc_model_name: "ubuntu20"
+          vnf_artifact_type: "CONTROLLER_BLUEPRINT_ARCHIVE"
+          vnf_artifact_name: "BASIC_VM_enriched.zip"
+          vnf_artifact_label: "vnfcds"
+          vnf_artifact_file_path: onaptests/templates/artifacts/basic_vm_cba_enriched.zip
+          heat_files_to_upload: onaptests/templates/heat-files/ubuntu20/ubuntu20agent.zip
+          vf_module_parameters:
+              - vf_module_name: base_ubuntu20
+                parameters: [
+                    {"name": "ubuntu20_image_name",
+                     "value": "Ubuntu_2004"
+                    },
+                    {"name": "ubuntu20_key_name",
+                     "value": "cleouverte"
+                    },
+                    {"name": "ubuntu20_pub_key",
+                     "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA\
+  BAQDY15cdBmIs2XOpe4EiFCsaY6bmUmK/GysMoLl4UG51JCfJwvwoWCoA+6mDIbymZxhxq9IGx\
+  ilp/yTA6WQ9s/5pBag1cUMJmFuda9PjOkXl04jgqh5tR6I+GZ97AvCg93KAECis5ubSqw1xOCj4\
+  utfEUtPoF1OuzqM/lE5mY4N6VKXn+fT7pCD6cifBEs6JHhVNvs5OLLp/tO8Pa3kKYQOdyS0xc3r\
+  h+t2lrzvKUSWGZbX+dLiFiEpjsUL3tDqzkEMNUn4pdv69OJuzWHCxRWPfdrY9Wg0j3mJesP29EBh\
+  t+w+EC9/kBKq+1VKdmsXUXAcjEvjovVL8l1BrX3BY0R8D imported-openssh-key"
+                    },
+                    {"name": "ubuntu20_flavor_name",
+                     "value": "m1.smaller"
+                    },
+                    {"name": "VM_name",
+                     "value": "ubuntu20agent-VM-01"
+                    },
+                    {"name": "vnf_id",
+                     "value": "ubuntu20agent-VNF-instance"
+                    },
+                    {"name": "vf_module_id",
+                     "value": "ubuntu20agent-vfmodule-instance"
+                    },
+                    {"name": "vnf_name",
+                     "value": "ubuntu20agent-VNF"
+                    },
+                    {"name": "admin_plane_net_name",
+                     "value": "admin"
+                    },
+                    {"name": "ubuntu20_name_0",
+                     "value": "ubuntu20agent-VNF"}
+                ]