MCPcopy Create free account
hub / github.com/apache/impala / assert_eventually

Method assert_eventually

tests/common/impala_test_suite.py:1680–1696  ·  view source on GitHub ↗

Assert that the condition (a function with no parameters) returns True within the given timeout. The condition is executed every period_s seconds. The check assumes that once the condition returns True, it continues to return True. Throws a Timeout if the condition does not return true w

(self, timeout_s, period_s, condition, error_msg=None)

Source from the content-addressed store, hash-verified

1678 assert result.success
1679
1680 def assert_eventually(self, timeout_s, period_s, condition, error_msg=None):
1681 """Assert that the condition (a function with no parameters) returns True within the
1682 given timeout. The condition is executed every period_s seconds. The check assumes
1683 that once the condition returns True, it continues to return True. Throws a Timeout
1684 if the condition does not return true within timeout_s seconds. 'error_msg' is an
1685 optional function that must return a string. If set, the result of the function will
1686 be included in the Timeout error message."""
1687 count = 0
1688 start_time = time.time()
1689 while not condition() and time.time() - start_time < timeout_s:
1690 time.sleep(period_s)
1691 count += 1
1692 if not condition():
1693 error_msg_str = " error message: " + error_msg() if error_msg else ""
1694 raise Timeout(
1695 "Check failed to return True after {0} tries and {1} seconds{2}".format(
1696 count, timeout_s, error_msg_str))
1697
1698 def assert_impalad_log_contains(self, level, line_regex, expected_count=1, timeout_s=6,
1699 dry_run=False, sleep_s=1):

Calls 2

TimeoutClass · 0.90
formatMethod · 0.45

Tested by

no test coverage detected