]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Clean up FIP namespace in DVR functional tests
authorAssaf Muller <amuller@redhat.com>
Wed, 2 Dec 2015 01:53:16 +0000 (20:53 -0500)
committerAssaf Muller <amuller@redhat.com>
Wed, 2 Dec 2015 02:00:37 +0000 (21:00 -0500)
* Added FIP namespace cleanup to DVR router creation.
* The tests weren't actually verifying that the FIP namespace
  was being deleted.

Change-Id: I67287d397614ab368e940233c61738e0d77fbb2b
Closes-Bug: #1521820

neutron/tests/functional/agent/l3/test_dvr_router.py

index 1cdb84bbd18d28469ca9c03e235d5c52b20d2455..3ade35cc13d0523261d068f9c48c6919b756cafc 100644 (file)
@@ -19,6 +19,7 @@ import mock
 import netaddr
 
 from neutron.agent.l3 import agent as neutron_l3_agent
+from neutron.agent.l3 import dvr_fip_ns
 from neutron.agent.l3 import dvr_snat_ns
 from neutron.agent.l3 import namespaces
 from neutron.agent.linux import ip_lib
@@ -33,6 +34,18 @@ DEVICE_OWNER_COMPUTE = l3_constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 
 
 class TestDvrRouter(framework.L3AgentTestFramework):
+    def manage_router(self, agent, router):
+        def _safe_fipnamespace_delete_on_ext_net(ext_net_id):
+            try:
+                agent.fipnamespace_delete_on_ext_net(None, ext_net_id)
+            except RuntimeError:
+                pass
+        self.addCleanup(
+            _safe_fipnamespace_delete_on_ext_net,
+            router['gw_port']['network_id'])
+
+        return super(TestDvrRouter, self).manage_router(agent, router)
+
     def test_dvr_router_lifecycle_without_ha_without_snat_with_fips(self):
         self._dvr_router_lifecycle(enable_ha=False, enable_snat=False)
 
@@ -635,3 +648,5 @@ class TestDvrRouter(framework.L3AgentTestFramework):
         self.agent.fipnamespace_delete_on_ext_net(
             self.agent.context, ext_net_id)
         self._assert_interfaces_deleted_from_ovs()
+        fip_ns_name = dvr_fip_ns.FipNamespace._get_ns_name(ext_net_id)
+        self.assertFalse(self._namespace_exists(fip_ns_name))