dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py | 5 dirsrvtests/suites/basic/basic_test.py | 5 dirsrvtests/tickets/ticket47653MMR_test.py | 3 dirsrvtests/tickets/ticket47669_test.py | 121 +++++----- dirsrvtests/tickets/ticket47714_test.py | 8 5 files changed, 73 insertions(+), 69 deletions(-)
New commits: commit 5bc311bb4aada33b0911c7de5955287301782b62 Author: Mark Reynolds mreynolds@redhat.com Date: Fri Sep 25 20:17:21 2015 -0400
Ticket 48204 - update lib389 test scripts for python 3
Description: Added support for python3, and also addressed certain failing test scripts.
https://fedorahosted.org/389/ticket/48204
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 3d0ae27c29cc3a0fb9c152b012903c63a94c5dd6)
diff --git a/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py b/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py index c26a0a2..06e7425 100644 --- a/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py +++ b/dirsrvtests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py @@ -21,7 +21,8 @@ from lib389.utils import *
logging.getLogger(__name__).setLevel(logging.DEBUG) log = logging.getLogger(__name__) - +USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX +USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX installation1_prefix = None
@@ -67,6 +68,8 @@ def test_attr_uniqueness_init(topology): ldap.fatal('Failed to enable dynamic plugin!' + e.message['desc']) assert False
+ topology.standalone.plugins.enable(name=PLUGIN_ATTR_UNIQUENESS) +
def test_attr_uniqueness(topology): log.info('Running test_attr_uniqueness...') diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py index 9aec8ef..d2f81ff 100644 --- a/dirsrvtests/suites/basic/basic_test.py +++ b/dirsrvtests/suites/basic/basic_test.py @@ -661,15 +661,16 @@ def test_basic_systemctl(topology, import_example_ldif): log.fatal('test_basic_systemctl: The server incorrectly started') assert False log.info('Server failed to start as expected') + time.sleep(5)
# # Fix the dse.ldif, and make sure the server starts up, # and systemctl correctly identifies the successful start # shutil.copy(tmp_dir + 'dse.ldif', config_dir) - log.info('Starting the server...') + log.info('Starting the server with good dse.ldif...') rc = os.system(start_ds) - time.sleep(10) + time.sleep(5) log.info('Check the status...') if rc != 0 or os.system(is_running) != 0: log.fatal('test_basic_systemctl: Failed to start the server') diff --git a/dirsrvtests/tickets/ticket47653MMR_test.py b/dirsrvtests/tickets/ticket47653MMR_test.py index 0c6da02..f951e55 100644 --- a/dirsrvtests/tickets/ticket47653MMR_test.py +++ b/dirsrvtests/tickets/ticket47653MMR_test.py @@ -104,10 +104,9 @@ def topology(request): master2.allocate(args_master)
# Get the status of the instance and restart it if it exists - instance_master1 = master1.exists() + instance_master1 = master1.exists() instance_master2 = master2.exists()
- # Remove all the instances if instance_master1: master1.delete() diff --git a/dirsrvtests/tickets/ticket47669_test.py b/dirsrvtests/tickets/ticket47669_test.py index 5458fba..2ef1f3e 100644 --- a/dirsrvtests/tickets/ticket47669_test.py +++ b/dirsrvtests/tickets/ticket47669_test.py @@ -79,7 +79,7 @@ def topology(request): return TopologyStandalone(standalone)
-def test_ticket47669_init(topo): +def test_ticket47669_init(topology): """ Add cn=changelog5,cn=config Enable cn=Retro Changelog Plugin,cn=plugins,cn=config @@ -87,12 +87,12 @@ def test_ticket47669_init(topo): log.info('Testing Ticket 47669 - Test duration syntax in the changelogs')
# bind as directory manager - topo.standalone.log.info("Bind as %s" % DN_DM) - topo.standalone.simple_bind_s(DN_DM, PASSWORD) + topology.standalone.log.info("Bind as %s" % DN_DM) + topology.standalone.simple_bind_s(DN_DM, PASSWORD)
try: - changelogdir = "%s/changelog" % topo.standalone.dbdir - topo.standalone.add_s(Entry((CHANGELOG, + changelogdir = "%s/changelog" % topology.standalone.dbdir + topology.standalone.add_s(Entry((CHANGELOG, {'objectclass': 'top extensibleObject'.split(), 'nsslapd-changelogdir': changelogdir}))) except ldap.LDAPError as e: @@ -100,23 +100,23 @@ def test_ticket47669_init(topo): assert False
try: - topo.standalone.modify_s(RETROCHANGELOG, [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on')]) + topology.standalone.modify_s(RETROCHANGELOG, [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on')]) except ldap.LDAPError as e: log.error('Failed to enable ' + RETROCHANGELOG + ': error ' + e.message['desc']) assert False
# restart the server - topo.standalone.restart(timeout=10) + topology.standalone.restart(timeout=10)
-def add_and_check(topo, plugin, attr, val, isvalid): +def add_and_check(topology, plugin, attr, val, isvalid): """ Helper function to add/replace attr: val and check the added value """ if isvalid: log.info('Test %s: %s -- valid' % (attr, val)) try: - topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) + topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) except ldap.LDAPError as e: log.error('Failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc']) assert False @@ -124,17 +124,18 @@ def add_and_check(topo, plugin, attr, val, isvalid): log.info('Test %s: %s -- invalid' % (attr, val)) if plugin == CHANGELOG: try: - topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) + topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) except ldap.LDAPError as e: - log.error('Expectedly failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc']) + log.error('Expectedly failed to add ' + attr + ': ' + val + + ' to ' + plugin + ': error ' + e.message['desc']) else: try: - topo.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) + topology.standalone.modify_s(plugin, [(ldap.MOD_REPLACE, attr, val)]) except ldap.LDAPError as e: log.error('Failed to add ' + attr + ': ' + val + ' to ' + plugin + ': error ' + e.message['desc'])
try: - entries = topo.standalone.search_s(plugin, ldap.SCOPE_BASE, FILTER, [attr]) + entries = topology.standalone.search_s(plugin, ldap.SCOPE_BASE, FILTER, [attr]) if isvalid: if not entries[0].hasValue(attr, val): log.fatal('%s does not have expected (%s: %s)' % (plugin, attr, val)) @@ -153,86 +154,86 @@ def add_and_check(topo, plugin, attr, val, isvalid): assert False
-def test_ticket47669_changelog_maxage(topo): +def test_ticket47669_changelog_maxage(topology): """ Test nsslapd-changelogmaxage in cn=changelog5,cn=config """ log.info('1. Test nsslapd-changelogmaxage in cn=changelog5,cn=config')
# bind as directory manager - topo.standalone.log.info("Bind as %s" % DN_DM) - topo.standalone.simple_bind_s(DN_DM, PASSWORD) + topology.standalone.log.info("Bind as %s" % DN_DM) + topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, MAXAGE, '12345', True) - add_and_check(topo, CHANGELOG, MAXAGE, '10s', True) - add_and_check(topo, CHANGELOG, MAXAGE, '30M', True) - add_and_check(topo, CHANGELOG, MAXAGE, '12h', True) - add_and_check(topo, CHANGELOG, MAXAGE, '2D', True) - add_and_check(topo, CHANGELOG, MAXAGE, '4w', True) - add_and_check(topo, CHANGELOG, MAXAGE, '-123', False) - add_and_check(topo, CHANGELOG, MAXAGE, 'xyz', False) + add_and_check(topology, CHANGELOG, MAXAGE, '12345', True) + add_and_check(topology, CHANGELOG, MAXAGE, '10s', True) + add_and_check(topology, CHANGELOG, MAXAGE, '30M', True) + add_and_check(topology, CHANGELOG, MAXAGE, '12h', True) + add_and_check(topology, CHANGELOG, MAXAGE, '2D', True) + add_and_check(topology, CHANGELOG, MAXAGE, '4w', True) + add_and_check(topology, CHANGELOG, MAXAGE, '-123', False) + add_and_check(topology, CHANGELOG, MAXAGE, 'xyz', False)
-def test_ticket47669_changelog_triminterval(topo): +def test_ticket47669_changelog_triminterval(topology): """ Test nsslapd-changelogtrim-interval in cn=changelog5,cn=config """ log.info('2. Test nsslapd-changelogtrim-interval in cn=changelog5,cn=config')
# bind as directory manager - topo.standalone.log.info("Bind as %s" % DN_DM) - topo.standalone.simple_bind_s(DN_DM, PASSWORD) + topology.standalone.log.info("Bind as %s" % DN_DM) + topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, TRIMINTERVAL, '12345', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '10s', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '30M', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '12h', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '2D', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '4w', True) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, '-123', False) - add_and_check(topo, CHANGELOG, TRIMINTERVAL, 'xyz', False) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '12345', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '10s', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '30M', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '12h', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '2D', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '4w', True) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, '-123', False) + add_and_check(topology, CHANGELOG, TRIMINTERVAL, 'xyz', False)
-def test_ticket47669_changelog_compactdbinterval(topo): +def test_ticket47669_changelog_compactdbinterval(topology): """ Test nsslapd-changelogcompactdb-interval in cn=changelog5,cn=config """ log.info('3. Test nsslapd-changelogcompactdb-interval in cn=changelog5,cn=config')
# bind as directory manager - topo.standalone.log.info("Bind as %s" % DN_DM) - topo.standalone.simple_bind_s(DN_DM, PASSWORD) + topology.standalone.log.info("Bind as %s" % DN_DM) + topology.standalone.simple_bind_s(DN_DM, PASSWORD)
- add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '12345', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '10s', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '30M', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '12h', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '2D', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '4w', True) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, '-123', False) - add_and_check(topo, CHANGELOG, COMPACTDBINTERVAL, 'xyz', False) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '12345', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '10s', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '30M', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '12h', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '2D', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '4w', True) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, '-123', False) + add_and_check(topology, CHANGELOG, COMPACTDBINTERVAL, 'xyz', False)
-def test_ticket47669_retrochangelog_maxage(topo): +def test_ticket47669_retrochangelog_maxage(topology): """ Test nsslapd-changelogmaxage in cn=Retro Changelog Plugin,cn=plugins,cn=config """ log.info('4. Test nsslapd-changelogmaxage in cn=Retro Changelog Plugin,cn=plugins,cn=config')
# bind as directory manager - topo.standalone.log.info("Bind as %s" % DN_DM) - topo.standalone.simple_bind_s(DN_DM, PASSWORD) - - add_and_check(topo, RETROCHANGELOG, MAXAGE, '12345', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '10s', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '30M', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '12h', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '2D', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '4w', True) - add_and_check(topo, RETROCHANGELOG, MAXAGE, '-123', False) - add_and_check(topo, RETROCHANGELOG, MAXAGE, 'xyz', False) - - topo.standalone.log.info("ticket47669 was successfully verified.") + topology.standalone.log.info("Bind as %s" % DN_DM) + topology.standalone.simple_bind_s(DN_DM, PASSWORD) + + add_and_check(topology, RETROCHANGELOG, MAXAGE, '12345', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '10s', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '30M', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '12h', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '2D', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '4w', True) + add_and_check(topology, RETROCHANGELOG, MAXAGE, '-123', False) + add_and_check(topology, RETROCHANGELOG, MAXAGE, 'xyz', False) + + topology.standalone.log.info("ticket47669 was successfully verified.")
def test_ticket47669_final(topology): diff --git a/dirsrvtests/tickets/ticket47714_test.py b/dirsrvtests/tickets/ticket47714_test.py index 400c243..268ddef 100644 --- a/dirsrvtests/tickets/ticket47714_test.py +++ b/dirsrvtests/tickets/ticket47714_test.py @@ -209,22 +209,22 @@ def test_ticket47714_run_1(topology): except ldap.CONSTRAINT_VIOLATION as e: log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ time.sleep(1) + topology.standalone.simple_bind_s(DN_DM, PASSWORD) entry = topology.standalone.search_s(TEST_USER_DN, ldap.SCOPE_BASE, SEARCHFILTER, ['lastLoginTime']) - lastLoginTime0 = entry[0].lastLoginTime
- time.sleep(2) - log.info("\n######################### Bind as %s again ######################\n" % TEST_USER_DN) try: topology.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW) except ldap.CONSTRAINT_VIOLATION as e: log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ time.sleep(1) + topology.standalone.simple_bind_s(DN_DM, PASSWORD) entry = topology.standalone.search_s(TEST_USER_DN, ldap.SCOPE_BASE, SEARCHFILTER, ['lastLoginTime']) - lastLoginTime1 = entry[0].lastLoginTime
log.info("First lastLoginTime: %s, Second lastLoginTime: %s" % (lastLoginTime0, lastLoginTime1))
389-commits@lists.fedoraproject.org