2 """Basic VM test case."""
6 from xtesting.core import testcase
7 from onapsdk.configuration import settings
9 import onaptests.utils.exceptions as onap_test_exceptions
10 from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
12 class BasicVm(testcase.TestCase):
13 """Onboard then instantiate a simple VM with ONAP."""
15 __logger = logging.getLogger(__name__)
17 def __init__(self, **kwargs):
19 # import ubuntu16_nomulticloud_settings needed
20 if "case_name" not in kwargs:
21 kwargs["case_name"] = 'basic_vm'
22 super(BasicVm, self).__init__(**kwargs)
23 self.__logger.debug("BasicVm init started")
24 self.test = YamlTemplateVfModuleAlaCarteInstantiateStep(
25 cleanup=settings.CLEANUP_FLAG)
26 self.start_time = None
31 """Run onap_tests with ubuntu16 VM."""
32 self.start_time = time.time()
33 self.__logger.debug("start time")
36 self.__logger.info("VNF basic_vm successfully created")
37 # The cleanup is part of the test, not only a teardown action
38 if settings.CLEANUP_FLAG:
39 self.__logger.info("VNF basic_vm cleanup called")
40 time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
44 self.__logger.info("No cleanup requested. Test completed.")
46 except onap_test_exceptions.OnapTestException as exc:
48 self.__logger.error(exc.error_message)
50 self.stop_time = time.time()
53 """Clean Additional resources if needed."""
54 self.__logger.info("Generate Test report")
55 self.test.reports_collection.generate_report()