Commit 5dabe9c3 authored by Jeremy Hylton's avatar Jeremy Hylton

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.
parent c1b9dd50
......@@ -118,6 +118,13 @@ class PackableStorage(PackableStorageBase):
self._storage.store(ZERO, None, file.getvalue(), '', t)
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 @@ class PackableStorage(PackableStorageBase):
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 @@ class PackableStorage(PackableStorageBase):
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 @@ class PackableStorage(PackableStorageBase):
# 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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment