From c5f7f5e4d905171c1f0663bcb64ee050985a2d0b Mon Sep 17 00:00:00 2001 From: morganrol Date: Wed, 31 Mar 2021 19:07:11 +0200 Subject: [CLAMP] Integrate basic_clamp 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 Change-Id: I7a9e49d8ddc2c5bd0625a4a5ed940c10aed74f81 --- setup.cfg | 1 + .../configuration/basic_clamp_settings.py | 11 +++-- src/onaptests/configuration/tca-microservice.yaml | 2 +- src/onaptests/scenario/basic_clamp.py | 47 ++++++++++++++++++++++ src/onaptests/steps/loop/instantiate_loop.py | 6 +-- .../vnf-services/basic_clamp-service.yaml | 39 ++++++++++++++++++ .../vnf-services/ubuntu18agent-service.yaml | 39 ------------------ 7 files changed, 98 insertions(+), 47 deletions(-) create mode 100644 src/onaptests/scenario/basic_clamp.py create mode 100644 src/onaptests/templates/vnf-services/basic_clamp-service.yaml delete mode 100644 src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml diff --git a/setup.cfg b/setup.cfg index bd131a5..907dfe2 100644 --- 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 diff --git a/src/onaptests/configuration/basic_clamp_settings.py b/src/onaptests/configuration/basic_clamp_settings.py index d2f38a0..1c6ad61 100644 --- a/src/onaptests/configuration/basic_clamp_settings.py +++ b/src/onaptests/configuration/basic_clamp_settings.py @@ -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: diff --git a/src/onaptests/configuration/tca-microservice.yaml b/src/onaptests/configuration/tca-microservice.yaml index e7d967a..0f13c53 100644 --- a/src/onaptests/configuration/tca-microservice.yaml +++ b/src/onaptests/configuration/tca-microservice.yaml @@ -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 index 0000000..d3a9ba1 --- /dev/null +++ b/src/onaptests/scenario/basic_clamp.py @@ -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() diff --git a/src/onaptests/steps/loop/instantiate_loop.py b/src/onaptests/steps/loop/instantiate_loop.py index bd34a04..b6f4ffa 100644 --- a/src/onaptests/steps/loop/instantiate_loop.py +++ b/src/onaptests/steps/loop/instantiate_loop.py @@ -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) diff --git a/src/onaptests/templates/vnf-services/basic_clamp-service.yaml b/src/onaptests/templates/vnf-services/basic_clamp-service.yaml new file mode 100644 index 0000000..f5fe653 --- /dev/null +++ b/src/onaptests/templates/vnf-services/basic_clamp-service.yaml @@ -0,0 +1,39 @@ +--- +basicclamp: + vnfs: + - vnf_name: basicclamp + heat_files_to_upload: onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip + vnf_parameters: [ + {"name": "ubuntu18_image_name", + "value": "ubuntu-agent" + }, + {"name": "ubuntu18_key_name", + "value": "cleouverte" + }, + {"name": "ubuntu18_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": "ubuntu18_flavor_name", + "value": "m1.smaller" + }, + {"name": "VM_name", + "value": "ubuntu18agent-VM-01" + }, + {"name": "vnf_id", + "value": "ubuntu18agent-VNF-instance" + }, + {"name": "vf_module_id", + "value": "ubuntu18agent-vfmodule-instance" + }, + {"name": "vnf_name", + "value": "ubuntu18agent-VNF" + }, + {"name": "admin_plane_net_name", + "value": "admin" + } + ] diff --git a/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml b/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml deleted file mode 100644 index f5fe653..0000000 --- a/src/onaptests/templates/vnf-services/ubuntu18agent-service.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -basicclamp: - vnfs: - - vnf_name: basicclamp - heat_files_to_upload: onaptests/templates/heat-files/ubuntu18/ubuntu18agent.zip - vnf_parameters: [ - {"name": "ubuntu18_image_name", - "value": "ubuntu-agent" - }, - {"name": "ubuntu18_key_name", - "value": "cleouverte" - }, - {"name": "ubuntu18_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": "ubuntu18_flavor_name", - "value": "m1.smaller" - }, - {"name": "VM_name", - "value": "ubuntu18agent-VM-01" - }, - {"name": "vnf_id", - "value": "ubuntu18agent-VNF-instance" - }, - {"name": "vf_module_id", - "value": "ubuntu18agent-vfmodule-instance" - }, - {"name": "vnf_name", - "value": "ubuntu18agent-VNF" - }, - {"name": "admin_plane_net_name", - "value": "admin" - } - ] -- cgit 1.2.3-korg