Merge "Move state reporting initialization to after worker forking"

This commit is contained in:
Jenkins
2016-06-24 14:57:51 +00:00
committed by Gerrit Code Review
2 changed files with 6 additions and 9 deletions

View File

@@ -232,7 +232,6 @@ class UnixDomainMetadataProxy(object):
self.conf = conf self.conf = conf
agent_utils.ensure_directory_exists_without_file( agent_utils.ensure_directory_exists_without_file(
cfg.CONF.metadata_proxy_socket) cfg.CONF.metadata_proxy_socket)
self._init_state_reporting()
def _init_state_reporting(self): def _init_state_reporting(self):
self.context = context.get_admin_context_without_session() self.context = context.get_admin_context_without_session()
@@ -297,4 +296,5 @@ class UnixDomainMetadataProxy(object):
workers=self.conf.metadata_workers, workers=self.conf.metadata_workers,
backlog=self.conf.metadata_backlog, backlog=self.conf.metadata_backlog,
mode=self._get_socket_mode()) mode=self._get_socket_mode())
self._init_state_reporting()
server.wait() server.wait()

View File

@@ -489,6 +489,9 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
backlog=128, mode=0o644), backlog=128, mode=0o644),
mock.call().wait()] 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): def test_main(self):
with mock.patch.object(agent, 'UnixDomainMetadataProxy') as proxy: with mock.patch.object(agent, 'UnixDomainMetadataProxy') as proxy:
@@ -503,17 +506,11 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
mock.call().run()] 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): def test_report_state(self):
with mock.patch('neutron.agent.rpc.PluginReportStateAPI') as state_api: with mock.patch('neutron.agent.rpc.PluginReportStateAPI') as state_api:
with mock.patch('os.makedirs'): 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']) self.assertTrue(proxy.agent_state['start_flag'])
proxy._report_state() proxy._report_state()
self.assertNotIn('start_flag', proxy.agent_state) self.assertNotIn('start_flag', proxy.agent_state)