log.debug("wait_until_equal: success")
@classmethod
- def wait_until_true(cls, condition, timeout, period=5):
+ def wait_until_true(cls, condition, timeout, check_fn=None, period=5):
elapsed = 0
+ retry_count = 0
while True:
if condition():
- log.debug("wait_until_true: success in {0}s".format(elapsed))
+ log.debug("wait_until_true: success in {0}s and {1} retries".format(elapsed, retry_count))
return
else:
if elapsed >= timeout:
- raise TestTimeoutError("Timed out after {0}s".format(elapsed))
+ if check_fn and check_fn() and retry_count < 5:
+ elapsed = 0
+ retry_count += 1
+ log.debug("wait_until_true: making progress, waiting (timeout={0} retry_count={1})...".format(timeout, retry_count))
+ else:
+ raise TestTimeoutError("Timed out after {0}s and {1} retries".format(elapsed, retry_count))
else:
- log.debug("wait_until_true: waiting (timeout={0})...".format(timeout))
+ log.debug("wait_until_true: waiting (timeout={0} retry_count={1})...".format(timeout, retry_count))
time.sleep(period)
elapsed += period
assert ev_id in live_ids
return False
+ def _is_inprogress_or_complete(self, ev_id):
+ for ev in self._events_in_progress():
+ if ev['id'] == ev_id:
+ return ev['progress'] > 0
+ # check if the event completed
+ return self._is_complete(ev_id)
+
def tearDown(self):
if self.POOL in self.mgr_cluster.mon_manager.pools:
self.mgr_cluster.mon_manager.remove_pool(self.POOL)
log.info(json.dumps(ev1, indent=1))
self.wait_until_true(lambda: self._is_complete(ev1['id']),
+ check_fn=lambda: self._is_inprogress_or_complete(ev1['id']),
timeout=self.RECOVERY_PERIOD)
self.assertTrue(self._is_quiet())