Browse Source

Fixup unit tests to sync with neutron changes

Change-Id: Ib2dfa55e57fe7886626210e985bfc4e446ff8818
Stephen Ma 1 month ago
parent
commit
722bd66e8e

+ 1
- 1
networking_vsphere/agent/ovsvapp_agent.py View File

@@ -30,12 +30,12 @@ from neutron_lib.agent import topics
30 30
 from neutron_lib import constants as p_const
31 31
 from neutron_lib import context
32 32
 from neutron_lib.plugins import utils as p_utils
33
+from neutron_lib import rpc as n_rpc
33 34
 from neutron_lib.utils import helpers
34 35
 
35 36
 from neutron.agent.common import ovs_lib
36 37
 from neutron.agent import rpc as agent_rpc
37 38
 from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
38
-from neutron.common import rpc as n_rpc
39 39
 from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants as ovs_const  # noqa
40 40
 from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_neutron_agent as ovs_agent  # noqa
41 41
 from neutron.plugins.ml2.drivers.openvswitch.agent import vlanmanager

+ 1
- 1
networking_vsphere/agent/ovsvapp_sg_agent.py View File

@@ -29,7 +29,7 @@ from networking_vsphere._i18n import _LI, _LE
29 29
 from networking_vsphere.common import constants as ovsvapp_const
30 30
 
31 31
 from neutron.agent import securitygroups_rpc as sg_rpc
32
-from neutron.common import rpc as n_rpc
32
+from neutron_lib import rpc as n_rpc
33 33
 
34 34
 LOG = log.getLogger(__name__)
35 35
 

+ 1
- 1
networking_vsphere/common/dvs_agent_rpc_api.py View File

@@ -13,8 +13,8 @@
13 13
 #    License for the specific language governing permissions and limitations
14 14
 #    under the License.
15 15
 
16
-from neutron.common import rpc as n_rpc
17 16
 from neutron_lib.agent import topics
17
+from neutron_lib import rpc as n_rpc
18 18
 import oslo_messaging
19 19
 
20 20
 from networking_vsphere.common import constants as dvs_const

+ 1
- 2
networking_vsphere/ml2/ovsvapp_mech_driver.py View File

@@ -21,8 +21,6 @@ from oslo_config import cfg
21 21
 from oslo_log import log
22 22
 from oslo_utils import timeutils
23 23
 
24
-from neutron.common import rpc as n_rpc
25
-
26 24
 from neutron.plugins.ml2.drivers import mech_agent
27 25
 from neutron_lib.agent import topics
28 26
 from neutron_lib.api.definitions import portbindings
@@ -30,6 +28,7 @@ from neutron_lib import constants as n_const
30 28
 from neutron_lib import context as neutron_context
31 29
 from neutron_lib.plugins import directory
32 30
 from neutron_lib.plugins.ml2 import api
31
+from neutron_lib import rpc as n_rpc
33 32
 
34 33
 from networking_vsphere._i18n import _LE, _LI
35 34
 from networking_vsphere.common import constants as ovsvapp_const

+ 1
- 1
networking_vsphere/ml2/ovsvapp_rpc.py View File

@@ -25,7 +25,6 @@ from networking_vsphere.common import constants as ovsvapp_const
25 25
 from networking_vsphere.common import utils as ovsvapp_utils
26 26
 from networking_vsphere.db import ovsvapp_db
27 27
 
28
-from neutron.common import rpc as n_rpc
29 28
 from neutron.db import models_v2
30 29
 from neutron.db import securitygroups_rpc_base as sg_rpc_base
31 30
 from neutron.plugins.ml2 import db
@@ -36,6 +35,7 @@ from neutron_lib.agent import topics
36 35
 from neutron_lib.api.definitions import portbindings
37 36
 from neutron_lib import constants as common_const
38 37
 from neutron_lib.plugins.ml2 import api
38
+from neutron_lib import rpc as n_rpc
39 39
 
40 40
 LOG = log.getLogger(__name__)
41 41
 

+ 14
- 6
networking_vsphere/tests/base.py View File

@@ -18,15 +18,20 @@ import logging
18 18
 import eventlet
19 19
 import fixtures
20 20
 import mock
21
-from oslo_config import cfg
22
-from oslo_messaging import conffixture as messaging_conffixture
23
-from oslotest import base
24 21
 import six
25 22
 
26 23
 from networking_vsphere.common import config as ovsvapp_config
27 24
 
28
-from neutron.common import rpc as n_rpc
29
-from neutron.tests import fake_notifier
25
+from neutron_lib import fixture
26
+from neutron_lib import rpc as n_rpc
27
+from neutron_lib.tests.unit import fake_notifier
28
+
29
+from neutron.tests import tools
30
+
31
+from oslo_concurrency.fixture import lockutils
32
+from oslo_config import cfg
33
+from oslo_messaging import conffixture as messaging_conffixture
34
+from oslotest import base
30 35
 
31 36
 CONF = cfg.CONF
32 37
 eventlet.monkey_patch()
@@ -41,6 +46,9 @@ class TestCase(base.BaseTestCase):
41 46
         super(base.BaseTestCase, self).setUp()
42 47
         ovsvapp_config.register_options()
43 48
         self.setup_rpc_mocks()
49
+        self.useFixture(lockutils.ExternalLockFixture())
50
+        self.useFixture(fixture.APIDefinitionFixture())
51
+        self.useFixture(tools.WarningsFixture())
44 52
         self.mock = mock.Mock()
45 53
         self.logger = self.useFixture(fixtures.FakeLogger(name="neutron",
46 54
                                                           level=logging.INFO
@@ -51,7 +59,7 @@ class TestCase(base.BaseTestCase):
51 59
 
52 60
     def setup_rpc_mocks(self):
53 61
         # don't actually start RPC listeners when testing
54
-        mock.patch('neutron.common.rpc.Connection.consume_in_threads',
62
+        mock.patch('neutron_lib.rpc.Connection.consume_in_threads',
55 63
                    return_value=[]).start()
56 64
 
57 65
         self.useFixture(fixtures.MonkeyPatch(

+ 6
- 6
networking_vsphere/tests/unit/agent/test_ovsvapp_agent.py View File

@@ -146,7 +146,7 @@ class TestOVSvAppAgentRestart(base.TestCase):
146 146
 
147 147
     @mock.patch('neutron.common.config.init')
148 148
     @mock.patch('neutron.common.config.setup_logging')
149
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
149
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
150 150
     @mock.patch('networking_vsphere.agent.ovsvapp_agent.RpcPluginApi')
151 151
     @mock.patch('neutron.api.rpc.handlers.securitygroups_rpc.'
152 152
                 'SecurityGroupServerRpcApi')
@@ -299,7 +299,7 @@ class TestOVSvAppAgentRestart(base.TestCase):
299 299
             self.assertTrue(mock_delete_port.called)
300 300
             self.assertTrue(mock_int_del_port.called)
301 301
 
302
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
302
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
303 303
     def test_setup_ovs_bridges_vxlan_restart(self, mock_ovsdb_api):
304 304
         self.agent.local_ip = "10.10.10.10"
305 305
         bridge_tunnel = 'br-tunnel'
@@ -333,7 +333,7 @@ class TestOVSvAppAgent(base.TestCase):
333 333
 
334 334
     @mock.patch('neutron.common.config.init')
335 335
     @mock.patch('neutron.common.config.setup_logging')
336
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
336
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
337 337
     @mock.patch('networking_vsphere.agent.ovsvapp_agent.RpcPluginApi')
338 338
     @mock.patch('neutron.api.rpc.handlers.securitygroups_rpc.'
339 339
                 'SecurityGroupServerRpcApi')
@@ -525,7 +525,7 @@ class TestOVSvAppAgent(base.TestCase):
525 525
                               "br-eth3:physnet1", 'SECURITYGROUP')
526 526
         self._test_recover_security_br(mock_ovs_bridge, test_parms)
527 527
 
528
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
528
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
529 529
     def test_recover_physical_bridges(self, mock_ovsdb_api):
530 530
         cfg.CONF.set_override('bridge_mappings',
531 531
                               ["physnet1:br-eth1"], 'OVSVAPP')
@@ -686,7 +686,7 @@ class TestOVSvAppAgent(base.TestCase):
686 686
             mock_init_ovs_flows.assert_called_with(self.agent.bridge_mappings)
687 687
             self.assertTrue(mock_rarp_flow.called)
688 688
 
689
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
689
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
690 690
     def test_setup_ovs_bridges_vxlan(self, mock_ovsdb_api):
691 691
         self.agent.local_ip = "10.10.10.10"
692 692
         self.agent.tenant_network_types = [p_const.TYPE_VXLAN]
@@ -703,7 +703,7 @@ class TestOVSvAppAgent(base.TestCase):
703 703
             self.assertTrue(mock_setup_tunnel_br_flows.called)
704 704
             self.assertTrue(mock_rarp_flow.called)
705 705
 
706
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
706
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
707 707
     def test_setup_ovs_bridges_vxlan_ofport(self, mock_ovsdb_api):
708 708
         cfg.CONF.set_override('tenant_network_types',
709 709
                               "vxlan", 'OVSVAPP')

+ 1
- 1
networking_vsphere/tests/unit/agent/test_ovsvapp_sg_agent.py View File

@@ -71,7 +71,7 @@ class TestOVSvAppSecurityGroupAgent(base.TestCase):
71 71
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.create')
72 72
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.set_secure_mode')
73 73
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.get_port_ofport')
74
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
74
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
75 75
     def setUp(self, mock_ovsdb_api, mock_get_port_ofport,
76 76
               mock_set_secure_mode, mock_create_ovs_bridge,
77 77
               mock_setup_base_flows,

+ 1
- 1
networking_vsphere/tests/unit/drivers/test_ovs_firewall.py View File

@@ -67,7 +67,7 @@ class TestOVSFirewallDriver(base.TestCase):
67 67
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.create')
68 68
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.set_secure_mode')
69 69
     @mock.patch('neutron.agent.common.ovs_lib.OVSBridge.get_port_ofport')
70
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
70
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
71 71
     def setUp(self, mock_ovsdb_api, mock_get_port_ofport, mock_set_secure_mode,
72 72
               mock_create_ovs_bridge, mock_setup_base_flows,
73 73
               mock_check_ovs_firewall_restart,

+ 3
- 3
networking_vsphere/tests/unit/utils/test_ovs_bridge_util.py View File

@@ -34,7 +34,7 @@ FAKE_ETH_OFPORT = 6
34 34
 
35 35
 class TestOVSvAppIntegrationBridge(base.TestCase):
36 36
 
37
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
37
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
38 38
     def setUp(self, mock_ovsdb_api):
39 39
         super(TestOVSvAppIntegrationBridge, self).setUp()
40 40
         self.int_br = ovsvapp_br.OVSvAppIntegrationBridge("br-int")
@@ -97,7 +97,7 @@ class TestOVSvAppIntegrationBridge(base.TestCase):
97 97
 
98 98
 class TestOVSvAppPhysicalBridge(base.TestCase):
99 99
 
100
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
100
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
101 101
     def setUp(self, mock_ovsdb_api):
102 102
         super(TestOVSvAppPhysicalBridge, self).setUp()
103 103
         self.br = ovsvapp_br.OVSvAppPhysicalBridge("br-phy")
@@ -152,7 +152,7 @@ class TestOVSvAppPhysicalBridge(base.TestCase):
152 152
 
153 153
 class TestOVSvAppTunnelBridge(base.TestCase):
154 154
 
155
-    @mock.patch('neutron.agent.ovsdb.api.from_config')
155
+    @mock.patch('neutron.agent.ovsdb.impl_idl.api_factory')
156 156
     def setUp(self, mock_ovsdb_api):
157 157
         super(TestOVSvAppTunnelBridge, self).setUp()
158 158
         self.tun_br = ovsvapp_br.OVSvAppTunnelBridge("br-tun")

Loading…
Cancel
Save