Merge "Move state reporting initialization to after worker forking"
This commit is contained in:
@@ -232,7 +232,6 @@ class UnixDomainMetadataProxy(object):
|
||||
self.conf = conf
|
||||
agent_utils.ensure_directory_exists_without_file(
|
||||
cfg.CONF.metadata_proxy_socket)
|
||||
self._init_state_reporting()
|
||||
|
||||
def _init_state_reporting(self):
|
||||
self.context = context.get_admin_context_without_session()
|
||||
@@ -297,4 +296,5 @@ class UnixDomainMetadataProxy(object):
|
||||
workers=self.conf.metadata_workers,
|
||||
backlog=self.conf.metadata_backlog,
|
||||
mode=self._get_socket_mode())
|
||||
self._init_state_reporting()
|
||||
server.wait()
|
||||
|
@@ -489,6 +489,9 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
||||
backlog=128, mode=0o644),
|
||||
mock.call().wait()]
|
||||
)
|
||||
self.looping_mock.assert_called_once_with(p._report_state)
|
||||
self.looping_mock.return_value.start.assert_called_once_with(
|
||||
interval=mock.ANY)
|
||||
|
||||
def test_main(self):
|
||||
with mock.patch.object(agent, 'UnixDomainMetadataProxy') as proxy:
|
||||
@@ -503,17 +506,11 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
||||
mock.call().run()]
|
||||
)
|
||||
|
||||
def test_init_state_reporting(self):
|
||||
with mock.patch('os.makedirs'):
|
||||
proxy = agent.UnixDomainMetadataProxy(mock.Mock())
|
||||
self.looping_mock.assert_called_once_with(proxy._report_state)
|
||||
self.looping_mock.return_value.start.assert_called_once_with(
|
||||
interval=mock.ANY)
|
||||
|
||||
def test_report_state(self):
|
||||
with mock.patch('neutron.agent.rpc.PluginReportStateAPI') as state_api:
|
||||
with mock.patch('os.makedirs'):
|
||||
proxy = agent.UnixDomainMetadataProxy(mock.Mock())
|
||||
proxy = agent.UnixDomainMetadataProxy(self.cfg.CONF)
|
||||
proxy._init_state_reporting()
|
||||
self.assertTrue(proxy.agent_state['start_flag'])
|
||||
proxy._report_state()
|
||||
self.assertNotIn('start_flag', proxy.agent_state)
|
||||
|
Reference in New Issue
Block a user