Commit a1b3c3b5 authored by Jim Fulton's avatar Jim Fulton

Refactored a test helper to make it a little more self documenting.

parent 179d76ea
......@@ -640,6 +640,7 @@ class InvqTests(CommonSetupTearDown):
revid = self._dostore(oid)
revid = self._dostore(oid, revid)
forker.wait_until(
"Client has seen all of the transactions from the server",
lambda :
perstorage.lastTransaction() == self._storage.lastTransaction()
)
......@@ -864,6 +865,7 @@ class ReconnectionTests(CommonSetupTearDown):
revid = self._dostore(oid)
revid = self._dostore(oid, revid)
forker.wait_until(
"Client has seen all of the transactions from the server",
lambda :
perstorage.lastTransaction() == self._storage.lastTransaction()
)
......
......@@ -330,20 +330,18 @@ def setUp(test):
test.globs['wait_disconnected'] = wait_disconnected
def wait_until(func, timeout=30, label=None):
if not label:
label = func.__name__
def wait_until(label, func, timeout=30):
now = time.time()
giveup = now + 30
while not func():
now = time.time()
if time.time() > giveup:
raise AssertionError("Timed out waiting for", label)
raise AssertionError("Timed out waiting for: ", label)
time.sleep(0.01)
def wait_connected(storage):
wait_until(storage.is_connected)
wait_until("storage is connected", storage.is_connected)
def wait_disconnected(storage):
def not_connected():
return not storage.is_connected()
wait_until("storage is disconnected",
lambda : not storage.is_connected())
......@@ -1139,7 +1139,9 @@ def delete_object_multiple_clients():
try to access the object. We'll get a POSKeyError there too:
>>> tid = db.storage.lastTransaction()
>>> forker.wait_until(lambda : cs.lastTransaction() == tid)
>>> forker.wait_until(
... 'cs has caught up',
... lambda : cs.lastTransaction() == tid)
>>> cs.load(oid) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
......
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