Browse Source

OSP-244 Add Topo Sync Mock

We have made quite a few changes to the way we trigger topo sync,
and it can be triggered outside of watchdog currently.

Disabling the watchdog does not totally prevent topo sync from
being triggered.

It is easier to just return a success result than modifying codes
related to different cases that trigger topo sync, when there is
no need to verify those behaviors.

Currently the patch is only used in one test class:
TestBigSwitchMechDriverNetworksV2, but it can be reused in other
test classes if we find it neccessary.

Change-Id: If9f795507402cb870d93656b0f5b7f4fcb95c9d1
Weifan Fu 6 months ago
parent
commit
7d323a0040

+ 8
- 0
networking_bigswitch/tests/unit/bigswitch/test_base.py View File

@@ -26,6 +26,8 @@ from networking_bigswitch.plugins.bigswitch.db import consistency_db
26 26
 from networking_bigswitch.plugins.bigswitch.db import network_template_db  # noqa
27 27
 from networking_bigswitch.plugins.bigswitch.db import reachability_test_db  # noqa
28 28
 from networking_bigswitch.plugins.bigswitch.db import tenant_policy_db  # noqa
29
+from networking_bigswitch.plugins.bigswitch.servermanager\
30
+    import TOPO_RESPONSE_OK
29 31
 from networking_bigswitch.tests.unit.bigswitch import fake_server
30 32
 
31 33
 
@@ -105,6 +107,12 @@ class BigSwitchTestBase(object):
105 107
                                     new=fake_server.HTTPConnectionMock)
106 108
         self.httpPatch.start()
107 109
 
110
+    def startTopoSyncPatch(self):
111
+        self.topo_sync_p = \
112
+            mock.patch(SERVER_MANAGER + '.ServerPool.force_topo_sync',
113
+                       return_value=(True, TOPO_RESPONSE_OK))
114
+        self.topo_sync_p.start()
115
+
108 116
     def setup_db(self):
109 117
         # setup the db engine and models for the consistency db
110 118
         consistency_db.setup_db()

+ 3
- 0
networking_bigswitch/tests/unit/ml2/drivers/test_bigswitch_mech.py View File

@@ -79,6 +79,9 @@ class TestBigSwitchMechDriverBase(trp.BigSwitchProxyPluginV2TestCase):
79 79
 class TestBigSwitchMechDriverNetworksV2(test_db_base_plugin_v2.TestNetworksV2,
80 80
                                         TestBigSwitchMechDriverBase):
81 81
     def setUp(self, plugin=None, service_plugins=None, ext_mgr=None):
82
+        # topo sync can be triggered outside of watchdog
83
+        self.startTopoSyncPatch()
84
+
82 85
         TestBigSwitchMechDriverBase.setUp(self,
83 86
                                           plugin=plugin,
84 87
                                           service_plugins=service_plugins,

Loading…
Cancel
Save