Commit a3fc2e18 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

updated tests, and fixed a bug where a module could potentially return a message when it shouldn't


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac292@3256 e5f2f494-b856-4b98-b285-d166d9295462
parent 3c9e7b76
......@@ -216,7 +216,8 @@ class ModuleCCSession(ConfigData):
newc = self._remote_module_configs[module_name].get_local_config()
isc.cc.data.merge(newc, new_config)
self._remote_module_configs[module_name].set_local_config(newc)
return
# For other modules, we're not supposed to answer
return
# ok, so apparently this update is for us.
errors = []
......
......@@ -440,16 +440,41 @@ class TestModuleCCSession(unittest.TestCase):
def test_check_command_without_recvmsg_remote_module(self):
"copied from test_check_command3"
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec2.spec", None, None, fake_session)
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.set_config_handler(self.my_config_handler_ok)
self.assertEqual(len(fake_session.message_queue), 0)
fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
print(fake_session.message_queue)
self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
fake_session.get_message('ConfigManager', None))
self.assertEqual(len(fake_session.message_queue), 0)
cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec2': { 'item1': 2 }})
env = { 'group':'Spec2', 'from':None }
self.assertEqual(len(fake_session.message_queue), 0)
mccs.check_command_without_recvmsg(cmd, env)
self.assertEqual(len(fake_session.message_queue), 1)
self.assertEqual({'result': [0]},
fake_session.get_message('Spec2', None))
self.assertEqual(len(fake_session.message_queue), 0)
def test_check_command_without_recvmsg_remote_module2(self):
"copied from test_check_command3"
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.set_config_handler(self.my_config_handler_ok)
self.assertEqual(len(fake_session.message_queue), 0)
fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
fake_session.get_message('ConfigManager', None))
self.assertEqual(len(fake_session.message_queue), 0)
cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec3': { 'item1': 2 }})
env = { 'group':'Spec3', 'from':None }
self.assertEqual(len(fake_session.message_queue), 0)
mccs.check_command_without_recvmsg(cmd, env)
self.assertEqual(len(fake_session.message_queue), 0)
def test_check_command_block_timeout(self):
"""Check it works if session has timeout and it sets it back."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment