diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-04-21 10:39:19 +0200 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2016-04-21 10:46:44 +0200 |
commit | cd0cd3e5a5a099715c41ac9ad6f5697554d931c7 (patch) | |
tree | 81564de37a68af8c4d59177aa6e37b7e60c590dd | |
parent | ef62824e0471d07a4a3a40c401fc433070d961c6 (diff) |
Remove cleanup from vPing scripts, and use the existing cleanup script
JIRA: FUNCTEST-215
Change-Id: I1ec494097a9b70de142da9f90136256535af5100
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rwxr-xr-x | docker/run_tests.sh | 14 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing_ssh.py | 103 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing_userdata.py | 82 |
3 files changed, 6 insertions, 193 deletions
diff --git a/docker/run_tests.sh b/docker/run_tests.sh index f18f1d74..c258136d 100755 --- a/docker/run_tests.sh +++ b/docker/run_tests.sh @@ -103,17 +103,16 @@ function run_test(){ "healthcheck") info "Running health check test..." ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh - clean_openstack ;; "vping_ssh") info "Running vPing-SSH test..." python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \ - $debug $clean_flag $report + $debug $report ;; "vping_userdata") info "Running vPing-userdata test... " python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \ - $debug $clean_flag $report + $debug $report ;; "odl") info "Running ODL test..." @@ -138,19 +137,16 @@ function run_test(){ if [ -f ${tempest_conf} ]; then cp $tempest_conf ${FUNCTEST_CONF_DIR} fi - clean_openstack ;; "vims") info "Running vIMS test..." python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \ $debug $clean_flag $report - clean_openstack ;; "rally") info "Running Rally benchmark suite..." python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \ $debug $clean_flag all $report - clean_openstack ;; "bgpvpn") @@ -171,7 +167,6 @@ bgpvpn = True" >> /etc/tempest/tempest.conf ./run_tempest.sh -t -N -- networking_bgpvpn_tempest rm -rf /etc/tempest/tempest.conf popd - clean_openstack ;; "onos") info "Running ONOS test case..." @@ -185,7 +180,6 @@ bgpvpn = True" >> /etc/tempest/tempest.conf info "Running PROMISE test case..." python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $debug $report sleep 10 # to let the instances terminate - clean_openstack ;; "doctor") info "Running Doctor test..." @@ -196,6 +190,10 @@ bgpvpn = True" >> /etc/tempest/tempest.conf ${repos_dir}/ovno/Testcases/RunTests.sh ;; esac + + if [[ -n $clean_flag ]]; then + clean_openstack + fi } diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py index 43ab8525..dc46c89d 100644 --- a/testcases/vPing/CI/libraries/vPing_ssh.py +++ b/testcases/vPing/CI/libraries/vPing_ssh.py @@ -38,9 +38,6 @@ parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-r", "--report", help="Create json result file", action="store_true") -parser.add_argument("-n", "--noclean", - help="Don't clean the created resources for this test.", - action="store_true") args = parser.parse_args() @@ -257,93 +254,6 @@ def create_security_group(neutron_client): return sg_id -def cleanup(nova, neutron, image_id, network_dic, sg_id, floatingip): - if args.noclean: - logger.debug("The OpenStack resources are not deleted.") - return True - - # delete both VMs - logger.info("Cleaning up...") - if not image_exists: - logger.debug("Deleting image...") - if not openstack_utils.delete_glance_image(nova, image_id): - logger.error("Error deleting the glance image") - - vm1 = openstack_utils.get_instance_by_name(nova, NAME_VM_1) - if vm1: - logger.debug("Deleting '%s'..." % NAME_VM_1) - nova.servers.delete(vm1) - # wait until VMs are deleted - if not waitVmDeleted(nova, vm1): - logger.error( - "Instance '%s' with cannot be deleted. Status is '%s'" % ( - NAME_VM_1, openstack_utils.get_instance_status(nova, vm1))) - else: - logger.debug("Instance %s terminated." % NAME_VM_1) - - vm2 = openstack_utils.get_instance_by_name(nova, NAME_VM_2) - - if vm2: - logger.debug("Deleting '%s'..." % NAME_VM_2) - vm2 = nova.servers.find(name=NAME_VM_2) - nova.servers.delete(vm2) - - if not waitVmDeleted(nova, vm2): - logger.error( - "Instance '%s' with cannot be deleted. Status is '%s'" % ( - NAME_VM_2, openstack_utils.get_instance_status(nova, vm2))) - else: - logger.debug("Instance %s terminated." % NAME_VM_2) - - # delete created network - logger.debug("Deleting network '%s'..." % NEUTRON_PRIVATE_NET_NAME) - net_id = network_dic["net_id"] - subnet_id = network_dic["subnet_id"] - router_id = network_dic["router_id"] - - if not openstack_utils.remove_interface_router(neutron, router_id, - subnet_id): - logger.error("Unable to remove subnet '%s' from router '%s'" % ( - subnet_id, router_id)) - return False - - logger.debug("Interface removed successfully") - if not openstack_utils.delete_neutron_router(neutron, router_id): - logger.error("Unable to delete router '%s'" % router_id) - return False - - logger.debug("Router deleted successfully") - - if not openstack_utils.delete_neutron_subnet(neutron, subnet_id): - logger.error("Unable to delete subnet '%s'" % subnet_id) - return False - - logger.debug( - "Subnet '%s' deleted successfully" % NEUTRON_PRIVATE_SUBNET_NAME) - - if not openstack_utils.delete_neutron_net(neutron, net_id): - logger.error("Unable to delete network '%s'" % net_id) - return False - - logger.debug( - "Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME) - - if not openstack_utils.delete_security_group(neutron, sg_id): - logger.error("Unable to delete security group '%s'" % sg_id) - return False - logger.debug( - "Security group '%s' deleted successfully" % sg_id) - - logger.debug("Releasing floating ip '%s'..." % floatingip['fip_addr']) - if not openstack_utils.delete_floating_ip(nova, floatingip['fip_id']): - logger.error("Unable to delete floatingip '%s'" - % floatingip['fip_addr']) - return False - logger.debug( - "Floating IP '%s' deleted successfully" % floatingip['fip_addr']) - return True - - def push_results(start_time_ts, duration, test_status): try: logger.debug("Pushing result into DB...") @@ -452,8 +362,6 @@ def main(): if not waitVmActive(nova_client, vm1): logger.error("Instance '%s' cannot be booted. Status is '%s'" % ( NAME_VM_1, openstack_utils.get_instance_status(nova_client, vm1))) - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatingip) return (EXIT_CODE) else: logger.info("Instance '%s' is ACTIVE." % NAME_VM_1) @@ -481,8 +389,6 @@ def main(): if not waitVmActive(nova_client, vm2): logger.error("Instance '%s' cannot be booted. Status is '%s'" % ( NAME_VM_2, openstack_utils.get_instance_status(nova_client, vm2))) - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatip_dic) return (EXIT_CODE) else: logger.info("Instance '%s' is ACTIVE." % NAME_VM_2) @@ -498,8 +404,6 @@ def main(): if floatip is None: logger.error("Cannot create floating IP.") - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatip_dic) return (EXIT_CODE) logger.info("Floating IP created: '%s'" % floatip) @@ -507,8 +411,6 @@ def main(): % (floatip, NAME_VM_2)) if not openstack_utils.add_floating_ip(nova_client, vm2.id, floatip): logger.error("Cannot associate floating IP to VM.") - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatip_dic) return (EXIT_CODE) logger.info("Trying to establish SSH connection to %s..." % floatip) @@ -561,8 +463,6 @@ def main(): if timeout == 0: # 300 sec timeout (5 min) logger.error("Cannot establish connection to IP '%s'. Aborting" % floatip) - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatip_dic) return (EXIT_CODE) scp = SCPClient(ssh.get_transport()) @@ -610,9 +510,6 @@ def main(): logger.debug("Pinging %s. Waiting for response..." % test_ip) sec += 1 - cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, - floatip_dic) - test_status = "NOK" if EXIT_CODE == 0: logger.info("vPing OK") diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py index 1fc9e1d3..20a47aea 100644 --- a/testcases/vPing/CI/libraries/vPing_userdata.py +++ b/testcases/vPing/CI/libraries/vPing_userdata.py @@ -36,9 +36,6 @@ parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-r", "--report", help="Create json result file", action="store_true") -parser.add_argument("-n", "--noclean", - help="Don't clean the created resources for this test.", - action="store_true") args = parser.parse_args() @@ -251,80 +248,6 @@ def create_security_group(neutron_client): return sg_id -def cleanup(nova, neutron, image_id, network_dic): - if args.noclean: - logger.debug("The OpenStack resources are not deleted.") - return True - - # delete both VMs - logger.info("Cleaning up...") - if not image_exists: - logger.debug("Deleting image...") - if not openstack_utils.delete_glance_image(nova, image_id): - logger.error("Error deleting the glance image") - - vm1 = openstack_utils.get_instance_by_name(nova, NAME_VM_1) - if vm1: - logger.debug("Deleting '%s'..." % NAME_VM_1) - nova.servers.delete(vm1) - # wait until VMs are deleted - if not waitVmDeleted(nova, vm1): - logger.error( - "Instance '%s' with cannot be deleted. Status is '%s'" % ( - NAME_VM_1, openstack_utils.get_instance_status(nova, vm1))) - else: - logger.debug("Instance %s terminated." % NAME_VM_1) - - vm2 = openstack_utils.get_instance_by_name(nova, NAME_VM_2) - - if vm2: - logger.debug("Deleting '%s'..." % NAME_VM_2) - vm2 = nova.servers.find(name=NAME_VM_2) - nova.servers.delete(vm2) - - if not waitVmDeleted(nova, vm2): - logger.error( - "Instance '%s' with cannot be deleted. Status is '%s'" % ( - NAME_VM_2, openstack_utils.get_instance_status(nova, vm2))) - else: - logger.debug("Instance %s terminated." % NAME_VM_2) - - # delete created network - logger.info("Deleting network '%s'..." % NEUTRON_PRIVATE_NET_NAME) - net_id = network_dic["net_id"] - subnet_id = network_dic["subnet_id"] - router_id = network_dic["router_id"] - - if not openstack_utils.remove_interface_router(neutron, router_id, - subnet_id): - logger.error("Unable to remove subnet '%s' from router '%s'" % ( - subnet_id, router_id)) - return False - - logger.debug("Interface removed successfully") - if not openstack_utils.delete_neutron_router(neutron, router_id): - logger.error("Unable to delete router '%s'" % router_id) - return False - - logger.debug("Router deleted successfully") - - if not openstack_utils.delete_neutron_subnet(neutron, subnet_id): - logger.error("Unable to delete subnet '%s'" % subnet_id) - return False - - logger.debug( - "Subnet '%s' deleted successfully" % NEUTRON_PRIVATE_SUBNET_NAME) - - if not openstack_utils.delete_neutron_net(neutron, net_id): - logger.error("Unable to delete network '%s'" % net_id) - return False - - logger.debug( - "Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME) - - return True - - def push_results(start_time_ts, duration, test_status): try: logger.debug("Pushing result into DB...") @@ -439,7 +362,6 @@ def main(): logger.error("Instance '%s' cannot be booted. Status is '%s'" % ( NAME_VM_1, openstack_utils.get_instance_status(nova_client, vm1))) - cleanup(nova_client, neutron_client, image_id, network_dic) return (EXIT_CODE) else: logger.info("Instance '%s' is ACTIVE." % NAME_VM_1) @@ -475,8 +397,6 @@ def main(): if not waitVmActive(nova_client, vm2): logger.error("Instance '%s' cannot be booted. Status is '%s'" % ( NAME_VM_2, openstack_utils.get_instance_status(nova_client, vm2))) - cleanup(nova_client, neutron_client, image_id, network_dic, - port_id1, port_id2) return (EXIT_CODE) else: logger.info("Instance '%s' is ACTIVE." % NAME_VM_2) @@ -528,8 +448,6 @@ def main(): duration = 0 logger.error("vPing FAILED") - cleanup(nova_client, neutron_client, image_id, network_dic) - if args.report: push_results(start_time_ts, duration, test_status) |