Add 2 tests to the Floating IP test case

Associate a Floating IP to a port and then delete it
Associate a Floating IP to a port and then to a port on another
router

Change-Id: I37bb7c348db8767571f95db35df0545d366b5d10
Implements: blueprint add-test-neutron-tempest-floating-ip
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index a033125..6f3fa4b 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -32,6 +32,9 @@
         Delete a Floating IP
         List all Floating IPs
         Show Floating IP details
+        Associate a Floating IP with a port and then delete that port
+        Associate a Floating IP with a port and then with a port on another
+        router
 
     v2.0 of the Neutron API is assumed. It is also assumed that the following
     options are defined in the [network] section of etc/tempest.conf:
@@ -106,6 +109,51 @@
         self.assertIsNone(updated_floating_ip['fixed_ip_address'])
         self.assertIsNone(updated_floating_ip['router_id'])
 
+    @attr(type='smoke')
+    def test_floating_ip_delete_port(self):
+        # Create a floating IP
+        created_floating_ip = self.create_floating_ip(self.ext_net_id)
+        # Create a port
+        resp, port = self.client.create_port(self.network['id'])
+        created_port = port['port']
+        resp, floating_ip = self.client.update_floating_ip(
+            created_floating_ip['id'], port_id=created_port['id'])
+        self.assertEqual('200', resp['status'])
+        # Delete port
+        self.client.delete_port(created_port['id'])
+        # Verifies the details of the floating_ip
+        resp, floating_ip = self.client.show_floating_ip(
+            created_floating_ip['id'])
+        self.assertEqual('200', resp['status'])
+        shown_floating_ip = floating_ip['floatingip']
+        # Confirm the fields are back to None
+        self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
+        self.assertIsNone(shown_floating_ip['port_id'])
+        self.assertIsNone(shown_floating_ip['fixed_ip_address'])
+        self.assertIsNone(shown_floating_ip['router_id'])
+
+    @attr(type='smoke')
+    def test_floating_ip_update_different_router(self):
+        # Associate a floating IP to a port on a router
+        created_floating_ip = self.create_floating_ip(
+            self.ext_net_id, port_id=self.ports[1]['id'])
+        self.assertEqual(created_floating_ip['router_id'], self.router['id'])
+        network2 = self.create_network()
+        subnet2 = self.create_subnet(network2)
+        router2 = self.create_router(data_utils.rand_name('router-'),
+                                     external_network_id=self.ext_net_id)
+        self.create_router_interface(router2['id'], subnet2['id'])
+        port_other_router = self.create_port(network2)
+        # Associate floating IP to the other port on another router
+        resp, floating_ip = self.client.update_floating_ip(
+            created_floating_ip['id'], port_id=port_other_router['id'])
+        self.assertEqual('200', resp['status'])
+        updated_floating_ip = floating_ip['floatingip']
+        self.assertEqual(updated_floating_ip['router_id'], router2['id'])
+        self.assertEqual(updated_floating_ip['port_id'],
+                         port_other_router['id'])
+        self.assertIsNotNone(updated_floating_ip['fixed_ip_address'])
+
 
 class FloatingIPTestXML(FloatingIPTestJSON):
     _interface = 'xml'