Merge "Add create_floating_ip function"
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 318d891..dcad101 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -66,6 +66,7 @@
cls.health_monitors = []
cls.vpnservices = []
cls.ikepolicies = []
+ cls.floating_ips = []
@classmethod
def tearDownClass(cls):
@@ -75,6 +76,9 @@
# Clean up vpn services
for vpnservice in cls.vpnservices:
cls.client.delete_vpnservice(vpnservice['id'])
+ # Clean up floating IPs
+ for floating_ip in cls.floating_ips:
+ cls.client.delete_floating_ip(floating_ip['id'])
# Clean up routers
for router in cls.routers:
resp, body = cls.client.list_router_interfaces(router['id'])
@@ -167,6 +171,16 @@
return router
@classmethod
+ def create_floating_ip(cls, external_network_id, **kwargs):
+ """Wrapper utility that returns a test floating IP."""
+ resp, body = cls.client.create_floating_ip(
+ external_network_id,
+ **kwargs)
+ fip = body['floatingip']
+ cls.floating_ips.append(fip)
+ return fip
+
+ @classmethod
def create_pool(cls, name, lb_method, protocol, subnet):
"""Wrapper utility that returns a test pool."""
resp, body = cls.client.create_pool(
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 7ce8ca6..a033125 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -55,31 +55,17 @@
for i in range(2):
cls.create_port(cls.network)
- def _delete_floating_ip(self, floating_ip_id):
- # Deletes a floating IP and verifies if it is deleted or not
- resp, _ = self.client.delete_floatingip(floating_ip_id)
- self.assertEqual(204, resp.status)
- # Asserting that the floating_ip is not found in list after deletion
- resp, floating_ips = self.client.list_floatingips()
- floatingip_id_list = list()
- for f in floating_ips['floatingips']:
- floatingip_id_list.append(f['id'])
- self.assertNotIn(floating_ip_id, floatingip_id_list)
-
@attr(type='smoke')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
- resp, floating_ip = self.client.create_floating_ip(
+ created_floating_ip = self.create_floating_ip(
self.ext_net_id, port_id=self.ports[0]['id'])
- self.assertEqual('201', resp['status'])
- created_floating_ip = floating_ip['floatingip']
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
self.assertIsNotNone(created_floating_ip['floating_ip_address'])
self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
self.assertEqual(created_floating_ip['floating_network_id'],
self.ext_net_id)
- self.addCleanup(self._delete_floating_ip, created_floating_ip['id'])
# Verifies the details of a floating_ip
resp, floating_ip = self.client.show_floating_ip(
created_floating_ip['id'])