This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master
in repository 389-ds-base.
commit c2672e796a74b8c7130a4b8c73a86cb5849710c8
Author: William Brown <firstyear(a)redhat.com>
Date: Tue May 9 16:09:23 2017 +1000
Ticket 49244 - resolve various test case issues
Bug Description: With the changes to nsmemberof and nsworkers
various test case issues were shown. Most of these are timing
related, but some were related to the expectation of memberof
to "fail" in some cases.
Fix Description: Fix the issues in the test cases, and assert they
still pass (and validly test their tests)
https://pagure.io/389-ds-base/issue/49244
Author: wibrown
Review by: spichugi (Thanks!)
---
dirsrvtests/tests/tickets/ticket47431_test.py | 10 +--
dirsrvtests/tests/tickets/ticket47714_test.py | 17 +++-
dirsrvtests/tests/tickets/ticket47781_test.py | 4 +-
dirsrvtests/tests/tickets/ticket47815_test.py | 8 +-
dirsrvtests/tests/tickets/ticket48226_test.py | 4 +-
dirsrvtests/tests/tickets/ticket48228_test.py | 5 +-
dirsrvtests/tests/tickets/ticket48266_test.py | 111 ++++++++------------------
7 files changed, 63 insertions(+), 96 deletions(-)
diff --git a/dirsrvtests/tests/tickets/ticket47431_test.py
b/dirsrvtests/tests/tickets/ticket47431_test.py
index 3953937..1d05891 100644
--- a/dirsrvtests/tests/tickets/ticket47431_test.py
+++ b/dirsrvtests/tests/tickets/ticket47431_test.py
@@ -57,13 +57,13 @@ def test_ticket47431_1(topology_st):
assert False
arg2 = "nsslapd-pluginarg2: userpassword"
- topology_st.standalone.stop(timeout=10)
+ topology_st.standalone.stop()
dse_ldif = topology_st.standalone.confdir + '/dse.ldif'
os.system('mv %s %s.47431' % (dse_ldif, dse_ldif))
os.system(
'sed -e
"s/\\(%s\\)/\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1\\n\\1/"
%s.47431 > %s' % (
arg2, dse_ldif, dse_ldif))
- topology_st.standalone.start(timeout=10)
+ topology_st.standalone.start()
cmdline = 'egrep -i "%s" %s' % (expected,
topology_st.standalone.errlog)
p = os.popen(cmdline, "r")
@@ -116,7 +116,7 @@ def test_ticket47431_2(topology_st):
# PLUGIN LOG LEVEL
topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
'nsslapd-errorlog-level', '65536')])
- topology_st.standalone.restart(timeout=10)
+ topology_st.standalone.restart()
cmdline = 'egrep -i %s %s' % ("NS7bitAttr_Init",
topology_st.standalone.errlog)
p = os.popen(cmdline, "r")
@@ -176,10 +176,10 @@ def test_ticket47431_3(topology_st):
# PLUGIN LOG LEVEL
topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
'nsslapd-errorlog-level', '65536')])
- topology_st.standalone.stop(timeout=10)
+ topology_st.standalone.stop()
os.system('mv %s %s.47431' % (topology_st.standalone.errlog,
topology_st.standalone.errlog))
os.system('touch %s' % (topology_st.standalone.errlog))
- topology_st.standalone.start(timeout=10)
+ topology_st.standalone.start()
cmdline = 'egrep -i %s %s' % ("NS7bitAttr_Init",
topology_st.standalone.errlog)
p = os.popen(cmdline, "r")
diff --git a/dirsrvtests/tests/tickets/ticket47714_test.py
b/dirsrvtests/tests/tickets/ticket47714_test.py
index 146b49d..5ef9f9d 100644
--- a/dirsrvtests/tests/tickets/ticket47714_test.py
+++ b/dirsrvtests/tests/tickets/ticket47714_test.py
@@ -24,7 +24,8 @@ pytestmark = pytest.mark.skipif(ds_is_older('1.3.3'),
reason="Not implemented")
ACCT_POLICY_CONFIG_DN = ('cn=config,cn=%s,cn=plugins,cn=config' %
PLUGIN_ACCT_POLICY)
ACCT_POLICY_DN = 'cn=Account Inactivation Policy,%s' % SUFFIX
-INACTIVITY_LIMIT = '9'
+# Set inactivty high to prevent timing issues with debug options or gdb on test runs.
+INACTIVITY_LIMIT = '3000'
SEARCHFILTER = '(objectclass=*)'
TEST_USER = 'ticket47714user'
@@ -89,7 +90,7 @@ def test_ticket47714_run_0(topology_st):
# Enable the plugins
topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
- topology_st.standalone.restart(timeout=120)
+ topology_st.standalone.restart()
log.info("\n######################### Bind as %s ######################\n"
% TEST_USER_DN)
try:
@@ -121,6 +122,12 @@ def test_ticket47714_run_0(topology_st):
assert lastLoginTime0 < lastLoginTime1
topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+ # Now, change the inactivity limit, because that should trigger the account to now be
locked. This is possible because the check is "delayed" until the usage of the
account.
+
+ topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE,
'accountInactivityLimit', '1'),])
+ time.sleep(2)
+
entry = topology_st.standalone.search_s(ACCT_POLICY_DN, ldap.SCOPE_BASE,
SEARCHFILTER)
log.info("\n######################### %s ######################\n" %
ACCT_POLICY_CONFIG_DN)
log.info("accountInactivityLimit: %s" % entry[0].accountInactivityLimit)
@@ -134,6 +141,10 @@ def test_ticket47714_run_0(topology_st):
log.info("%s was successfully inactivated." % TEST_USER_DN)
pass
+ # Now reset the value high to prevent issues with the next test.
+ topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+ topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE,
'accountInactivityLimit', INACTIVITY_LIMIT),])
+
def test_ticket47714_run_1(topology_st):
"""
@@ -162,7 +173,7 @@ def test_ticket47714_run_1(topology_st):
# Enable the plugins
topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
- topology_st.standalone.restart(timeout=120)
+ topology_st.standalone.restart()
log.info("\n######################### Bind as %s ######################\n"
% TEST_USER_DN)
try:
diff --git a/dirsrvtests/tests/tickets/ticket47781_test.py
b/dirsrvtests/tests/tickets/ticket47781_test.py
index c38b3f2..7e1e1de 100644
--- a/dirsrvtests/tests/tickets/ticket47781_test.py
+++ b/dirsrvtests/tests/tickets/ticket47781_test.py
@@ -78,8 +78,8 @@ def test_ticket47781(topology_st):
# Restart the server
#
log.info('Restarting server...')
- topology_st.standalone.stop(timeout=5)
- topology_st.standalone.start(timeout=5)
+ topology_st.standalone.stop()
+ topology_st.standalone.start()
#
# Import the ldif
diff --git a/dirsrvtests/tests/tickets/ticket47815_test.py
b/dirsrvtests/tests/tickets/ticket47815_test.py
index 939a9bc..0ceb31f 100644
--- a/dirsrvtests/tests/tickets/ticket47815_test.py
+++ b/dirsrvtests/tests/tickets/ticket47815_test.py
@@ -19,8 +19,7 @@ log = logging.getLogger(__name__)
from lib389.utils import *
# Skip on older versions
-pytestmark = pytest.mark.skipif(ds_is_older('1.3.3'), reason="Not
implemented")
-
+pytestmark = pytest.mark.skipif(ds_is_older('1.3.3') or
ds_is_newer('1.3.7'), reason="Not implemented, or invalid by
nsMemberOf")
def test_ticket47815(topology_st):
"""
@@ -58,10 +57,7 @@ def test_ticket47815(topology_st):
log.error('Failed to add automember config')
exit(1)
- topology_st.standalone.stop(timeout=120)
- time.sleep(1)
- topology_st.standalone.start(timeout=120)
- time.sleep(3)
+ topology_st.standalone.restart()
# need to reopen a connection toward the instance
topology_st.standalone.open()
diff --git a/dirsrvtests/tests/tickets/ticket48226_test.py
b/dirsrvtests/tests/tickets/ticket48226_test.py
index b2afdea..584b999 100644
--- a/dirsrvtests/tests/tickets/ticket48226_test.py
+++ b/dirsrvtests/tests/tickets/ticket48226_test.py
@@ -30,8 +30,8 @@ def test_ticket48226_set_purgedelay(topology_m2):
assert False
topology_m2.ms["master1"].modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
'nsslapd-auditlog-logging-enabled', 'on')])
topology_m2.ms["master2"].modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
'nsslapd-auditlog-logging-enabled', 'on')])
- topology_m2.ms["master1"].restart(30)
- topology_m2.ms["master2"].restart(30)
+ topology_m2.ms["master1"].restart()
+ topology_m2.ms["master2"].restart()
def test_ticket48226_1(topology_m2):
diff --git a/dirsrvtests/tests/tickets/ticket48228_test.py
b/dirsrvtests/tests/tickets/ticket48228_test.py
index 08c372e..6c542ad 100644
--- a/dirsrvtests/tests/tickets/ticket48228_test.py
+++ b/dirsrvtests/tests/tickets/ticket48228_test.py
@@ -120,10 +120,12 @@ def check_passwd_inhistory(topology_st, user, cpw, passwd):
def update_passwd(topology_st, user, passwd, times):
+ # Set the default value
+ cpw = passwd
for i in range(times):
log.info(" Bind as {%s,%s}" % (user, cpw))
topology_st.standalone.simple_bind_s(user, cpw)
- time.sleep(1)
+ # Now update the value for this iter.
cpw = 'password%d' % i
try:
topology_st.standalone.modify_s(user, [(ldap.MOD_REPLACE,
'userpassword', cpw)])
@@ -132,7 +134,6 @@ def update_passwd(topology_st, user, passwd, times):
'test_ticket48228: Failed to update the password ' + cpw + '
of user ' + user + ': error ' + e.message[
'desc'])
assert False
- time.sleep(1)
# checking the first password, which is supposed to be in history
inhistory = check_passwd_inhistory(topology_st, user, cpw, passwd)
diff --git a/dirsrvtests/tests/tickets/ticket48266_test.py
b/dirsrvtests/tests/tickets/ticket48266_test.py
index 1964c85..3c814ec 100644
--- a/dirsrvtests/tests/tickets/ticket48266_test.py
+++ b/dirsrvtests/tests/tickets/ticket48266_test.py
@@ -10,30 +10,6 @@ NEW_ACCOUNT = "new_account"
MAX_ACCOUNTS = 20
-def pattern_accesslog(file, log_pattern):
- try:
- pattern_accesslog.last_pos += 1
- except AttributeError:
- pattern_accesslog.last_pos = 0
-
- found = None
- file.seek(pattern_accesslog.last_pos)
-
- # Use a while true iteration because 'for line in file: hit a
- # python bug that break file.tell()
- while True:
- line = file.readline()
- found = log_pattern.search(line)
- if ((line == '') or (found)):
- break
-
- pattern_accesslog.last_pos = file.tell()
- if found:
- return line
- else:
- return None
-
-
@pytest.fixture(scope="module")
def entries(topology_m2):
# add dummy entries in the staging DIT
@@ -43,10 +19,15 @@ def entries(topology_m2):
'objectclass': "top person".split(),
'sn': name,
'cn': name})))
- mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '8192'),
- (ldap.MOD_REPLACE, 'nsslapd-accesslog-level', str(256 + 4))]
- topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
- topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
+
topology_m2.ms["master1"].config.set('nsslapd-accesslog-logbuffering',
'off')
+ topology_m2.ms["master1"].config.set('nsslapd-errorlog-level',
'8192')
+ # 256 + 4
+ topology_m2.ms["master1"].config.set('nsslapd-accesslog-level',
'260')
+
+
topology_m2.ms["master2"].config.set('nsslapd-accesslog-logbuffering',
'off')
+ topology_m2.ms["master2"].config.set('nsslapd-errorlog-level',
'8192')
+ # 256 + 4
+ topology_m2.ms["master2"].config.set('nsslapd-accesslog-level',
'260')
def test_ticket48266_fractional(topology_m2, entries):
@@ -64,8 +45,8 @@ def test_ticket48266_fractional(topology_m2, entries):
assert len(ents) == 1
topology_m2.ms["master2"].modify_s(ents[0].dn, mod)
- topology_m2.ms["master1"].restart(timeout=10)
- topology_m2.ms["master2"].restart(timeout=10)
+ topology_m2.ms["master1"].restart()
+ topology_m2.ms["master2"].restart()
topology_m2.ms["master1"].agreement.init(SUFFIX, HOST_MASTER_2,
PORT_MASTER_2)
topology_m2.ms["master1"].waitForReplInit(m1_m2_agmt)
@@ -109,31 +90,20 @@ def _get_last_not_replicated_csn(topology_m2):
break
assert attr
+ log.info("############# %s " % name)
# now retrieve the CSN of the operation we are looking for
csn = None
- topology_m2.ms["master1"].stop(timeout=10)
- file_obj = open(topology_m2.ms["master1"].accesslog, "r")
-
- # First the conn/op of the operation
- regex = re.compile("MOD dn=\"%s\"" % name)
- found_op = pattern_accesslog(file_obj, regex)
- assert found_op
- if found_op:
- conn_op_pattern = '.* (conn=[0-9]* op=[0-9]*) .*'
- conn_op_re = re.compile(conn_op_pattern)
- conn_op_match = conn_op_re.match(found_op)
- conn_op = conn_op_match.group(1)
-
- # now the related CSN
- regex = re.compile("%s RESULT" % conn_op)
- found_result = pattern_accesslog(file_obj, regex)
- csn_pattern = '.* csn=(.*)'
- csn_re = re.compile(csn_pattern)
- csn_match = csn_re.match(found_result)
- csn = csn_match.group(1)
-
- topology_m2.ms["master1"].start(timeout=10)
- return csn
+ found_ops = topology_m2.ms['master1'].ds_access_log.match(".*MOD
dn=\"%s\".*" % name)
+ assert(len(found_ops) > 0)
+ found_op = topology_m2.ms['master1'].ds_access_log.parse_line(found_ops[-1])
+ log.info(found_op)
+
+ # Now look for the related CSN
+ found_csns = topology_m2.ms['master1'].ds_access_log.match(".*conn=%s
op=%s RESULT.*" % (found_op['conn'], found_op['op']))
+ assert(len(found_csns) > 0)
+ found_csn =
topology_m2.ms['master1'].ds_access_log.parse_line(found_csns[-1])
+ log.info(found_csn)
+ return found_csn['csn']
def _get_first_not_replicated_csn(topology_m2):
@@ -155,31 +125,20 @@ def _get_first_not_replicated_csn(topology_m2):
break
assert attr
+ log.info("############# %s " % name)
# now retrieve the CSN of the operation we are looking for
csn = None
- topology_m2.ms["master1"].stop(timeout=10)
- file_obj = open(topology_m2.ms["master1"].accesslog, "r")
-
- # First the conn/op of the operation
- regex = re.compile("MOD dn=\"%s\"" % name)
- found_op = pattern_accesslog(file_obj, regex)
- assert found_op
- if found_op:
- conn_op_pattern = '.* (conn=[0-9]* op=[0-9]*) .*'
- conn_op_re = re.compile(conn_op_pattern)
- conn_op_match = conn_op_re.match(found_op)
- conn_op = conn_op_match.group(1)
-
- # now the related CSN
- regex = re.compile("%s RESULT" % conn_op)
- found_result = pattern_accesslog(file_obj, regex)
- csn_pattern = '.* csn=(.*)'
- csn_re = re.compile(csn_pattern)
- csn_match = csn_re.match(found_result)
- csn = csn_match.group(1)
-
- topology_m2.ms["master1"].start(timeout=10)
- return csn
+ found_ops = topology_m2.ms['master1'].ds_access_log.match(".*MOD
dn=\"%s\".*" % name)
+ assert(len(found_ops) > 0)
+ found_op = topology_m2.ms['master1'].ds_access_log.parse_line(found_ops[-1])
+ log.info(found_op)
+
+ # Now look for the related CSN
+ found_csns = topology_m2.ms['master1'].ds_access_log.match(".*conn=%s
op=%s RESULT.*" % (found_op['conn'], found_op['op']))
+ assert(len(found_csns) > 0)
+ found_csn =
topology_m2.ms['master1'].ds_access_log.parse_line(found_csns[-1])
+ log.info(found_csn)
+ return found_csn['csn']
def _count_full_session(topology_m2):
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.