Skip to content

Commit

Permalink
router d.p. can be started as non-standalone
Browse files Browse the repository at this point in the history
Added "standalone" parameter to router data provider initialization.  If two
threads of the same process call "load_schemas", it can lead to inconsistent
runtime schema data.  The change tells the data provider to not load its own
schema in tests.

Signed-off-by: Martin Volf <[email protected]>
  • Loading branch information
martin-volf committed Dec 14, 2023
1 parent e943bcd commit b10df28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/route_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class RouteProvider:
@staticmethod
def init_dp(route_data: RouteData,
confd_ip=None,
standalone=True,
confd_port=_confd.CONFD_PORT,
confd_debug_level=_confd.DEBUG):
log.info("==>")
Expand All @@ -147,7 +148,8 @@ def init_dp(route_data: RouteData,
confd_ip, confd_port)
dp.connect(RouteProvider.ctx, RouteProvider.wrksock, dp.WORKER_SOCKET,
confd_ip, confd_port)
maapi.load_schemas(RouteProvider.maapisock)
if standalone:
maapi.load_schemas(RouteProvider.maapisock)

tcb = TransCbs(RouteProvider.wrksock)
dp.register_trans_cb(RouteProvider.ctx, tcb)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_server_confd.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_subscribe_stream_on_change_api_state(self, request):

route_data = RouteData(num=10, random=False)
assert len(route_data.routes)
RouteProvider.init_dp(route_data, confd_debug_level=_confd_DEBUG)
RouteProvider.init_dp(route_data, confd_debug_level=_confd_DEBUG, standalone=False)

confd_thread = threading.Thread(target=RouteProvider.confd_loop)
change_thread = threading.Thread(
Expand Down

0 comments on commit b10df28

Please sign in to comment.