selftest: Make setexpiry test much more reliable
authorAndrew Bartlett <abartlet@samba.org>
Tue, 15 May 2018 00:26:03 +0000 (12:26 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 15 May 2018 21:58:17 +0000 (23:58 +0200)
Rather than setting all the expiries and expecting that they will be done within 5 seconds,
measure and check the time individually for each record.

This should make this test much less prone to flapping.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue May 15 23:58:17 CEST 2018 on sn-devel-144

python/samba/tests/samba_tool/user.py

index aaeafee71cd7ce8fd535c4bca9a0166a29465dbf..f99288a7cb88bf80421b8a8f996585a2355442df 100644 (file)
@@ -306,9 +306,9 @@ class UserCmdTestCase(SambaToolCmdTest):
 
 
     def test_setexpiry(self):
-        twodays = time.time() + (2 * 24 * 60 * 60)
-
         for user in self.users:
+            twodays = time.time() + (2 * 24 * 60 * 60)
+
             (result, out, err) = self.runsubcmd("user", "setexpiry", user["name"],
                                                 "--days=2",
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
@@ -316,7 +316,6 @@ class UserCmdTestCase(SambaToolCmdTest):
             self.assertCmdSuccess(result, out, err, "Can we run setexpiry with names")
             self.assertIn("Expiry for user '%s' set to 2 days." % user["name"], out)
 
-        for user in self.users:
             found = self._find_user(user["name"])
 
             expires = nttime2unix(int("%s" % found.get("accountExpires")))