tests/auth_log: Make discardMessages() more reliable
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 25 May 2023 00:15:07 +0000 (12:15 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 29 May 2023 22:32:28 +0000 (22:32 +0000)
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>
python/samba/tests/auth_log_base.py
selftest/knownfail.d/auth-log-pass-change [deleted file]

index af16b3dbea2a52d4c95bfc5b3beb95c0974360c9..b7a29e0c24217b721ae0ac48163988c599792853 100644 (file)
@@ -129,10 +129,19 @@ class AuthLogTestBase(samba.tests.TestCase):
     # Discard any previously queued messages.
     @classmethod
     def discardMessages(cls):
-        cls.msg_ctx.loop_once(0.001)
-        while cls.context["messages"]:
-            cls.context["messages"] = []
-            cls.msg_ctx.loop_once(0.001)
+        messages = cls.context["messages"]
+
+        while True:
+            messages.clear()
+
+            # tevent presumably has other tasks to run, so we might need two or
+            # three loops before a message comes through.
+            for _ in range(5):
+                cls.msg_ctx.loop_once(0.001)
+
+            if not messages:
+                # No new messages. We’ve probably got them all.
+                break
 
     # Remove any NETLOGON authentication messages
     # NETLOGON is only performed once per session, so to avoid ordering
diff --git a/selftest/knownfail.d/auth-log-pass-change b/selftest/knownfail.d/auth-log-pass-change
deleted file mode 100644 (file)
index 4f19319..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-^samba.tests.auth_log_pass_change.samba.tests.auth_log_pass_change.AuthLogPassChangeTests.test_ldap_change_password_bad_user.ad_dc_ntvfs
-^samba.tests.auth_log_pass_change.samba.tests.auth_log_pass_change.AuthLogPassChangeTests.test_ldap_change_password_bad_user.ad_dc_smb1