Browse Source

OSP-256: Mock oslo_messaging.server.MessageHandlingServer.start to fix Max workers must be greater than 0 issue for local unit tests

Some of the other RPC related mocks are no longer needed and thus
removed.

Change-Id: I1e585c4fcbabf79855b1226e92fe49a8b75a5b20
Weifan Fu 4 months ago
parent
commit
53148f16ff

+ 3
- 3
networking_bigswitch/tests/unit/bigswitch/mock_paths.py View File

@@ -22,9 +22,6 @@ import six
22 22
 KEYSTONE_CLIENT = 'keystoneclient.v3.client.Client'
23 23
 
24 24
 # Neutron
25
-DHCP_NOTIFIER = ('neutron.api.rpc.agentnotifiers.dhcp_rpc_agent_api'
26
-                 '.DhcpAgentNotifyAPI.notify')
27
-
28 25
 NEUTRON_AGENT = 'neutron.agent'
29 26
 OVS_BRIDGE = NEUTRON_AGENT + '.common.ovs_lib.OVSBridge'
30 27
 PLUGIN_API = NEUTRON_AGENT + '.rpc.PluginApi'
@@ -37,6 +34,9 @@ CONTEXT = 'neutron_lib.context'
37 34
 NEUTRON_CFG = 'neutron.common.config'
38 35
 LIB_RPC_TRANSPORT = 'neutron_lib.rpc.TRANSPORT'
39 36
 
37
+# oslo_messaging
38
+RPC_SERVER_START = ('oslo_messaging.server.MessageHandlingServer.start')
39
+
40 40
 # BSN
41 41
 BSN_DIR = 'networking_bigswitch.plugins.bigswitch'
42 42
 

+ 0
- 1
networking_bigswitch/tests/unit/bigswitch/test_agent_scheduler.py View File

@@ -31,4 +31,3 @@ class BigSwitchDhcpAgentNotifierTestCase(
31 31
         test_agentschedulers_db.OvsDhcpAgentNotifierTestCase.setUp(self)
32 32
         self.setup_db()
33 33
         self.startHttpPatch()
34
-        self.dhcp_notifier_p.stop()

+ 6
- 10
networking_bigswitch/tests/unit/bigswitch/test_base.py View File

@@ -33,7 +33,6 @@ from networking_bigswitch.tests.unit.bigswitch import fake_server
33 33
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import BACKGROUND
34 34
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
35 35
     BSN_SERVICE_PLUGIN_PATH
36
-from networking_bigswitch.tests.unit.bigswitch.mock_paths import DHCP_NOTIFIER
37 36
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import HTTPCON
38 37
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
39 38
     IS_UNICODE_ENABLED
@@ -44,10 +43,11 @@ from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
44 43
     LIB_RPC_TRANSPORT
45 44
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
46 45
     MAP_DISPLAY_NAME_OR_TENANT
47
-from networking_bigswitch.tests.unit.bigswitch.mock_paths import NOTIFIER
48 46
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import PLUGIN_PATH
49 47
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
50 48
     POOL_TOPO_SYNC
49
+from networking_bigswitch.tests.unit.bigswitch.mock_paths import \
50
+    RPC_SERVER_START
51 51
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import SERVER_MANAGER
52 52
 from networking_bigswitch.tests.unit.bigswitch.mock_paths import SPAWN
53 53
 
@@ -87,8 +87,8 @@ class BigSwitchTestBase(object):
87 87
         return False
88 88
 
89 89
     def setup_patches(self):
90
-        self.plugin_notifier_p = mock.patch(NOTIFIER)
91
-        self.dhcp_notifier_p = mock.patch(DHCP_NOTIFIER)
90
+        self.lib_rpc_transport_p = mock.patch(LIB_RPC_TRANSPORT)
91
+        self.rpc_server_start_p = mock.patch(RPC_SERVER_START)
92 92
         # prevent any greenthreads from spawning
93 93
         self.spawn_p = mock.patch(SPAWN, new=lambda *args, **kwargs: None)
94 94
         # prevent the consistency watchdog and keystone sync from starting
@@ -105,19 +105,15 @@ class BigSwitchTestBase(object):
105 105
         self.is_unicode_enabled_p = mock.patch(
106 106
             IS_UNICODE_ENABLED,
107 107
             side_effect=self.is_unicode_enabled_side_effect)
108
-        # TODO(weifan): Find out why Mocking Transport does not work
109
-        # This mock fixes problems on zuul, but it is still broken locally
110
-        self.lib_rpc_transport_p = mock.patch(LIB_RPC_TRANSPORT)
111 108
         # start all mock patches
112 109
         self.log_exc_p.start()
113
-        self.plugin_notifier_p.start()
114
-        self.dhcp_notifier_p.start()
110
+        self.lib_rpc_transport_p.start()
111
+        self.rpc_server_start_p.start()
115 112
         self.spawn_p.start()
116 113
         self.watch_p.start()
117 114
         self.ksclient_p.start()
118 115
         self.map_display_name_or_tenant_p.start()
119 116
         self.is_unicode_enabled_p.start()
120
-        self.lib_rpc_transport_p.start()
121 117
 
122 118
     def startHttpPatch(self):
123 119
         self.httpPatch = mock.patch(HTTPCON,

+ 5
- 0
networking_bigswitch/tests/unit/bigswitch/test_security_groups.py View File

@@ -13,12 +13,15 @@
13 13
 #    License for the specific language governing permissions and limitations
14 14
 #    under the License.
15 15
 
16
+import mock
16 17
 from neutron.tests.unit.agent import test_securitygroups_rpc as test_sg_rpc
17 18
 from neutron.tests.unit.extensions import test_securitygroup as test_sg
18 19
 from neutron_lib.plugins import directory
19 20
 
20 21
 from networking_bigswitch.tests.unit.bigswitch import test_base
21 22
 
23
+from networking_bigswitch.tests.unit.bigswitch.mock_paths import NOTIFIER
24
+
22 25
 
23 26
 class RestProxySecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase,
24 27
                                       test_base.BigSwitchTestBase):
@@ -27,8 +30,10 @@ class RestProxySecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase,
27 30
 
28 31
     def setUp(self, plugin=None):
29 32
         test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER)
33
+        self.plugin_notifier_p = mock.patch(NOTIFIER)
30 34
         self.setup_config_files()
31 35
         self.setup_patches()
36
+        self.plugin_notifier_p.start()
32 37
         self._attribute_map_bk_ = {}
33 38
         test_sg.SecurityGroupDBTestCase.setUp(self, self.plugin_str)
34 39
         self.setup_db()

Loading…
Cancel
Save