1 """Basic Clamp test case."""
4 from xtesting.core import testcase
5 from onapsdk.configuration import settings
6 from onapsdk.exceptions import SDKException, APIError
7 from onaptests.steps.loop.clamp import ClampStep
8 from onaptests.utils.exceptions import OnapTestException
9 class BasicClamp(testcase.TestCase):
10 """Onboard, update a model with a loop, design the loop and deploy it."""
11 __logger = logging.getLogger(__name__)
12 def __init__(self, **kwargs):
13 """Init Basic Clamp, onboard a VM, design and deploy a loop with CLAMP."""
14 if "case_name" not in kwargs:
15 kwargs["case_name"] = 'basic_clamp'
16 super(BasicClamp, self).__init__(**kwargs)
17 self.__logger.debug("Basic CLAMP init started")
18 self.test = ClampStep(
19 cleanup=settings.CLEANUP_FLAG)
20 self.start_time = None
24 """Run Basic CLAMP onap test."""
25 self.start_time = time.time()
26 self.__logger.debug("start time")
29 self.__logger.info("VNF basic_clamp successfully created")
30 # The cleanup is part of the test, not only a teardown action
31 if settings.CLEANUP_FLAG:
32 self.__logger.info("VNF basic_clamp cleanup called")
33 time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
37 self.__logger.info("No cleanup requested. Test completed.")
39 except OnapTestException as exc:
41 self.__logger.error(exc.error_message)
42 except (SDKException, APIError):
44 self.__logger.error("SDK exception")
46 self.stop_time = time.time()
48 """Clean Additional resources if needed."""
49 self.__logger.info("Generate Test report")
50 self.test.reports_collection.generate_report()