X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=sdnvpn%2Ftest%2Ffunctest%2Ftestcase_1.py;h=937ab7ac68deaaca4893abab1b6c498c4b312dd8;hb=8a20b43bfb9723ae1f2410a5448363a5e3f38f7b;hp=544d30f691bcf72890b541e75c1bd992f9704dd6;hpb=93370e86515f9381ec84f9408a2bf900a0ed8689;p=sdnvpn.git diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index 544d30f..937ab7a 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -8,28 +8,20 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import argparse import logging -from random import randint - -import functest.utils.openstack_utils as os_utils +import sys -from sdnvpn.lib import utils as test_utils +from functest.utils import openstack_utils as os_utils +from random import randint from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib import utils as test_utils from sdnvpn.lib.results import Results -parser = argparse.ArgumentParser() - -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") - -args = parser.parse_args() - -logger = logging.getLogger('sdnvpn-testcase-1') +logger = logging.getLogger(__name__) COMMON_CONFIG = sdnvpn_config.CommonConfig() -TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_1') +TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig( + 'sdnvpn.test.functest.testcase_1') def main(): @@ -43,26 +35,33 @@ def main(): neutron_client = os_utils.get_neutron_client() glance_client = os_utils.get_glance_client() + (floatingip_ids, instance_ids, router_ids, network_ids, image_ids, + subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8)) + image_id = os_utils.create_glance_image(glance_client, TESTCASE_CONFIG.image_name, COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format, container="bare", public='public') + image_ids.append(image_id) + network_1_id = test_utils.create_net(neutron_client, TESTCASE_CONFIG.net_1_name) - test_utils.create_subnet(neutron_client, - TESTCASE_CONFIG.subnet_1_name, - TESTCASE_CONFIG.subnet_1_cidr, - network_1_id) + subnet_1_id = test_utils.create_subnet(neutron_client, + TESTCASE_CONFIG.subnet_1_name, + TESTCASE_CONFIG.subnet_1_cidr, + network_1_id) network_2_id = test_utils.create_net(neutron_client, TESTCASE_CONFIG.net_2_name) - test_utils.create_subnet(neutron_client, - TESTCASE_CONFIG.subnet_2_name, - TESTCASE_CONFIG.subnet_2_cidr, - network_2_id) + subnet_2_id = test_utils.create_subnet(neutron_client, + TESTCASE_CONFIG.subnet_2_name, + TESTCASE_CONFIG.subnet_2_cidr, + network_2_id) + network_ids.extend([network_1_id, network_2_id]) + subnet_ids.extend([subnet_1_id, subnet_2_id]) sg_id = os_utils.create_security_group_full(neutron_client, TESTCASE_CONFIG.secgroup_name, @@ -132,6 +131,7 @@ def main(): secgroup_name=TESTCASE_CONFIG.secgroup_name, compute_node=av_zone_1, userdata=u1) + instance_ids.extend([vm_1.id, vm_2.id, vm_3.id, vm_4.id, vm_5.id]) msg = ("Create VPN with eRT<>iRT") results.record_action(msg) @@ -142,15 +142,16 @@ def main(): "route_distinguishers": TESTCASE_CONFIG.route_distinguishers, "name": vpn_name } - bgpvpn = os_utils.create_bgpvpn(neutron_client, **kwargs) + bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs) bgpvpn_id = bgpvpn['bgpvpn']['id'] logger.debug("VPN created details: %s" % bgpvpn) + bgpvpn_ids.append(bgpvpn_id) msg = ("Associate network '%s' to the VPN." % TESTCASE_CONFIG.net_1_name) results.record_action(msg) results.add_to_summary(0, "-") - os_utils.create_network_association( + test_utils.create_network_association( neutron_client, bgpvpn_id, network_1_id) # Wait for VMs to get ips. @@ -170,7 +171,7 @@ def main(): results.add_to_summary(0, "-") results.record_action(msg) results.add_to_summary(0, "-") - os_utils.create_network_association( + test_utils.create_network_association( neutron_client, bgpvpn_id, network_2_id) test_utils.wait_for_bgp_net_assocs(neutron_client, @@ -194,7 +195,7 @@ def main(): kwargs = {"import_targets": TESTCASE_CONFIG.targets1, "export_targets": TESTCASE_CONFIG.targets1, "name": vpn_name} - bgpvpn = os_utils.update_bgpvpn(neutron_client, bgpvpn_id, **kwargs) + bgpvpn = test_utils.update_bgpvpn(neutron_client, bgpvpn_id, **kwargs) logger.info("Waiting for the VMs to connect to each other using the" " updated network configuration") @@ -203,9 +204,14 @@ def main(): results.get_ping_status(vm_1, vm_4, expected="PASS", timeout=30) results.get_ping_status(vm_1, vm_5, expected="PASS", timeout=30) + test_utils.cleanup_nova(nova_client, instance_ids, image_ids) + test_utils.cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, + interfaces, subnet_ids, router_ids, + network_ids) + return results.compile_summary() if __name__ == '__main__': logging.basicConfig(level=logging.INFO) - main() + sys.exit(main())