[CLAMP] Integrate basic_clamp 72/120072/2
authormorganrol <morgan.richomme@orange.com>
Wed, 31 Mar 2021 17:07:11 +0000 (19:07 +0200)
committermorganrol <morgan.richomme@orange.com>
Wed, 31 Mar 2021 17:23:15 +0000 (19:23 +0200)
Some regressions occured and old files were used
This patch update the different components with the right versions
It also renames the vnf-service in basic_clamp-services.yaml
It creates the entry point and the scenario to integrate the test in xtesting

Issue-ID: INT-1819

Signed-off-by: morganrol <morgan.richomme@orange.com>
Change-Id: I7a9e49d8ddc2c5bd0625a4a5ed940c10aed74f81

setup.cfg
src/onaptests/configuration/basic_clamp_settings.py
src/onaptests/configuration/tca-microservice.yaml
src/onaptests/scenario/basic_clamp.py [new file with mode: 0644]
src/onaptests/steps/loop/instantiate_loop.py
src/onaptests/templates/vnf-services/basic_clamp-service.yaml [moved from src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml with 100% similarity]

index bd131a5..907dfe2 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -51,3 +51,4 @@ xtesting.testcase =
   clearwater_ims = onaptests.scenario.clearwater_ims:ClearwaterIms
   basic_onboard = onaptests.scenario.basic_onboard:BasicOnboard
   pnf_macro = onaptests.scenario.pnf_macro:PnfMacro
+  basic_clamp = onaptests.scenario.basic_clamp:BasicClamp
index d2f38a0..1c6ad61 100644 (file)
@@ -6,6 +6,13 @@ from .settings import * # pylint: disable=W0614
 """ Specific Basic clamp settings."""
 CLEANUP_FLAG = False
 CLAMP_DISTRIBUTION_TIMER = 10
+
+# pylint: disable=bad-whitespace
+# The ONAP part
+SERVICE_DETAILS=("Onboarding, enriching a model with TCA." +
+                 "Design a loop with Clamp and deploy it in Policy and DCAE")
+SERVICE_COMPONENTS="SDC, CLAMP, POLICY, DCAE, DMAAP"
+
 VENDOR_NAME = "basiclamp_vendor"
 
 VSP_NAME = "basiclamp_vsp"
@@ -30,12 +37,10 @@ OPERATIONAL_POLICIES = [
   }
 ]
 
-# SERVICE_NAME = "ubuntu18agent"
-
 # if a yaml file is define, retrieve info from this yaml files
 # if not declare the parameters in the settings
 SERVICE_YAML_TEMPLATE = (sys.path[-1] + "/onaptests/templates/vnf-services/" +
-                         "ubuntu18agent-service.yaml")
+                         "basic_clamp-service.yaml")
 CONFIGURATION_PATH = sys.path[-1] + "/onaptests/configuration/"
 
 try:
index e7d967a..0f13c53 100644 (file)
@@ -19,7 +19,7 @@
 tosca_definitions_version: cloudify_dsl_1_3
 imports:
   - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
-  - plugin:k8splugin?version=3.4.2
+  - plugin:k8splugin?version=>=3.4.3,<4.0.0
   - plugin:clamppolicyplugin?version=1.1.0
 inputs:
   service_name:
diff --git a/src/onaptests/scenario/basic_clamp.py b/src/onaptests/scenario/basic_clamp.py
new file mode 100644 (file)
index 0000000..d3a9ba1
--- /dev/null
@@ -0,0 +1,47 @@
+"""Basic Clamp test case."""
+import logging
+import time
+from xtesting.core import testcase
+from onapsdk.configuration import settings
+from onapsdk.exceptions import SDKException, APIError
+from onaptests.steps.loop.clamp import ClampStep
+from onaptests.utils.exceptions import OnapTestException
+class BasicClamp(testcase.TestCase):
+    """Onboard, update a model with a loop, design the loop and deploy it."""
+    __logger = logging.getLogger(__name__)
+    def __init__(self, **kwargs):
+        """Init Basic Clamp, onboard a VM, design and deploy a loop with CLAMP."""
+        if "case_name" not in kwargs:
+            kwargs["case_name"] = 'basic_clamp'
+        super(BasicClamp, self).__init__(**kwargs)
+        self.__logger.debug("Basic CLAMP init started")
+        self.test = ClampStep(
+                cleanup=settings.CLEANUP_FLAG)
+        self.start_time = None
+        self.stop_time = None
+        self.result = 0
+    def run(self):
+        """Run Basic CLAMP onap test."""
+        self.start_time = time.time()
+        self.__logger.debug("start time")
+        try:
+            self.test.execute()
+            self.__logger.info("VNF basic_clamp successfully created")
+            # The cleanup is part of the test, not only a teardown action
+            if settings.CLEANUP_FLAG:
+                self.__logger.info("VNF basic_clamp cleanup called")
+                time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
+                self.test.cleanup()
+                self.result = 100
+            else:
+                self.__logger.info("No cleanup requested. Test completed.")
+                self.result = 100
+        except (OnapTestException, SDKException, APIError) as exc:
+            self.result = 0
+            self.__logger.error(exc.error_message)
+        finally:
+            self.stop_time = time.time()
+    def clean(self):
+        """Clean Additional resources if needed."""
+        self.__logger.info("Generate Test report")
+        self.test.reports_collection.generate_report()
index bd34a04..b6f4ffa 100644 (file)
@@ -11,11 +11,10 @@ from onapsdk.configuration import settings
 class InstantiateLoop():
     """class instantiating a closed loop in clamp."""
 
-    def __init__(self, template: str, loop_name: str, operational_policies: list, cert: tuple):
+    def __init__(self, template: str, loop_name: str, operational_policies: list):
         self.template=template
         self.loop_name=loop_name
         self.operational_policies=operational_policies
-        self.cert=cert
 
         self._logger: logging.Logger = logging.getLogger("")
         logging.config.dictConfig(settings.LOG_CONFIG)
@@ -71,8 +70,7 @@ class InstantiateLoop():
         """Instantiate the control loop."""
         loop = LoopInstance(template=self.template,
                             name=self.loop_name,
-                            details={},
-                            cert=self.cert)
+                            details={})
         details = loop.create()
         if details:
             self._logger.info("Loop instance %s successfully created !!", self.loop_name)