[Zodb-checkins] CVS: StandaloneZODB/ZODB/tests - PackableStorage.py:1.11

Jeremy Hylton jeremy@zope.com
Mon, 29 Oct 2001 15:41:24 -0500


Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv10819

Modified Files:
	PackableStorage.py 
Log Message:
Add a sleep(1) before each pack() call.

pack() uses a coarse-grain timer to decide which revisions to look at
during a pack.  The tests depend on a pack() called after a commit to
see that committed transaction, but the implementation can't guarantee
that it will.

In particular, pack() converts its time argument to a TimeStamp by
truncating to the nearest second.  If a transaction T1 commits and pack
is called (with the current time as its argument) during the same second,
the pack() will not consider T1.  This was causing intermittent, but
frequent test failures on Windows.

The fix is to add a small delay in the pack test cases to guarantee that
pack(time.time()) will always see the last committed transaction. 


=== StandaloneZODB/ZODB/tests/PackableStorage.py 1.10 => 1.11 ===
             self._storage.tpc_vote(t)
             self._storage.tpc_finish(t)
+
+    def checkPackEmptyStorage(self):
+        self._storage.pack(time.time(), referencesf)
+
+    def checkPackTomorrow(self):
+        self._initroot()
+        self._storage.pack(time.time() + 10000, referencesf)
             
     def checkPackAllRevisions(self):
         self._initroot()
@@ -146,7 +153,9 @@
         pobj = pickle.loads(data)
         eq(pobj.getoid(), oid)
         eq(pobj.value, 3)
-        # Now pack all transactions
+        # Now pack all transactions; need to sleep a second to make
+        # sure that the pack time is greater than the last commit time.
+        time.sleep(1)
         self._storage.pack(time.time(), referencesf)
         # All revisions of the object should be gone, since there is no
         # reference from the root object to this object.
@@ -197,6 +206,7 @@
         eq(pobj.value, 3)
         # Now pack just revisions 1 and 2.  The object's current revision
         # should stay alive because it's pointed to by the root.
+        time.sleep(1)
         self._storage.pack(time.time(), referencesf)
         # Make sure the revisions are gone, but that object zero and revision
         # 3 are still there and correct
@@ -273,6 +283,7 @@
         # Now pack just revisions 1 and 2 of object1.  Object1's current
         # revision should stay alive because it's pointed to by the root, as
         # should Object2's current revision.
+        time.sleep(1)
         self._storage.pack(time.time(), referencesf)
         # Make sure the revisions are gone, but that object zero, object2, and
         # revision 3 of object1 are still there and correct.