mirror of
https://github.com/samba-team/samba.git
synced 2025-12-23 00:23:53 +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:
committed by
Andrew Bartlett
parent
e2e8c86988
commit
e1884e8038
@@ -175,14 +175,21 @@ 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
|
||||
|
||||
# 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. We’ve 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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user