[Checkins] SVN: zc.zkzeo/trunk/src/zc/zkzeo/ Got tests passing. :(
jim
cvs-admin at zope.org
Fri Jun 22 18:16:25 UTC 2012
Log message for revision 127037:
Got tests passing. :(
They were passing the last time I worked on this.
At least one failure was due to a change in the zc.zk initial
connetion timeout. The rest seemed to be timeing relatedq. I don't
know why these didn't rear their heads before. :/
Changed:
U zc.zkzeo/trunk/src/zc/zkzeo/README.txt
U zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py
U zc.zkzeo/trunk/src/zc/zkzeo/tests.py
U zc.zkzeo/trunk/src/zc/zkzeo/wait-for-zookeeper.test
-=-
Modified: zc.zkzeo/trunk/src/zc/zkzeo/README.txt
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/README.txt 2012-06-22 17:09:08 UTC (rev 127036)
+++ zc.zkzeo/trunk/src/zc/zkzeo/README.txt 2012-06-22 18:16:20 UTC (rev 127037)
@@ -68,8 +68,6 @@
>>> zk.print_tree('/databases/demo')
/demo
- >>> zk.close()
-
where ``FILENAME`` is the name of the configuration file you created.
Including a ``zc.monitor`` monitoring server
@@ -108,8 +106,6 @@
the ZooKeeper tree for '/databases/demo' using the ``zc.zk`` package, we'd
see something like the following::
- >>> import zc.zk
- >>> zk = zc.zk.ZooKeeper('zookeeper.example.com:2181')
>>> zk.print_tree('/databases/demo')
/demo
/127.0.0.1:64211
@@ -231,10 +227,11 @@
>>> stop().exception
- >>> wait_until(lambda : not client.is_connected())
- >>> wait_until(lambda : not db_from_config.storage.is_connected())
- >>> wait_until(lambda : not db.storage.is_connected())
- >>> wait_until(lambda : not exconn.db().storage.is_connected())
+ >>> from zope.testing.wait import wait
+ >>> wait(lambda : not client.is_connected())
+ >>> wait(lambda : not db_from_config.storage.is_connected())
+ >>> wait(lambda : not db.storage.is_connected())
+ >>> wait(lambda : not exconn.db().storage.is_connected())
>>> print handler
zc.zkzeo WARNING
@@ -272,20 +269,20 @@
monitor = u'127.0.0.1:23265'
pid = 88841
- >>> wait_until(db_from_config.storage.is_connected)
+ >>> wait(db_from_config.storage.is_connected)
>>> with db_from_config.transaction() as conn:
... conn.root.x = 2
- >>> wait_until(client.is_connected)
+ >>> wait(db_from_py.storage.is_connected, timeout=22)
>>> with db_from_py.transaction() as conn:
... print conn.root()
{'x': 2}
- >>> wait_until(db.storage.is_connected)
+ >>> wait(db.storage.is_connected, timeout=22)
>>> with db.transaction() as conn:
... print conn.root()
{'x': 2}
- >>> wait_until(exconn.db().storage.is_connected)
+ >>> wait(exconn.db().storage.is_connected, timeout=22)
>>> with transaction.manager:
... print exconn.root()
{'x': 2}
Modified: zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py 2012-06-22 17:09:08 UTC (rev 127036)
+++ zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py 2012-06-22 18:16:20 UTC (rev 127037)
@@ -109,7 +109,6 @@
s.main()
def close311(self): # based on server close method in 3.11
-
# Stop accepting connections
self.dispatcher.close()
if self.monitor is not None:
@@ -153,14 +152,37 @@
os.close(fd)
event = threading.Event()
server = main(['-C', confpath], event.set)
+
os.remove(confpath)
+ run_zeo_server_for_testing = None
+
+ def stop():
+ close = getattr(server.server, 'close', None)
+ if close is None:
+ close311(server.server)
+ else:
+ close()
+ assert not server.server.dispatcher._map, server.server.dispatcher._map
+
+ if run_zeo_server_for_testing is not None:
+ run_zeo_server_for_testing.join(11)
+ assert not run_zeo_server_for_testing.is_alive()
+ return run_zeo_server_for_testing
+
if not threaded:
- return server.main()
+ try:
+ return server.main()
+ except:
+ stop()
+ raise
@zc.thread.Thread
def run_zeo_server_for_testing():
+ import asyncore
try:
+ # Make the loop die quickly when we close the storage
+ server.loop_forever = lambda : asyncore.loop(.5)
server.main()
except select.error:
pass
@@ -169,15 +191,6 @@
logging.getLogger(__name__+'.test').exception(
'wtf %r', sys.exc_info()[1])
- def stop():
- close = getattr(server.server, 'close', None)
- if close is None:
- close311(server.server)
- else:
- close()
- run_zeo_server_for_testing.join(1)
- return run_zeo_server_for_testing
-
stop.server = server # :)
event.wait(1)
Modified: zc.zkzeo/trunk/src/zc/zkzeo/tests.py
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/tests.py 2012-06-22 17:09:08 UTC (rev 127036)
+++ zc.zkzeo/trunk/src/zc/zkzeo/tests.py 2012-06-22 18:16:20 UTC (rev 127037)
@@ -12,6 +12,7 @@
#
##############################################################################
from zope.testing import setupstack
+from zope.testing.wait import wait
import doctest
import unittest
import manuel.capture
@@ -215,8 +216,8 @@
And the clients will connect:
- >>> wait_until(c1.is_connected)
- >>> wait_until(c2.is_connected)
+ >>> wait(c1.is_connected)
+ >>> wait(c2.is_connected)
>>> print handler # doctest: +NORMALIZE_WHITESPACE
zc.zkzeo WARNING
Modified: zc.zkzeo/trunk/src/zc/zkzeo/wait-for-zookeeper.test
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/wait-for-zookeeper.test 2012-06-22 17:09:08 UTC (rev 127036)
+++ zc.zkzeo/trunk/src/zc/zkzeo/wait-for-zookeeper.test 2012-06-22 18:16:20 UTC (rev 127037)
@@ -32,7 +32,7 @@
Let's wait a while:
>>> import time
- >>> time.sleep(4)
+ >>> time.sleep(12)
We're asking for help:
More information about the checkins
mailing list