Merge "Add agent_updated to BgpDrAgentNotifyApi notifier" into stable/rocky
This commit is contained in:
commit
d5e98c5c56
|
@ -34,6 +34,14 @@ class BgpDrAgentNotifyApi(object):
|
|||
self.client = n_rpc.get_client(target)
|
||||
self.topic = topic
|
||||
|
||||
def agent_updated(self, context, admin_state_up, host):
|
||||
"""Tell BgpDrAgent that agent was updated.
|
||||
|
||||
This effectively tells the bgp_dragent to resync.
|
||||
"""
|
||||
self._notification_host_cast(context, 'agent_updated',
|
||||
{'admin_state_up': admin_state_up}, host)
|
||||
|
||||
def bgp_routes_advertisement(self, context, bgp_speaker_id,
|
||||
routes, host):
|
||||
"""Tell BgpDrAgent to begin advertising the given route.
|
||||
|
|
|
@ -37,6 +37,13 @@ class TestBgpDrAgentNotifyApi(base.BaseTestCase):
|
|||
self.context = context.get_admin_context()
|
||||
self.host = 'host-1'
|
||||
|
||||
def test_agent_updated(self):
|
||||
admin_state_up = True
|
||||
host = 'my-hostname'
|
||||
self.notifier.agent_updated(self.context, admin_state_up, host)
|
||||
self.assertEqual(1, self.mock_cast.call_count)
|
||||
self.assertEqual(0, self.mock_call.call_count)
|
||||
|
||||
def test_notify_dragent_bgp_routes_advertisement(self):
|
||||
bgp_speaker_id = 'bgp-speaker-1'
|
||||
routes = [{'destination': '1.1.1.1', 'next_hop': '2.2.2.2'}]
|
||||
|
|
|
@ -66,6 +66,7 @@ class TestBgpDrAgent(base.BaseTestCase):
|
|||
super(TestBgpDrAgent, self).setUp()
|
||||
cfg.CONF.register_opts(bgp_config.BGP_DRIVER_OPTS, 'BGP')
|
||||
cfg.CONF.register_opts(bgp_config.BGP_PROTO_CONFIG_OPTS, 'BGP')
|
||||
cfg.CONF.register_opts(config.AGENT_STATE_OPTS, 'AGENT')
|
||||
mock_log_p = mock.patch.object(bgp_dragent, 'LOG')
|
||||
self.mock_log = mock_log_p.start()
|
||||
self.driver_cls_p = mock.patch(
|
||||
|
@ -109,6 +110,14 @@ class TestBgpDrAgent(base.BaseTestCase):
|
|||
bgp_dr.after_start()
|
||||
self.assertIsNotNone(len(sync_state.mock_calls))
|
||||
|
||||
def test_agent_updated(self):
|
||||
bgp_dr = bgp_dragent.BgpDrAgentWithStateReport(HOSTNAME)
|
||||
payload = {'admin_state_up': True}
|
||||
with mock.patch.object(bgp_dr, 'agent_updated') as agent_updated:
|
||||
bgp_dr.agent_updated(self.context, payload)
|
||||
self.assertIsNotNone(len(agent_updated.mock_calls))
|
||||
self.assertEqual(1, bgp_dr.agent_updated.call_count)
|
||||
|
||||
def _test_sync_state_helper(self, bgp_speaker_list=None,
|
||||
cached_info=None,
|
||||
safe_configure_call_count=0,
|
||||
|
|
Loading…
Reference in New Issue