QA: Add forbid_msgs param to TestNode.wait_for_debug_log

This commit is contained in:
Luke Dashjr 2024-03-25 22:29:00 +00:00
parent 1248d0da22
commit 8e46b4a040

View File

@ -519,7 +519,7 @@ class TestNode():
self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
@contextlib.contextmanager
def busy_wait_for_debug_log(self, expected_msgs, timeout=60):
def busy_wait_for_debug_log(self, expected_msgs, timeout=60, *, forbid_msgs=()):
"""
Block until we see a particular debug log message fragment or until we exceed the timeout.
Return:
@ -536,6 +536,13 @@ class TestNode():
dl.seek(prev_size)
log = dl.read()
for msg in forbid_msgs:
if msg in log:
print_log = " - " + "\n - ".join(log.decode("utf8", errors="replace").splitlines())
self._raise_assertion_error(
'Forbidden message "{}" partially matched log:\n\n{}\n\n'.format(
str(msg), print_log))
for expected_msg in expected_msgs:
if expected_msg not in log:
found = False