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