From 291f7804f4a89946aee961b4bed43fa91b4a3c1f Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Thu, 29 Oct 2015 14:38:40 +0100 Subject: Fix error when deleting the network in vPing test. JIRA: FUNCTEST-93 Change-Id: I9472c1183eea86b0c018059aa17b76bd2932ad8e Signed-off-by: jose.lausuch --- testcases/functest_utils.py | 7 +++++++ testcases/vPing/CI/libraries/vPing.py | 27 +++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index 262149b25..323297f28 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -210,6 +210,13 @@ def create_neutron_port(neutron_client, name, network_id, ip): print "Error:", sys.exc_info()[0] return False +def delete_neutron_port(neutron_client, port_id): + try: + neutron_client.delete_port(port_id) + return True + except: + print "Error:", sys.exc_info()[0] + return False def get_network_id(neutron_client, network_name): networks = neutron_client.list_networks()['networks'] diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index fbe134cb8..875ad6aad 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -202,7 +202,7 @@ def delete_glance_image(name): return True -def cleanup(nova, neutron, network_dic): +def cleanup(nova, neutron, network_dic, port_id1, port_id2): # delete both VMs logger.info("Cleaning up...") @@ -241,6 +241,17 @@ def cleanup(nova, neutron, network_dic): subnet_id = network_dic["subnet_id"] router_id = network_dic["router_id"] + + if not functest_utils.delete_neutron_port(neutron, port_id1): + logger.error("Unable to remove port '%s'" %port_id1) + return False + logger.debug("Port '%s' removed successfully" %port_id1) + + if not functest_utils.delete_neutron_port(neutron, port_id2): + logger.error("Unable to remove port '%s'" %port_id2) + return False + logger.debug("Port '%s' removed successfully" %port_id2) + if not functest_utils.remove_interface_router(neutron, router_id, subnet_id): logger.error("Unable to remove subnet '%s' from router '%s'" % ( @@ -336,10 +347,10 @@ def main(): # create VM logger.debug("Creating port 'vping-port-1' with IP %s..." % IP_1) - port_id = functest_utils.create_neutron_port(neutron_client, + port_id1 = functest_utils.create_neutron_port(neutron_client, "vping-port-1", network_id, IP_1) - if not port_id: + if not port_id1: logger.error("Unable to create port.") exit(-1) @@ -352,7 +363,7 @@ def main(): flavor=flavor, image=image, # nics = [{"net-id": network_id, "v4-fixed-ip": IP_1}] - nics=[{"port-id": port_id}] + nics=[{"port-id": port_id1}] ) # wait until VM status is active @@ -386,11 +397,11 @@ def main(): # create VM logger.debug("Creating port 'vping-port-2' with IP %s..." % IP_2) - port_id = functest_utils.create_neutron_port(neutron_client, + port_id2 = functest_utils.create_neutron_port(neutron_client, "vping-port-2", network_id, IP_2) - if not port_id: + if not port_id2: logger.error("Unable to create port.") exit(-1) logger.info("Creating instance '%s' with IP %s..." % (NAME_VM_2, IP_2)) @@ -403,7 +414,7 @@ def main(): flavor=flavor, image=image, # nics = [{"net-id": network_id, "v4-fixed-ip": IP_2}], - nics=[{"port-id": port_id}], + nics=[{"port-id": port_id2}], userdata=u ) @@ -440,7 +451,7 @@ def main(): logger.debug("No vPing detected...") sec += 1 - cleanup(nova_client, neutron_client, network_dic) + cleanup(nova_client, neutron_client, network_dic, port_id1, port_id2) test_status = "NOK" if EXIT_CODE == 0: -- cgit 1.2.3-korg