[Zodb-checkins] CVS: ZODB3/ZEO/tests - ConnectionTests.py:1.4.2.5.4.1

Barry Warsaw barry at zope.com
Fri Aug 1 17:10:30 EDT 2003


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv3990

Modified Files:
      Tag: ZODB3-3_1-boston-branch
	ConnectionTests.py 
Log Message:
checkTimeoutAfterVote(): A new test which tickles a bug discovered via
code inspection (and other means <wink>) in ClientStorage's
tpc_finish().  If a storage times out between the vote and the finish,
the zeo cache would have gotten populated with objects that didn't
make it to the storage server.

A fix for this is coming up next.


=== ZODB3/ZEO/tests/ConnectionTests.py 1.4.2.5 => 1.4.2.5.4.1 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.4.2.5	Wed Jun 11 19:11:32 2003
+++ ZODB3/ZEO/tests/ConnectionTests.py	Fri Aug  1 16:10:23 2003
@@ -26,6 +26,7 @@
 from ZEO.ClientStorage import ClientStorage, ClientDisconnected
 from ZEO.Exceptions import Disconnected
 from ZEO.zrpc.marshal import Marshaller
+from ZEO.zrpc.error import DisconnectedError
 from ZEO.tests.InvalidationTests import InvalidationTests
 
 from ZODB.Transaction import get_transaction, Transaction
@@ -35,7 +36,7 @@
 from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
 
 class DummyDB:
-    def invalidate(self, *args):
+    def invalidate(self, *args, **kws):
         pass
 
 class ConnectionTests(StorageTestBase.StorageTestBase,
@@ -577,3 +578,33 @@
         storage.tpc_begin(txn)
         storage.tpc_abort(txn)
 
+    def checkTimeoutAfterVote(self):
+        raises = self.assertRaises
+        unless = self.failUnless
+        self.shutdownServer()
+        self.startServer(transaction_timeout=1)
+        self._storage = storage = self.openClientStorage()
+        # Assert that the zeo cache is empty
+        unless(not storage._cache._index)
+        # Create the object
+        oid = storage.new_oid()
+        obj = MinPO(7)
+        ZERO = '\0'*8
+        # Now do a store, sleeping before the finish so as to cause a timeout
+        t = Transaction()
+        storage.tpc_begin(t)
+        revid1 = storage.store(oid, ZERO, zodb_pickle(obj), '', t)
+        storage.tpc_vote(t)
+        # Now sleep long enough for the storage to time out
+        time.sleep(3)
+        storage.sync()
+        self.assert_(not storage.is_connected())
+        storage._wait()
+        self.assert_(storage.is_connected())
+        # This will just return
+        raises(ClientDisconnected, storage.tpc_finish, t)
+        # The cache should still be empty
+        unless(not storage._cache._index)
+        # Load should fail since the object should not be in either the cache
+        # or the server.
+        raises(KeyError, storage.load, oid, '')




More information about the Zodb-checkins mailing list