[Zodb-checkins] SVN: ZODB/branches/jim-3.8-connection/src/ZEO/tests/ checkpointing

Jim Fulton jim at zope.com
Thu Jul 10 07:11:03 EDT 2008


Log message for revision 88168:
  checkpointing
  

Changed:
  A   ZODB/branches/jim-3.8-connection/src/ZEO/tests/invalidations_while_connecting.test
  U   ZODB/branches/jim-3.8-connection/src/ZEO/tests/testConnection.py

-=-
Added: ZODB/branches/jim-3.8-connection/src/ZEO/tests/invalidations_while_connecting.test
===================================================================
--- ZODB/branches/jim-3.8-connection/src/ZEO/tests/invalidations_while_connecting.test	                        (rev 0)
+++ ZODB/branches/jim-3.8-connection/src/ZEO/tests/invalidations_while_connecting.test	2008-07-10 11:11:03 UTC (rev 88168)
@@ -0,0 +1,94 @@
+Invalidations while connecting
+==============================
+
+As soon as a client registers with a server, it will recieve
+invalidations from the server.  The client must be careful to queue
+these invalidations until it is ready to deal with them.  At the time
+of the writing of this test, clients weren't careful enogh about
+queing invalidations.  This led to cache corruption in the form of
+both low-level file corruption as well as out-of-date records marked
+as current.
+
+This tests tries to provoke this bug by:
+
+- starting a server
+
+    >>> import ZEO.tests.testZEO, ZEO.tests.forker
+    >>> addr = 'localhost', ZEO.tests.testZEO.get_port()
+    >>> zconf = ZEO.tests.forker.ZEOConfig(addr)
+    >>> sconf = '<filestorage 1>\npath Data.fs\n</filestorage>\n'
+    >>> _, adminaddr, pid, conf_path = ZEO.tests.forker.start_zeo_server(
+    ...     sconf, zconf, addr[1])
+
+- opening a client to the server that writes some objects, filling
+  it's cache at the same time,
+
+    >>> import ZEO.ClientStorage, ZODB.tests.MinPO, transaction
+    >>> db = ZODB.DB(ZEO.ClientStorage.ClientStorage(addr, client='x'))
+    >>> conn = db.open()
+    >>> for i in range(1000):
+    ...     conn.root()[i] = ZODB.tests.MinPO.MinPO(0)
+    >>> transaction.commit()
+
+- disconnecting the first client (closing it with a persistent cache),
+
+    >>> db.close()
+
+- starting a second client that writes objects more or less
+  constantly,
+
+    >>> import threading
+    >>> stop = False
+    >>> db2 = ZODB.DB(ZEO.ClientStorage.ClientStorage(addr))
+    >>> tm = transaction.TransactionManager()
+    >>> conn2 = db2.open(transaction_manager=tm)
+    >>> def run():
+    ...     while 1:
+    ...         for i in range(500):
+    ...             if stop:
+    ...                 return
+    ...             conn2.root()[i].value += 1
+    ...             tm.commit()
+    >>> thread = threading.Thread(target=run)
+    >>> thread.start()
+
+- restarting the first client, and 
+
+    >>> import zope.testing.loggingsupport, logging
+    >>> handler = zope.testing.loggingsupport.InstalledHandler(
+    ...    'ZEO', level=logging.ERROR)
+
+    >>> import time
+    >>> for i in range(10):
+    ...    time.sleep(.1)
+    ...    db = ZODB.DB(ZEO.ClientStorage.ClientStorage(addr, client='x'))
+    ...    time.sleep(.1)
+    ...    db.close()
+
+    >>> time.sleep(.1)
+    >>> db = ZODB.DB(ZEO.ClientStorage.ClientStorage(addr, client='x'))
+
+
+    >>> stop = True
+    >>> thread.join(10)
+    >>> thread.isAlive()
+    False
+
+    >>> time.sleep(.1)
+
+- testing for cache validity.
+
+    >>> conn = db.open()
+    >>> for i in range(1000):
+    ...     if conn.root()[i].value != conn2.root()[i].value:
+    ...         print i, conn.root()[i].value, conn2.root()[i].value
+
+
+    >>> for record in handler.records:
+    ...     print record.name, record.levelname
+    ...     print handler.format(record)
+
+    >>> handler.uninstall()
+
+    >>> db.close()
+    >>> db2.close()


Property changes on: ZODB/branches/jim-3.8-connection/src/ZEO/tests/invalidations_while_connecting.test
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: ZODB/branches/jim-3.8-connection/src/ZEO/tests/testConnection.py
===================================================================
--- ZODB/branches/jim-3.8-connection/src/ZEO/tests/testConnection.py	2008-07-10 11:08:24 UTC (rev 88167)
+++ ZODB/branches/jim-3.8-connection/src/ZEO/tests/testConnection.py	2008-07-10 11:11:03 UTC (rev 88168)
@@ -21,8 +21,8 @@
 import unittest
 # Import the actual test class
 from ZEO.tests import ConnectionTests, InvalidationTests
+from zope.testing import doctest, setupstack
 
-
 class FileStorageConfig:
     def getConfig(self, path, create, read_only):
         return """\
@@ -135,6 +135,10 @@
     for klass in test_classes:
         sub = unittest.makeSuite(klass, 'check')
         suite.addTest(sub)
+    suite.addTest(doctest.DocFileSuite(
+        'invalidations_while_connecting.test',
+        setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown,
+        ))
     return suite
 
 



More information about the Zodb-checkins mailing list