diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-07-20 10:15:32 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-11-08 17:17:21 +0000 |
commit | aad04fa2a7e1c9d71f273d26da25436e5c6b779c (patch) | |
tree | 8b247e3c7d2bf22a9b6d50b764afba6946b5e746 /src/onaptests/scenario/cds_resource_resolution.py | |
parent | 1a77bcd6eb5ab695a232004b88e5e59d9d9ff6a3 (diff) |
[TEST] CDS resource-resolution test
Issue-ID: TEST-291
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I5d9f55b67942c62f63e11282ef2383fe063d3137
(cherry picked from commit c31b7fb464fbb8bb0c7d8d2b3dc7b20f4a04cff5)
Diffstat (limited to 'src/onaptests/scenario/cds_resource_resolution.py')
-rw-r--r-- | src/onaptests/scenario/cds_resource_resolution.py | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/onaptests/scenario/cds_resource_resolution.py b/src/onaptests/scenario/cds_resource_resolution.py new file mode 100644 index 0000000..7e9635f --- /dev/null +++ b/src/onaptests/scenario/cds_resource_resolution.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python +"""CDS resource resolution test scenario.""" + +import logging +import time + +from onapsdk.configuration import settings +from onapsdk.exceptions import SDKException +from xtesting.core import testcase + +from onaptests.steps.base import BaseStep +from onaptests.steps.onboard.cds import CbaProcessStep +from onaptests.steps.simulator.cds_mockserver import CdsMockserverCnfConfigureStep +from onaptests.utils.exceptions import OnapTestException + + +class CDSResourceResolutionStep(BaseStep): + """Step created to run scenario and generate report.""" + + def __init__(self, cleanup=False): + """Initialize step. + + Substeps: + - CdsMockserverCnfConfigureStep, + - CbaProcessStep. + """ + super().__init__(cleanup=cleanup) + self.add_step(CdsMockserverCnfConfigureStep( + cleanup=cleanup + )) + self.add_step(CbaProcessStep( + cleanup=cleanup + )) + + @property + def description(self) -> str: + """Step description. + + Used for reports + + Returns: + str: Step description + + """ + return "CDS resource-resoulution base step" + + @property + def component(self) -> str: + """Component name. + + Name of the component this step relates to. + Usually the name of ONAP component. + + Returns: + str: Component name + + """ + return "PythonSDK-tests" + + +class CDSResourceResolution(testcase.TestCase): + """Enrich simple blueprint using CDS blueprintprocessor.""" + + __logger = logging.getLogger(__name__) + + def __init__(self, **kwargs): + """Init CDS resource resolution use case.""" + if "case_name" not in kwargs: + kwargs["case_name"] = 'basic_cds' + super().__init__(**kwargs) + self.__logger.debug("CDS resource resolution initialization") + self.test = CDSResourceResolutionStep( + cleanup=settings.CLEANUP_FLAG) + self.start_time = None + self.stop_time = None + self.result = 0 + + def run(self): + self.__logger.debug("CDS resource resolution run") + self.start_time = time.time() + try: + self.test.execute() + 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): + """Clean Additional resources if needed.""" + self.__logger.info("Generate Test report") + self.test.reports_collection.generate_report() |