[svn] commit: r3111 - in /branches/trac349/src: bin/bind10/bind10.8 lib/python/isc/config/tests/ccsession_test.py lib/python/isc/config/tests/cfgmgr_test.py lib/python/isc/config/tests/unittest_fakesession.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Oct 4 18:06:25 UTC 2010
Author: vorner
Date: Mon Oct 4 18:06:25 2010
New Revision: 3111
Log:
Introduce WouldBlockForever test exception
It is thrown if a blocking read is requested on empty fake_session.
Fixed tests that depended on wrong fake_session behaviour/sideeffected
on it.
Modified:
branches/trac349/src/bin/bind10/bind10.8
branches/trac349/src/lib/python/isc/config/tests/ccsession_test.py
branches/trac349/src/lib/python/isc/config/tests/cfgmgr_test.py
branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py
Modified: branches/trac349/src/bin/bind10/bind10.8
==============================================================================
--- branches/trac349/src/bin/bind10/bind10.8 (original)
+++ branches/trac349/src/bin/bind10/bind10.8 Mon Oct 4 18:06:25 2010
@@ -1,13 +1,22 @@
'\" t
.\" Title: bind10
.\" Author: [see the "AUTHORS" section]
-.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Generator: DocBook XSL Stylesheets v1.76.0 <http://docbook.sf.net/>
.\" Date: July 29, 2010
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "BIND10" "8" "July 29, 2010" "BIND10" "BIND10"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
Modified: branches/trac349/src/lib/python/isc/config/tests/ccsession_test.py
==============================================================================
--- branches/trac349/src/lib/python/isc/config/tests/ccsession_test.py (original)
+++ branches/trac349/src/lib/python/isc/config/tests/ccsession_test.py Mon Oct 4 18:06:25 2010
@@ -125,6 +125,8 @@
self.assertTrue("Spec1" in fake_session.subscriptions)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec1')
+ fake_session.group_sendmsg(None, 'Spec1')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', {'module_name': 'Spec1'}]},
@@ -150,6 +152,8 @@
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec2.spec", None, None, fake_session)
self.assertEqual(len(fake_session.message_queue), 0)
+ fake_session.group_sendmsg(None, 'Spec2')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -173,6 +177,8 @@
mccs = self.create_session("spec2.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')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -196,6 +202,8 @@
mccs = self.create_session("spec2.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')
+ fake_session.group_sendmsg(None, 'Spec2')
self.assertRaises(ModuleCCSessionError, mccs.start)
self.assertEqual(len(fake_session.message_queue), 2)
self.assertEqual({'command': ['module_spec', mccs.specification._module_spec]},
@@ -382,6 +390,7 @@
self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
self.assertFalse("Spec2" in fake_session.subscriptions)
+ fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
self.assertTrue("Spec2" in fake_session.subscriptions)
self.assertEqual("Spec2", rmodname)
@@ -395,6 +404,7 @@
self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
# test if unsubscription is alse sent when object is deleted
+ fake_session.group_sendmsg({'result' : [0]}, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
self.assertTrue("Spec2" in fake_session.subscriptions)
mccs = None
@@ -405,6 +415,7 @@
fake_session = FakeModuleCCSession()
mccs = self.create_session("spec1.spec", None, None, fake_session)
mccs.set_command_handler(self.my_command_handler_ok)
+ fake_session.group_sendmsg(None, 'Spec2')
rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
# remove the 'get config' from the queue
Modified: branches/trac349/src/lib/python/isc/config/tests/cfgmgr_test.py
==============================================================================
--- branches/trac349/src/lib/python/isc/config/tests/cfgmgr_test.py (original)
+++ branches/trac349/src/lib/python/isc/config/tests/cfgmgr_test.py Mon Oct 4 18:06:25 2010
@@ -255,6 +255,7 @@
self.fake_session.get_message(self.name, None))
self.assertEqual(len(self.fake_session.message_queue), 0)
+ self.fake_session.group_sendmsg(None, 'ConfigManager')
self._handle_msg_helper({ "command": [ "set_config", [ ] ] },
{'result': [1, 'Wrong number of arguments']} )
self._handle_msg_helper({ "command": [ "set_config", [ self.name, { "test": 125 }] ] },
Modified: branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py
==============================================================================
--- branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py (original)
+++ branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py Mon Oct 4 18:06:25 2010
@@ -16,6 +16,13 @@
# $Id$
import isc
+
+class WouldBlockForever(Exception):
+ """
+ This is thrown by the FakeModuleCCSession if it would need
+ to block forever for incoming message.
+ """
+ pass
#
# We can probably use a more general version of this
@@ -64,13 +71,18 @@
if 'group' in env:
self.message_queue.append([ env['group'], None, msg])
- def group_recvmsg(self, blocking, seq = None):
+ def group_recvmsg(self, nonblock=True, seq = None):
for qm in self.message_queue:
- if qm[0] in self.subscriptions and (qm[1] == None or qm[1] in self.subscriptions[qm[0]]):
+ if qm[0] in self.subscriptions and (qm[1] == None or qm[1] in
+ self.subscriptions[qm[0]]):
self.message_queue.remove(qm)
return qm[2], {'group': qm[0], 'from': qm[1]}
if self._timeout == 0:
- return None, None
+ if nonblock:
+ return None, None
+ else:
+ raise WouldBlockForever(
+ "Blocking read without timeout and no message ready")
else:
raise isc.cc.SessionTimeout("Timeout set but no data to "
"return to group_recvmsg()")
More information about the bind10-changes
mailing list