import opnfv.utils.ovs_logger as ovs_log import sfc.lib.config as sfc_config import sfc.lib.utils as test_utils from sfc.lib.results import Results from opnfv.deployment.factory import Factory as DeploymentFactory import sfc.lib.topology_shuffler as topo_shuffler from functest.utils.constants import CONST logger = logging.getLogger(__name__) CLIENT = "client" SERVER = "server" COMMON_CONFIG = sfc_config.CommonConfig() TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_two_chains_SSH_and_HTTP') def main(): deploymentHandler = DeploymentFactory.get_handler( COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, installer_pwd=COMMON_CONFIG.installer_password) cluster = COMMON_CONFIG.installer_cluster openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) if cluster is not None else deploymentHandler.get_nodes()) controller_nodes = [node for node in openstack_nodes
if __name__ == '__main__': return results.compile_summary(), self.creators if __name__ == \ 'sfc.tests.functest.sfc_one_chain_two_service_functions': return results.compile_summary(), self.creators def get_creators(self): """Return the creators info, specially in case the info is not returned due to an exception. :return: creators """ return self.creators if __name__ == '__main__': # Disable InsecureRequestWarning errors when executing the SFC tests in XCI urllib3.disable_warnings() TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_one_chain_two_service' '_functions') supported_installers = ['fuel', 'apex', 'osa', 'compass'] vnfs = ['testVNF1', 'testVNF2'] test_run = SfcOneChainTwoServiceTC(TESTCASE_CONFIG, supported_installers, vnfs) test_run.run()
import opnfv.utils.ovs_logger as ovs_log from opnfv.deployment.factory import Factory as DeploymentFactory import sfc.lib.config as sfc_config import sfc.lib.utils as test_utils from sfc.lib.results import Results import sfc.lib.topology_shuffler as topo_shuffler from functest.utils.constants import CONST logger = logging.getLogger(__name__) CLIENT = "client" SERVER = "server" COMMON_CONFIG = sfc_config.CommonConfig() TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_symmetric_chain') def main(): deploymentHandler = DeploymentFactory.get_handler( COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, installer_pwd=COMMON_CONFIG.installer_password) cluster = COMMON_CONFIG.installer_cluster all_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) if cluster is not None else deploymentHandler.get_nodes()) controller_nodes = [node for node in all_nodes if node.is_controller()]
def run(self): deploymentHandler = DeploymentFactory.get_handler( COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, COMMON_CONFIG.installer_password, COMMON_CONFIG.installer_key_file) cluster = COMMON_CONFIG.installer_cluster nodes = (deploymentHandler.get_nodes({'cluster': cluster}) if cluster is not None else deploymentHandler.get_nodes()) self.__disable_heat_resource_finder_cache(nodes, COMMON_CONFIG.installer_type) odl_ip, odl_port = odl_utils.get_odl_ip_port(nodes) ovs_logger = ovs_log.OVSLogger( os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'), COMMON_CONFIG.functest_results_dir) config_file = os.path.join(COMMON_CONFIG.config_file) with open(config_file) as f: config_yaml = yaml.safe_load(f) testcases = config_yaml.get("testcases") testcases_ordered = OrderedDict(sorted(testcases.items(), key=lambda x: x[1]['order'])) overall_status = "NOT TESTED" self.start_time = time.time() for tc, test_cfg in testcases_ordered.items(): if test_cfg['enabled']: test_name = tc test_descr = test_cfg['description'] title = ("Running '%s - %s'" % (test_name, test_descr)) logger.info(title) logger.info("%s\n" % ("=" * len(title))) module = importlib.import_module( "sfc.tests.functest.{0}".format(test_name), package=None) testcase_config = sfc_config.TestcaseConfig(test_name) supported_installers = test_cfg['supported_installers'] vnf_names = test_cfg['vnf_names'] tc_class = getattr(module, test_cfg['class_name']) tc_instance = tc_class(testcase_config, supported_installers, vnf_names) start_time = time.time() try: result, creators = tc_instance.run() except Exception as e: logger.error("Exception when executing: %s" % test_name) logger.error(e) result = {'status': 'FAILED'} end_time = time.time() duration = end_time - start_time logger.info("Results of test case '%s - %s':\n%s\n" % (test_name, test_descr, result)) if result['status'] == 'PASS': status = 'PASS' self.details.update({test_name: "worked"}) if overall_status != "FAIL": overall_status = "PASS" else: status = 'FAIL' overall_status = "FAIL" self.details.update({test_name: "execution error."}) ovs_logger.create_artifact_archive() dic = {"duration": duration, "status": status} self.details.update({test_name: dic}) sfc_cleanup.cleanup(creators, odl_ip=odl_ip, odl_port=odl_port) self.stop_time = time.time() if overall_status == "PASS": self.result = 100 return testcase.TestCase.EX_OK return testcase.TestCase.EX_RUN_ERROR
logger.info("Test HTTP again") results = self.present_results_http() if __name__ == '__main__': return results.compile_summary(), self.creators if __name__ == 'sfc.tests.functest.sfc_chain_deletion': return results.compile_summary(), self.creators def get_creators(self): """Return the creators info, specially in case the info is not returned due to an exception. :return: creators """ return self.creators if __name__ == '__main__': # Disable InsecureRequestWarning errors when executing the SFC tests in XCI urllib3.disable_warnings() TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_chain_deletion') supported_installers = ['fuel', 'apex', 'osa', 'compass'] vnf_names = ['testVNF1', 'testVNF2'] test_run = SfcChainDeletion(TESTCASE_CONFIG, supported_installers, vnf_names) test_run.run()