Exemple #1
0
 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_bgp_dragent_manager(self):
     state_rpc_str = 'neutron.agent.rpc.PluginReportStateAPI'
     # sync_state is needed for this test
     with mock.patch.object(bgp_dragent.BgpDrAgentWithStateReport,
                            'sync_state',
                            autospec=True) as mock_sync_state:
         with mock.patch(state_rpc_str) as state_rpc:
             with mock.patch.object(sys, 'argv') as sys_argv:
                 sys_argv.return_value = [
                     'bgp_dragent', '--config-file',
                     base.etcdir('neutron.conf')]
                 config.register_agent_state_opts_helper(cfg.CONF)
                 n_config.init(sys.argv[1:])
                 agent_mgr = bgp_dragent.BgpDrAgentWithStateReport(
                     'testhost')
                 eventlet.greenthread.sleep(1)
                 agent_mgr.after_start()
                 self.assertIsNotNone(len(mock_sync_state.mock_calls))
                 state_rpc.assert_has_calls(
                     [mock.call(mock.ANY),
                      mock.call().report_state(mock.ANY, mock.ANY,
                                               mock.ANY)])