]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Router test enhancements
authorabhishek60014726 <abhishek.g-m@hp.com>
Wed, 25 Mar 2015 12:50:29 +0000 (05:50 -0700)
committerabhishek60014726 <abhishek.g-m@hp.com>
Thu, 2 Apr 2015 06:42:56 +0000 (23:42 -0700)
Add test to attach two routers to the same network
   -Create a network
   -Create a subnet
   -Create two port for the same network
   -Create two routers
   -Add router interface with the port_id for two routers by using respective port_ids
   -Verify the port device_id with that of router_id
   -Verify the port network id with that of created network

Change-Id: Id9de0edf687319b6e20804daee347b41d8b840a2

neutron/tests/api/test_routers.py

index fc5efceda3792e1381ef6e14504f96921b9967c5..5f3d2b0defbee7bd443dcfd83e50b665b5708845 100644 (file)
@@ -354,6 +354,32 @@ class RoutersTest(base.BaseRouterTest):
         self.assertEqual(subnet_id,
                          interface_port['fixed_ips'][0]['subnet_id'])
 
+    @test.attr(type='smoke')
+    @test.idempotent_id('01f185d1-d1a6-4cf9-abf7-e0e1384c169c')
+    def test_network_attached_with_two_routers(self):
+        network = self.create_network(data_utils.rand_name('network1'))
+        self.create_subnet(network)
+        port1 = self.create_port(network)
+        port2 = self.create_port(network)
+        router1 = self._create_router(data_utils.rand_name('router1'))
+        router2 = self._create_router(data_utils.rand_name('router2'))
+        self.client.add_router_interface_with_port_id(
+            router1['id'], port1['id'])
+        self.client.add_router_interface_with_port_id(
+            router2['id'], port2['id'])
+        self.addCleanup(self.client.remove_router_interface_with_port_id,
+                        router1['id'], port1['id'])
+        self.addCleanup(self.client.remove_router_interface_with_port_id,
+                        router2['id'], port2['id'])
+        body = self.client.show_port(port1['id'])
+        port_show1 = body['port']
+        body = self.client.show_port(port2['id'])
+        port_show2 = body['port']
+        self.assertEqual(port_show1['network_id'], network['id'])
+        self.assertEqual(port_show2['network_id'], network['id'])
+        self.assertEqual(port_show1['device_id'], router1['id'])
+        self.assertEqual(port_show2['device_id'], router2['id'])
+
 
 class RoutersIpV6Test(RoutersTest):
     _ip_version = 6