1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-21 20:23:50 +03:00

tests/audit_log: Make discardMessages() more reliable

It can take two or three calls to msg_ctx.loop_once() before a message
comes in. Make sure we get all of the messages.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton
2023-05-25 12:13:28 +12:00
committed by Andrew Bartlett
parent e2e8c86988
commit e1884e8038

View File

@@ -175,13 +175,20 @@ class AuditLogTestBase(samba.tests.TestCase):
# Discard any previously queued messages.
def discardMessages(self):
self.msg_ctx.loop_once(0.001)
while (self.context["messages"] or
self.context["txnMessage"] is not None):
messages = self.context["messages"]
self.context["messages"] = []
while True:
messages.clear()
self.context["txnMessage"] = None
self.msg_ctx.loop_once(0.001)
# tevent presumably has other tasks to run, so we might need two or
# three loops before a message comes through.
for _ in range(5):
self.msg_ctx.loop_once(0.001)
if not messages and self.context["txnMessage"] is None:
# No new messages. Weve probably got them all.
break
GUID_RE = re.compile(
"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")