[Zodb-checkins] CVS: ZODB3/ZEO/tests - ConnectionTests.py:1.13 forker.py:1.31 testConnection.py:1.9 zeoserver.py:1.7

Jeremy Hylton jeremy@zope.com
Tue, 7 Jan 2003 17:13:03 -0500


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

Modified Files:
	ConnectionTests.py forker.py testConnection.py zeoserver.py 
Log Message:
Add per-storage transaction timeout feature and a couple of tests.


=== ZODB3/ZEO/tests/ConnectionTests.py 1.12 => 1.13 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.12	Fri Jan  3 17:07:40 2003
+++ ZODB3/ZEO/tests/ConnectionTests.py	Tue Jan  7 17:12:58 2003
@@ -60,6 +60,7 @@
     __super_tearDown = StorageTestBase.tearDown
     keep = 0
     invq = None
+    timeout = None
 
     def setUp(self):
         """Test setup for connection tests.
@@ -131,7 +132,7 @@
         path = "%s.%d" % (self.file, index)
         conf = self.getConfig(path, create, read_only)
         zeoport, adminaddr, pid = forker.start_zeo_server(
-            conf, addr, ro_svr, self.keep, self.invq)
+            conf, addr, ro_svr, self.keep, self.invq, self.timeout)
         self._pids.append(pid)
         self._servers.append(adminaddr)
 
@@ -674,6 +675,29 @@
 
         perstorage.close()
 
+class TimeoutTests(CommonSetupTearDown):
+    timeout = 1
+
+    def checkTimeout(self):
+        storage = self.openClientStorage()
+        txn = Transaction()
+        storage.tpc_begin(txn)
+        storage.tpc_vote(txn)
+        time.sleep(2)
+        self.assertRaises(Disconnected, storage.tpc_finish, txn)
+
+    def checkTimeoutOnAbort(self):
+        storage = self.openClientStorage()
+        txn = Transaction()
+        storage.tpc_begin(txn)
+        storage.tpc_vote(txn)
+        storage.tpc_abort(txn)
+
+    def checkTimeoutOnAbortNoLock(self):
+        storage = self.openClientStorage()
+        txn = Transaction()
+        storage.tpc_begin(txn)
+        storage.tpc_abort(txn)
 
 class MSTThread(threading.Thread):
 


=== ZODB3/ZEO/tests/forker.py 1.30 => 1.31 ===
--- ZODB3/ZEO/tests/forker.py:1.30	Fri Jan  3 17:07:40 2003
+++ ZODB3/ZEO/tests/forker.py	Tue Jan  7 17:12:58 2003
@@ -51,7 +51,8 @@
     raise RuntimeError, "Can't find port"
 
 
-def start_zeo_server(conf, addr=None, ro_svr=0, keep=0, invq=None):
+def start_zeo_server(conf, addr=None, ro_svr=0, keep=0, invq=None,
+                     timeout=None):
     """Start a ZEO server in a separate process.
 
     Returns the ZEO port, the test server port, and the pid.
@@ -79,6 +80,8 @@
         args.append('-k')
     if invq:
         args += ['-Q', str(invq)]
+    if timeout:
+        args += ['-T', str(timeout)]
     args.append(str(port))
     d = os.environ.copy()
     d['PYTHONPATH'] = os.pathsep.join(sys.path)


=== ZODB3/ZEO/tests/testConnection.py 1.8 => 1.9 ===
--- ZODB3/ZEO/tests/testConnection.py:1.8	Fri Jan  3 17:52:09 2003
+++ ZODB3/ZEO/tests/testConnection.py	Tue Jan  7 17:12:58 2003
@@ -59,6 +59,12 @@
     ):
     """FileStorage-specific re-connection tests."""
 
+class FileStorageTimeoutTests(
+    FileStorageConfig,
+    ConnectionTests.TimeoutTests
+    ):
+    # doesn't test anything that is storage-specific
+    pass
 
 class BDBConnectionTests(
     BerkeleyStorageConfig,
@@ -74,7 +80,8 @@
     """Berkeley storage re-connection tests."""
 
 
-test_classes = [FileStorageConnectionTests, FileStorageReconnectionTests]
+test_classes = [FileStorageConnectionTests, FileStorageReconnectionTests,
+                FileStorageTimeoutTests]
 
 import BDBStorage
 if BDBStorage.is_available:


=== ZODB3/ZEO/tests/zeoserver.py 1.6 => 1.7 ===
--- ZODB3/ZEO/tests/zeoserver.py:1.6	Fri Jan  3 17:07:40 2003
+++ ZODB3/ZEO/tests/zeoserver.py	Tue Jan  7 17:12:58 2003
@@ -117,8 +117,9 @@
     keep = 0
     configfile = None
     invalidation_queue_size = 100
+    transaction_timeout = None
     # Parse the arguments and let getopt.error percolate
-    opts, args = getopt.getopt(sys.argv[1:], 'rkC:Q:')
+    opts, args = getopt.getopt(sys.argv[1:], 'rkC:Q:T:')
     for opt, arg in opts:
         if opt == '-r':
             ro_svr = 1
@@ -128,6 +129,8 @@
             configfile = arg
         elif opt == '-Q':
             invalidation_queue_size = int(arg)
+        elif opt == '-T':
+            transaction_timeout = int(arg)
     # Open the config file and let ZConfig parse the data there.  Then remove
     # the config file, otherwise we'll leave turds.
     fp = open(configfile, 'r')
@@ -150,7 +153,8 @@
     log(label, 'creating the storage server')
     serv = ZEO.StorageServer.StorageServer(
         addr, {'1': storage}, ro_svr,
-        invalidation_queue_size=invalidation_queue_size)
+        invalidation_queue_size=invalidation_queue_size,
+        transaction_timeout=transaction_timeout)
     log(label, 'entering ThreadedAsync loop')
     ThreadedAsync.LoopCallback.loop()