s4:dsdb/test/notification: make test_invalid_filter more resilient against ordering...
authorStefan Metzmacher <metze@samba.org>
Fri, 11 Mar 2016 09:16:27 +0000 (10:16 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 11 Mar 2016 21:58:18 +0000 (22:58 +0100)
We saw a lot of flapping tests with:

    [1793(11038)/1892 at 1h55m26s]
    samba4.ldap.notification.python(ad_dc_ntvfs)(ad_dc_ntvfs)
    UNEXPECTED(failure):
    samba4.ldap.notification.python(ad_dc_ntvfs).__main__.LDAPNotificationTest.test_max_search(ad_dc_ntvfs)
    REASON: Exception: Exception: Traceback (most recent call last):
      File
    "/memdisk/autobuild/fl/b1782183/samba/source4/dsdb/tests/python/notification.py",
    line 181, in test_max_search
        self.assertEquals(num, ERR_TIME_LIMIT_EXCEEDED)
    AssertionError: 11 != 3

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/tests/python/notification.py

index d799c91def56adfd8e9ac98bff1c8365c1d38c3a..afc6343c30934ae6f869c9537e632f91f5474d1a 100755 (executable)
@@ -168,6 +168,8 @@ delete: otherLoginWorkstations
                                                    attrs=["name"],
                                                    controls=["notification:1"],
                                                    timeout=1)
+        num_admin_limit = 0
+        num_time_limit = 0
         for i in xrange(0, max_notifications + 1):
             try:
                 for msg in notifies[i]:
@@ -175,10 +177,15 @@ delete: otherLoginWorkstations
                 res = notifies[i].result()
                 self.fail()
             except LdbError, (num, _):
-                if i >= max_notifications:
-                    self.assertEquals(num, ERR_ADMIN_LIMIT_EXCEEDED)
-                else:
-                    self.assertEquals(num, ERR_TIME_LIMIT_EXCEEDED)
+                if num == ERR_ADMIN_LIMIT_EXCEEDED:
+                    num_admin_limit += 1
+                    continue
+                if num == ERR_TIME_LIMIT_EXCEEDED:
+                    num_time_limit += 1
+                    continue
+                raise
+        self.assertEqual(num_admin_limit, 1)
+        self.assertEqual(num_time_limit, max_notifications)
 
     def test_invalid_filter(self):
         """Testing invalid filters for notifications"""