diff options
Diffstat (limited to 'test/functest/testcase_2.py')
-rw-r--r-- | test/functest/testcase_2.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/test/functest/testcase_2.py b/test/functest/testcase_2.py index 76757d6..c28e535 100644 --- a/test/functest/testcase_2.py +++ b/test/functest/testcase_2.py @@ -27,11 +27,9 @@ parser.add_argument("-r", "--report", args = parser.parse_args() -""" logging configuration """ -logger = ft_logger.Logger("sdnvpn-testcase-1").getLogger() +logger = ft_logger.Logger("sdnvpn-testcase-2").getLogger() REPO_PATH = os.environ['repos_dir'] + '/sdnvpn/' -HOME = os.environ['HOME'] + "/" VM_BOOT_TIMEOUT = 180 @@ -97,12 +95,20 @@ SECGROUP_NAME = ft_utils.get_parameter_from_yaml( "testcases.testcase_2.sdnvpn_sg_name", config_file) SECGROUP_DESCR = ft_utils.get_parameter_from_yaml( "testcases.testcase_2.sdnvpn_sg_descr", config_file) - +TARGETS_1 = ft_utils.get_parameter_from_yaml( + "testcases.testcase_2.targets1", config_file) +TARGETS_2 = ft_utils.get_parameter_from_yaml( + "testcases.testcase_2.targets2", config_file) +SUCCESS_CRITERIA = ft_utils.get_parameter_from_yaml( + "testcases.testcase_1.succes_criteria", config_file) TEST_DB = ft_utils.get_parameter_from_yaml("results.test_db_url") TEST_RESULT = "PASS" SUMMARY = "" LINE_LENGTH = 90 # length for the summary table +DETAILS = [] +NUM_TESTS = 0 +NUM_TESTS_FAILED = 0 def create_network(neutron_client, net, subnet1, cidr1, @@ -231,7 +237,7 @@ def check_ssh_output(vm_source, ip_source, test_case_name = ("[%s] returns 'I am %s' to '%s'[%s]" % (ip_target, expected, vm_source.name, ip_source)) - logger.debug("\n%sSSH\n%sfrom '%s' (%s)\n%sto '%s' (%s).\n" + logger.debug("%sSSH\n%sfrom '%s' (%s)\n%sto '%s' (%s).\n" "%s-->Expected result: %s.\n" % (tab, tab, vm_source.name, ip_source, tab, vm_target.name, ip_target, @@ -262,7 +268,7 @@ def check_ssh_output(vm_source, ip_source, def add_to_summary(num_cols, col1, col2=""): - global SUMMARY, LINE_LENGTH + global SUMMARY, LINE_LENGTH, NUM_TESTS, NUM_TESTS_FAILED if num_cols == 0: SUMMARY += ("+%s+\n" % (col1 * (LINE_LENGTH - 2))) elif num_cols == 1: @@ -270,6 +276,11 @@ def add_to_summary(num_cols, col1, col2=""): elif num_cols == 2: SUMMARY += ("| %s" % col1.ljust(7) + "| ") SUMMARY += (col2.ljust(LINE_LENGTH - 12) + "|\n") + DETAILS.append({col2: col1}) + if col1 in ("FAIL", "PASS"): + NUM_TESTS += 1 + if col1 == "FAIL": + NUM_TESTS_FAILED += 1 def main(): @@ -402,19 +413,19 @@ def main(): (INSTANCE_1_NAME, vm_1_ip)) msg = ("Create VPN1 with eRT=iRT") - logger.info("\n\n--> %s ..." % msg) + logger.info(msg) add_to_summary(1, msg) vpn1_name = "sdnvpn-1-" + str(randint(100000, 999999)) - kwargs = {"import_targets": "55:55", - "export_targets": "55:55", - "route_targets": "55:55", + kwargs = {"import_targets": TARGETS_2, + "export_targets": TARGETS_2, + "route_targets": TARGETS_2, "name": vpn1_name} bgpvpn1 = os_utils.create_bgpvpn(neutron_client, **kwargs) bgpvpn1_id = bgpvpn1['bgpvpn']['id'] logger.debug("VPN1 created details: %s" % bgpvpn1) msg = ("Associate network '%s' to the VPN." % NET_1_NAME) - logger.info("\n\n--> %s..." % msg) + logger.info(msg) add_to_summary(1, msg) add_to_summary(0, "-") @@ -433,19 +444,19 @@ def main(): add_to_summary(0, "-") msg = ("Create VPN2 with eRT=iRT") - logger.info("\n\n--> %s ..." % msg) + logger.info(msg) add_to_summary(1, msg) vpn2_name = "sdnvpn-2-" + str(randint(100000, 999999)) - kwargs = {"import_targets": "88:88", - "export_targets": "88:88", - "route_targets": "88:88", + kwargs = {"import_targets": TARGETS_1, + "export_targets": TARGETS_1, + "route_targets": TARGETS_1, "name": vpn2_name} bgpvpn2 = os_utils.create_bgpvpn(neutron_client, **kwargs) bgpvpn2_id = bgpvpn2['bgpvpn']['id'] logger.debug("VPN created details: %s" % bgpvpn2) msg = ("Associate network '%s' to the VPN2." % NET_2_NAME) - logger.info("\n\n--> %s..." % msg) + logger.info(msg) add_to_summary(1, msg) add_to_summary(0, "-") @@ -471,7 +482,12 @@ def main(): else: logger.info("One or more sub tests have failed.") - sys.exit(0) + status = "PASS" + success = 100 - (100 * int(NUM_TESTS_FAILED) / int(NUM_TESTS)) + if success < int(SUCCESS_CRITERIA): + status = "FAILED" + + return {"status": status, "details": DETAILS} if __name__ == '__main__': |