From 18443e7872ddb154e2c91433ed03b09deab90321 Mon Sep 17 00:00:00 2001 From: tomsou Date: Tue, 27 Jun 2017 13:51:13 +0000 Subject: Adapt the floating ip handling in functest Comply with the new floating ip management in functest (https://gerrit.opnfv.org/gerrit/#/c/36415) JIRA: SDNVPN-165 Change-Id: I39e380caf07568e2370246afcf483eb8adb3def6 Signed-off-by: tomsou --- sdnvpn/lib/utils.py | 23 +++++++++++------------ sdnvpn/test/functest/testcase_1.py | 8 ++++---- sdnvpn/test/functest/testcase_2.py | 9 ++++----- sdnvpn/test/functest/testcase_3.py | 10 ++++------ sdnvpn/test/functest/testcase_4.py | 9 ++++----- sdnvpn/test/functest/testcase_7.py | 8 ++++---- sdnvpn/test/functest/testcase_8.py | 9 +++++---- 7 files changed, 36 insertions(+), 40 deletions(-) diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index 7e41d41..220f61e 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -538,8 +538,16 @@ def detach_instance_from_ext_br(instance, compute_node): compute_node.run_cmd(cmd.format(bridge=bridge)) -def cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, subnet_ids, - router_ids, network_ids): +def cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, interfaces, + subnet_ids, router_ids, network_ids): + + if len(floatingip_ids) != 0: + for floatingip_id in floatingip_ids: + if not os_utils.delete_floating_ip(neutron_client, floatingip_id): + logging.error('Fail to delete all floating ips. ' + 'Floating ip with id {} was not deleted.'. + format(floatingip_id)) + return False if len(bgpvpn_ids) != 0: for bgpvpn_id in bgpvpn_ids: @@ -586,16 +594,7 @@ def cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, subnet_ids, return True -def cleanup_nova(nova_client, floatingip_ids, instance_ids, image_ids): - - if len(floatingip_ids) != 0: - for floatingip_id in floatingip_ids: - if not os_utils.delete_floating_ip(nova_client, floatingip_id): - logging.error('Fail to delete all floating ips. ' - 'Floating ip with id {} was not deleted.'. - format(floatingip_id)) - return False - +def cleanup_nova(nova_client, instance_ids, image_ids): if len(instance_ids) != 0: for instance_id in instance_ids: if not os_utils.delete_instance(nova_client, instance_id): diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index 2cd03b6..d114929 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -212,10 +212,10 @@ 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, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) + 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() diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py index 61d81a3..425589d 100644 --- a/sdnvpn/test/functest/testcase_2.py +++ b/sdnvpn/test/functest/testcase_2.py @@ -253,11 +253,10 @@ def main(): expected="not reachable", timeout=30) - test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) - + 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() diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index dbbdb59..24d413c 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -279,14 +279,12 @@ def main(): else: results.add_failure("Peering with quagga") - test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) - + 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() diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py index 69c3461..b907145 100644 --- a/sdnvpn/test/functest/testcase_4.py +++ b/sdnvpn/test/functest/testcase_4.py @@ -219,11 +219,10 @@ def main(): results.add_to_summary(0, "=") logger.info("\n%s" % results.summary) - test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) - + 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() diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index 48e26d5..d29a50a 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -163,11 +163,11 @@ def main(): results.ping_ip_test(fip['fip_addr']) floatingip_ids.append(fip['fip_id']) - test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) + 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() diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index f08ead2..e3ccd66 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -166,10 +166,11 @@ def main(): floatingip_ids.append(fip['fip_id']) - test_utils.cleanup_nova(nova_client, floatingip_ids, instance_ids, - image_ids) - test_utils.cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, - subnet_ids, router_ids, network_ids) + 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() -- cgit 1.2.3-korg