]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix some NVP tests do not do cleanup of nvp ports
authorAaron Rosen <arosen@nicira.com>
Wed, 7 Aug 2013 18:24:01 +0000 (11:24 -0700)
committerAaron Rosen <arosen@nicira.com>
Mon, 12 Aug 2013 22:03:13 +0000 (15:03 -0700)
Some of the NVP test do not execute self.addCleanup(self.fc.reset_all)
from setUp() as NiciraPluginV2TestCase is not the first mixin.
This casuses left over ports to still exist between different testcases.
This patch only fixes this issue for TestNiciraPortsV2 and
NiciraPortSecurityTestCaseas, some of the other tests require the setUp()
for the first mixin to be called for their tests to work.

Note: this is why the tests for the Remove DHCP lease logic are failing.

Fixes bug: 1209355

Change-Id: I932471cdb8925353c5825cd70c8217511d6d7938

neutron/tests/unit/nicira/test_nicira_plugin.py

index 00746350c4b5bfeeff8478ce169b569103cdd1b4..8eeb72bd266c40a427256d4b55ee3ad9a45dffc3 100644 (file)
@@ -105,8 +105,8 @@ class TestNiciraV2HTTPResponse(test_plugin.TestV2HTTPResponse,
     pass
 
 
-class TestNiciraPortsV2(test_plugin.TestPortsV2,
-                        NiciraPluginV2TestCase,
+class TestNiciraPortsV2(NiciraPluginV2TestCase,
+                        test_plugin.TestPortsV2,
                         test_bindings.PortBindingsTestCase):
 
     VIF_TYPE = portbindings.VIF_TYPE_OVS
@@ -282,21 +282,22 @@ class NiciraPortSecurityTestCase(psec.PortSecurityDBTestCase):
     def setUp(self):
         test_lib.test_config['config_files'] = [get_fake_conf('nvp.ini.test')]
         # mock nvp api client
-        fc = fake_nvpapiclient.FakeClient(STUBS_PATH)
+        self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH)
         self.mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True)
         instance = self.mock_nvpapi.start()
         instance.return_value.login.return_value = "the_cookie"
 
         def _fake_request(*args, **kwargs):
-            return fc.fake_request(*args, **kwargs)
+            return self.fc.fake_request(*args, **kwargs)
 
         instance.return_value.request.side_effect = _fake_request
         super(NiciraPortSecurityTestCase, self).setUp(PLUGIN_NAME)
+        self.addCleanup(self.fc.reset_all)
         self.addCleanup(self.mock_nvpapi.stop)
 
 
-class TestNiciraPortSecurity(psec.TestPortSecurity,
-                             NiciraPortSecurityTestCase):
+class TestNiciraPortSecurity(NiciraPortSecurityTestCase,
+                             psec.TestPortSecurity):
         pass