[Zope-Checkins] CVS: ZODB3/ZEO/tests - ConnectionTests.py:1.40.4.4

Jeremy Hylton jeremy at zope.com
Fri Jan 9 15:54:55 EST 2004


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

Modified Files:
      Tag: Zope-2_7-branch
	ConnectionTests.py 
Log Message:
Backport ZEO getInvalidations() fix from the trunk.


=== ZODB3/ZEO/tests/ConnectionTests.py 1.40.4.3 => 1.40.4.4 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.40.4.3	Thu Oct 16 11:08:47 2003
+++ ZODB3/ZEO/tests/ConnectionTests.py	Fri Jan  9 15:54:49 2004
@@ -23,6 +23,7 @@
 
 import zLOG
 
+import ZEO.ServerStub
 from ZEO.ClientStorage import ClientStorage
 from ZEO.Exceptions import ClientDisconnected
 from ZEO.zrpc.marshal import Marshaller
@@ -34,13 +35,24 @@
 from ZODB.POSException import ReadOnlyError, ConflictError
 from ZODB.tests.StorageTestBase import StorageTestBase
 from ZODB.tests.MinPO import MinPO
-from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
-from ZODB.tests.StorageTestBase import handle_all_serials, ZERO
-from ZODB.tests.StorageTestBase import handle_serials
+from ZODB.tests.StorageTestBase \
+     import zodb_pickle, zodb_unpickle, handle_all_serials, handle_serials
+
+ZERO = '\0'*8
+
+class TestServerStub(ZEO.ServerStub.StorageServer):
+    __super_getInvalidations = ZEO.ServerStub.StorageServer.getInvalidations
+
+    def getInvalidations(self, tid):
+        # squirrel the results away for inspection by test case
+        self._last_invals = self.__super_getInvalidations(tid)
+        return self._last_invals
 
 class TestClientStorage(ClientStorage):
 
-    test_connection = 0
+    test_connection = False
+
+    StorageServerStubClass = TestServerStub
 
     def verify_cache(self, stub):
         self.end_verify = threading.Event()
@@ -54,7 +66,7 @@
         try:
             return ClientStorage.testConnection(self, conn)
         finally:
-            self.test_connection = 1
+            self.test_connection = True
 
 class DummyDB:
     def invalidate(self, *args, **kwargs):
@@ -568,7 +580,7 @@
         db1.close()
 
 class InvqTests(CommonSetupTearDown):
-    invq = 2
+    invq = 3
 
     def checkQuickVerificationWith2Clients(self):
         perstorage = self.openClientStorage(cache="test")
@@ -576,6 +588,7 @@
 
         self._storage = self.openClientStorage()
         oid = self._storage.new_oid()
+        oid2 = self._storage.new_oid()
         # When we create a new storage, it should always do a full
         # verification
         self.assertEqual(self._storage.verify_result, "full verification")
@@ -583,15 +596,20 @@
         # message is generated
         revid = self._dostore(oid)
         revid = self._dostore(oid, revid)
+        # Create a second object and revision to guarantee it doesn't
+        # show up in the list of invalidations sent when perstore restarts.
+        revid2 = self._dostore(oid2)
+        revid2 = self._dostore(oid2, revid2)
 
         perstorage.load(oid, '')
         perstorage.close()
 
         revid = self._dostore(oid, revid)
-
         perstorage = self.openClientStorage(cache="test")
         self.assertEqual(perstorage.verify_result, "quick verification")
-
+        self.assertEqual(perstorage._server._last_invals,
+                         (revid, [(oid, '')]))
+                         
         self.assertEqual(perstorage.load(oid, ''),
                          self._storage.load(oid, ''))
         perstorage.close()
@@ -857,7 +875,6 @@
         # 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)
@@ -887,7 +904,6 @@
         # Create the object
         oid = storage.new_oid()
         obj = MinPO(7)
-        ZERO = '\0'*8
         # We need to successfully commit an object now so we have something to
         # conflict about.
         t = Transaction()




More information about the Zope-Checkins mailing list