[Zodb-checkins] CVS: StandaloneZODB/ZEO/tests - CommitLockTests.py:1.7

Jeremy Hylton jeremy@zope.com
Mon, 12 Aug 2002 14:24:14 -0400


Update of /cvs-repository/StandaloneZODB/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv4368/tests

Modified Files:
	CommitLockTests.py 
Log Message:
Use an Event to wait for each WorkerThread to begin the commit process.


=== StandaloneZODB/ZEO/tests/CommitLockTests.py 1.6 => 1.7 ===
--- StandaloneZODB/ZEO/tests/CommitLockTests.py:1.6	Mon Aug 12 14:05:23 2002
+++ StandaloneZODB/ZEO/tests/CommitLockTests.py	Mon Aug 12 14:24:13 2002
@@ -13,6 +13,7 @@
 ##############################################################################
 """Tests of the distributed commit lock."""
 
+import threading
 import time
 
 from ZODB.Transaction import Transaction
@@ -38,6 +39,7 @@
         self.storage = storage
         self.trans = trans
         self.method = method
+        self.ready = threading.Event()
         TestThread.__init__(self, testcase)
 
     def testrun(self):
@@ -49,6 +51,7 @@
             oid = self.storage.new_oid()
             p = zodb_pickle(MinPO("c"))
             self.storage.store(oid, ZERO, p, '', self.trans)
+            self.ready.set()
             self.storage.tpc_vote(self.trans)
             if self.method == "tpc_finish":
                 self.storage.tpc_finish(self.trans)
@@ -106,6 +109,21 @@
         # check the commit lock when a client attemps a transaction,
         # but fails/exits before finishing the commit.
 
+        # The general flow of these tests is to start a transaction by
+        # calling tpc_begin().  Then begin one or more other
+        # connections that also want to commit.  This causes the
+        # commit lock code to be exercised.  Once the other
+        # connections are started, the first transaction completes.
+        # Either by commit or abort, depending on whether method_name
+        # is "tpc_finish."
+
+        # The tests are parameterized by method_name, dosetup(), and
+        # dowork().  The dosetup() function is called with a
+        # connectioned client storage, transaction, and timestamp.
+        # Any work it does occurs after the first transaction has
+        # started, but before it finishes.  The dowork() function
+        # executes after the first transaction has completed.
+
         # Start on transaction normally.
         t = Transaction()
         self._storage.tpc_begin(t)
@@ -155,6 +173,7 @@
         t = WorkerThread(self, storage, trans)
         self._threads.append(t)
         t.start()
+        t.ready.wait()
 
     def _dowork2(self, method_name):
         for t in self._threads: