2 """Basic CNF test case."""
6 from xtesting.core import testcase
7 from onapsdk.configuration import settings
8 import onaptests.utils.exceptions as onap_test_exceptions
9 from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
11 class BasicCnf(testcase.TestCase):
12 """Onboard then instantiate a simple CNF with ONAP."""
14 __logger = logging.getLogger(__name__)
16 def __init__(self, **kwargs):
18 if "case_name" not in kwargs:
19 kwargs["case_name"] = 'basic_cnf'
20 super(BasicCnf, self).__init__(**kwargs)
21 self.__logger.debug("BasicCnf init started")
22 self.test = YamlTemplateVfModuleAlaCarteInstantiateStep(
23 cleanup=settings.CLEANUP_FLAG)
24 self.start_time = None
29 """Run onap_tests with basic_cnf VM."""
30 self.start_time = time.time()
31 self.__logger.debug("start time")
34 self.__logger.info("basic_cnf successfully created")
35 # The cleanup is part of the test, not only a teardown action
36 if settings.CLEANUP_FLAG:
37 self.__logger.info("basic_cnf cleanup called")
38 time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
42 self.__logger.info("No cleanup requested. Test completed.")
44 except onap_test_exceptions.TestConfigurationException:
46 self.__logger.error("Basic CNF configuration error")
47 except onap_test_exceptions.ServiceInstantiateException:
49 self.__logger.error("Basic CNF service instantiation error")
50 except onap_test_exceptions.ServiceCleanupException:
52 self.__logger.error("Basic CNF service instance cleanup error")
53 except onap_test_exceptions.VnfInstantiateException:
55 self.__logger.error("Basic CNF Vnf instantiation error")
56 except onap_test_exceptions.VnfCleanupException:
58 self.__logger.error("Basic CNF Vnf instance cleanup error")
59 except onap_test_exceptions.ProfileInformationException:
60 self.__logger.error("Missing k8s profile information")
62 except onap_test_exceptions.ProfileCleanupException:
63 self.__logger.error("K8s profile deletion failed")
65 except onap_test_exceptions.VfModuleInstantiateException:
67 self.__logger.error("Basic CNF Module instantiation error")
68 except onap_test_exceptions.VfModuleCleanupException:
69 self.__logger.error("Basic CNF Module cleanup failed.")
72 self.stop_time = time.time()
75 """Clean Additional resources if needed."""
76 self.__logger.info("Generate Test report")
77 self.test.reports_collection.generate_report()