dirsrvtests/create_test.py | 7 dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py | 20 dirsrvtests/tests/suites/acct_usability_plugin/acct_usability_test.py | 12 dirsrvtests/tests/suites/acctpolicy_plugin/acctpolicy_test.py | 15 dirsrvtests/tests/suites/acl/acl_test.py | 6 dirsrvtests/tests/suites/attr_encryption/attr_encrypt_test.py | 14 dirsrvtests/tests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py | 17 dirsrvtests/tests/suites/automember_plugin/automember_test.py | 14 dirsrvtests/tests/suites/basic/basic_test.py | 31 dirsrvtests/tests/suites/betxns/betxn_test.py | 11 dirsrvtests/tests/suites/chaining_plugin/chaining_test.py | 15 dirsrvtests/tests/suites/clu/clu_test.py | 15 dirsrvtests/tests/suites/clu/db2ldif_test.py | 14 dirsrvtests/tests/suites/collation_plugin/collatation_test.py | 8 dirsrvtests/tests/suites/cos_plugin/cos_test.py | 13 dirsrvtests/tests/suites/deref_plugin/deref_test.py | 13 dirsrvtests/tests/suites/disk_monitoring/disk_monitor_test.py | 13 dirsrvtests/tests/suites/distrib_plugin/distrib_test.py | 13 dirsrvtests/tests/suites/ds_logs/ds_logs_test.py | 13 dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py | 9 dirsrvtests/tests/suites/filter/filter_test.py | 12 dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py | 2 dirsrvtests/tests/suites/get_effective_rights/ger_test.py | 13 dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py | 5 dirsrvtests/tests/suites/ldapi/ldapi_test.py | 13 dirsrvtests/tests/suites/linkedattrs_plugin/linked_attrs_test.py | 13 dirsrvtests/tests/suites/mapping_tree/mapping_tree_test.py | 13 dirsrvtests/tests/suites/memberof_plugin/memberof_test.py | 1 dirsrvtests/tests/suites/memory_leaks/range_search_test.py | 4 dirsrvtests/tests/suites/monitor/monitor_test.py | 13 dirsrvtests/tests/suites/paged_results/paged_results_test.py | 40 dirsrvtests/tests/suites/pam_passthru_plugin/pam_test.py | 13 dirsrvtests/tests/suites/passthru_plugin/passthru_test.py | 13 dirsrvtests/tests/suites/password/password_test.py | 11 dirsrvtests/tests/suites/password/pwdAdmin_test.py | 11 dirsrvtests/tests/suites/password/pwdPolicy_test.py | 181 +- dirsrvtests/tests/suites/posix_winsync_plugin/posix_winsync_test.py | 13 dirsrvtests/tests/suites/psearch/psearch_test.py | 13 dirsrvtests/tests/suites/referint_plugin/referint_test.py | 13 dirsrvtests/tests/suites/replication/cleanallruv_test.py | 703 +++------- dirsrvtests/tests/suites/replication/wait_for_async_feature_test.py | 16 dirsrvtests/tests/suites/replsync_plugin/repl_sync_test.py | 13 dirsrvtests/tests/suites/resource_limits/res_limits_test.py | 13 dirsrvtests/tests/suites/retrocl_plugin/retrocl_test.py | 13 dirsrvtests/tests/suites/reverpwd_plugin/reverpwd_test.py | 13 dirsrvtests/tests/suites/roles_plugin/roles_test.py | 13 dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py | 22 dirsrvtests/tests/suites/sasl/sasl_test.py | 14 dirsrvtests/tests/suites/schema/test_schema.py | 10 dirsrvtests/tests/suites/schema_reload_plugin/schema_reload_test.py | 13 dirsrvtests/tests/suites/snmp/snmp_test.py | 13 dirsrvtests/tests/suites/ssl/ssl_test.py | 13 dirsrvtests/tests/suites/syntax_plugin/syntax_test.py | 13 dirsrvtests/tests/suites/usn_plugin/usn_test.py | 13 dirsrvtests/tests/suites/views_plugin/views_test.py | 14 dirsrvtests/tests/suites/vlv/vlv_test.py | 13 dirsrvtests/tests/suites/whoami_plugin/whoami_test.py | 13 dirsrvtests/tests/tickets/ticket1347760_test.py | 10 dirsrvtests/tests/tickets/ticket142_test.py | 15 dirsrvtests/tests/tickets/ticket365_test.py | 67 dirsrvtests/tests/tickets/ticket47313_test.py | 12 dirsrvtests/tests/tickets/ticket47384_test.py | 41 dirsrvtests/tests/tickets/ticket47431_test.py | 14 dirsrvtests/tests/tickets/ticket47490_test.py | 11 dirsrvtests/tests/tickets/ticket47536_test.py | 36 dirsrvtests/tests/tickets/ticket47560_test.py | 8 dirsrvtests/tests/tickets/ticket47573_test.py | 10 dirsrvtests/tests/tickets/ticket47619_test.py | 10 dirsrvtests/tests/tickets/ticket47640_test.py | 6 dirsrvtests/tests/tickets/ticket47653MMR_test.py | 13 dirsrvtests/tests/tickets/ticket47653_test.py | 13 dirsrvtests/tests/tickets/ticket47669_test.py | 6 dirsrvtests/tests/tickets/ticket47676_test.py | 10 dirsrvtests/tests/tickets/ticket47714_test.py | 19 dirsrvtests/tests/tickets/ticket47721_test.py | 11 dirsrvtests/tests/tickets/ticket47781_test.py | 6 dirsrvtests/tests/tickets/ticket47787_test.py | 10 dirsrvtests/tests/tickets/ticket47808_test.py | 10 dirsrvtests/tests/tickets/ticket47815_test.py | 6 dirsrvtests/tests/tickets/ticket47819_test.py | 15 dirsrvtests/tests/tickets/ticket47823_test.py | 8 dirsrvtests/tests/tickets/ticket47828_test.py | 202 +- dirsrvtests/tests/tickets/ticket47829_test.py | 8 dirsrvtests/tests/tickets/ticket47833_test.py | 54 dirsrvtests/tests/tickets/ticket47838_test.py | 24 dirsrvtests/tests/tickets/ticket47869MMR_test.py | 10 dirsrvtests/tests/tickets/ticket47871_test.py | 11 dirsrvtests/tests/tickets/ticket47900_test.py | 6 dirsrvtests/tests/tickets/ticket47910_test.py | 44 dirsrvtests/tests/tickets/ticket47920_test.py | 6 dirsrvtests/tests/tickets/ticket47921_test.py | 6 dirsrvtests/tests/tickets/ticket47927_test.py | 6 dirsrvtests/tests/tickets/ticket47937_test.py | 6 dirsrvtests/tests/tickets/ticket47950_test.py | 6 dirsrvtests/tests/tickets/ticket47953_test.py | 19 dirsrvtests/tests/tickets/ticket47963_test.py | 6 dirsrvtests/tests/tickets/ticket47966_test.py | 10 dirsrvtests/tests/tickets/ticket47970_test.py | 6 dirsrvtests/tests/tickets/ticket47973_test.py | 6 dirsrvtests/tests/tickets/ticket47980_test.py | 6 dirsrvtests/tests/tickets/ticket47981_test.py | 6 dirsrvtests/tests/tickets/ticket47988_test.py | 9 dirsrvtests/tests/tickets/ticket48005_test.py | 38 dirsrvtests/tests/tickets/ticket48013_test.py | 6 dirsrvtests/tests/tickets/ticket48026_test.py | 6 dirsrvtests/tests/tickets/ticket48170_test.py | 8 dirsrvtests/tests/tickets/ticket48194_test.py | 10 dirsrvtests/tests/tickets/ticket48212_test.py | 10 dirsrvtests/tests/tickets/ticket48214_test.py | 7 dirsrvtests/tests/tickets/ticket48226_test.py | 29 dirsrvtests/tests/tickets/ticket48228_test.py | 6 dirsrvtests/tests/tickets/ticket48252_test.py | 15 dirsrvtests/tests/tickets/ticket48265_test.py | 5 dirsrvtests/tests/tickets/ticket48270_test.py | 28 dirsrvtests/tests/tickets/ticket48294_test.py | 9 dirsrvtests/tests/tickets/ticket48295_test.py | 8 dirsrvtests/tests/tickets/ticket48342_test.py | 12 dirsrvtests/tests/tickets/ticket48362_test.py | 33 dirsrvtests/tests/tickets/ticket48366_test.py | 11 dirsrvtests/tests/tickets/ticket48497_test.py | 18 dirsrvtests/tests/tickets/ticket48745_test.py | 12 dirsrvtests/tests/tickets/ticket48746_test.py | 22 dirsrvtests/tests/tickets/ticket48759_test.py | 16 dirsrvtests/tests/tickets/ticket48784_test.py | 29 dirsrvtests/tests/tickets/ticket48798_test.py | 10 dirsrvtests/tests/tickets/ticket48844_test.py | 2 dirsrvtests/tests/tickets/ticket48891_test.py | 10 dirsrvtests/tests/tickets/ticket548_test.py | 5 128 files changed, 1198 insertions(+), 1596 deletions(-)
New commits: commit 19721959cbbbad60d8621bdca8a2c66d67bb5d5c Author: Mark Reynolds mreynolds@redhat.com Date: Wed Jul 20 20:43:19 2016 -0400
Ticket 48832 - Fix lib389 CI ticket/suite test failures
Description: There were varuious failures in many of the lib389 CI tests. Here is a list of some of the common fixes that were made:
- Removed the use of TMP_DIR, and used /tmp for everything. There were just too many issues with permissions (between user running the tests and the DS user). - Added some sleeps where timing was an issue. - Updated the tests to match new lib389 API changes - Fixed all the tests so they work with SELinux enforcing - Made sure ever test script has a finialzier to remove the instance.
https://fedorahosted.org/389/ticket/48832
Reviewed by: spichugi & firstyear (Thanks!!)
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py index 46c8217..19b838f 100755 --- a/dirsrvtests/create_test.py +++ b/dirsrvtests/create_test.py @@ -346,6 +346,8 @@ if len(sys.argv) > 0: '(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, ' + 'replicaId=CONSUMER_REPLICAID)\n\n')
+ writeFinalizer() + # # Create the master agreements # @@ -584,8 +586,6 @@ if len(sys.argv) > 0: TEST.write(' assert False\n') TEST.write('\n')
- writeFinalizer() - # # Write the finals steps for replication # @@ -649,10 +649,7 @@ if len(sys.argv) > 0:
writeFinalizer()
- TEST.write(' # Clear out the tmp dir\n') - TEST.write(' standalone.clearTmpDir(__file__)\n') TEST.write('\n') - TEST.write(' return TopologyStandalone(standalone') for idx in range(instances): idx += 1 diff --git a/dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py b/dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py index b827033..d00d78c 100644 --- a/dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py +++ b/dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py @@ -1,5 +1,5 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2016 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). @@ -50,7 +50,7 @@ def topology(request): args_instance[SER_DEPLOYED_DIR] = installation1_prefix
# Creating master 1... - master1 = DirSrv(verbose=True) + master1 = DirSrv(verbose=False) args_instance[SER_HOST] = HOST_MASTER_1 args_instance[SER_PORT] = PORT_MASTER_1 args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1 @@ -118,9 +118,9 @@ def topology(request): # # Import tests entries into master1 before we initialize master2 # - tmp_dir = master1.getDir(__file__, TMP_DIR) + ldif_dir = master1.get_ldif_dir()
- import_ldif = tmp_dir + '/rel7.5-entries.ldif' + import_ldif = ldif_dir + '/rel7.5-entries.ldif'
# First generate an ldif try: @@ -200,6 +200,9 @@ def topology(request): def fin(): master1.delete() master2.delete() + if ENABLE_VALGRIND: + sbin_dir = get_sbin_dir(prefix=master1.prefix) + valgrind_disable(sbin_dir) request.addfinalizer(fin)
return TopologyReplication(master1, master2) @@ -279,7 +282,7 @@ class ModUsers(threading.Thread): DEFAULT_SUFFIX) NEW_RDN = 'cn=master' + self.id + '_entry' + str(idx) try: - conn.rename(USER_DN, NEW_RDN, delold=1) + conn.rename_s(USER_DN, NEW_RDN, delold=1) except ldap.LDAPError as e: log.error('Failed to modrdn (' + USER_DN + ') on master ' + self.id + ': error ' + e.message['desc']) @@ -294,7 +297,7 @@ class ModUsers(threading.Thread): DEFAULT_SUFFIX) NEW_RDN = 'uid=master' + self.id + '_entry' + str(idx) try: - conn.rename(USER_DN, NEW_RDN, delold=1) + conn.rename_s(USER_DN, NEW_RDN, delold=1) except ldap.LDAPError as e: log.error('Failed to modrdn (' + USER_DN + ') on master ' + self.id + ': error ' + e.message['desc']) @@ -557,11 +560,6 @@ def test_reliab7_5_run(topology): fullSearch1.join() fullSearch2.join()
- if ENABLE_VALGRIND: - # We're done, disable valgrind... - sbin_dir = get_sbin_dir(prefix=topology.master1.prefix) - valgrind_disable(sbin_dir) -
if __name__ == '__main__': # Run isolated diff --git a/dirsrvtests/tests/suites/acct_usability_plugin/acct_usability_test.py b/dirsrvtests/tests/suites/acct_usability_plugin/acct_usability_test.py index 36021e2..38b78c2 100644 --- a/dirsrvtests/tests/suites/acct_usability_plugin/acct_usability_test.py +++ b/dirsrvtests/tests/suites/acct_usability_plugin/acct_usability_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -54,6 +54,10 @@ def topology(request): # Clear out the tmp dir standalone.clearTmpDir(__file__)
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + return TopologyStandalone(standalone)
@@ -73,11 +77,6 @@ def test_acct_usability_(topology): return
-def test_acct_usability_final(topology): - topology.standalone.delete() - log.info('acct_usability test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +84,6 @@ def run_isolated(): topo = topology(True) test_acct_usability_init(topo) test_acct_usability_(topo) - test_acct_usability_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/acctpolicy_plugin/acctpolicy_test.py b/dirsrvtests/tests/suites/acctpolicy_plugin/acctpolicy_test.py index b7db352..6404360 100644 --- a/dirsrvtests/tests/suites/acctpolicy_plugin/acctpolicy_test.py +++ b/dirsrvtests/tests/suites/acctpolicy_plugin/acctpolicy_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -69,13 +70,8 @@ def test_acctpolicy_(topology): ''' Write a single test here... ''' - - return - - -def test_acctpolicy_final(topology): - topology.standalone.delete() log.info('acctpolicy test suite PASSED') + return
def run_isolated(): @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_acctpolicy_init(topo) test_acctpolicy_(topo) - test_acctpolicy_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/acl/acl_test.py b/dirsrvtests/tests/suites/acl/acl_test.py index 422a1ec..f42a584 100644 --- a/dirsrvtests/tests/suites/acl/acl_test.py +++ b/dirsrvtests/tests/suites/acl/acl_test.py @@ -190,7 +190,7 @@ def add_attr(topology, attr_name): mod = [(ldap.MOD_ADD, 'attributeTypes', ATTR_VALUE)]
try: - topology.standalone.modify_s(DN_SCHEMA, mod) + topology.master1.modify_s(DN_SCHEMA, mod) except ldap.LDAPError as e: log.fatal('Failed to add attr (%s): error (%s)' % (attr_name, e.message['desc'])) @@ -220,7 +220,7 @@ def aci_with_attr_subtype(request, topology): log.info(" Add an ACI with attribute subtype") mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)] try: - topology.standalone.modify_s(DEFAULT_SUFFIX, mod) + topology.master1.modify_s(DEFAULT_SUFFIX, mod) except ldap.LDAPError as e: log.fatal('Failed to add ACI: error (%s)' % (e.message['desc'])) assert False @@ -230,7 +230,7 @@ def aci_with_attr_subtype(request, topology): SUBTYPE) mod = [(ldap.MOD_DELETE, 'aci', ACI_BODY)] try: - topology.standalone.modify_s(DEFAULT_SUFFIX, mod) + topology.master1.modify_s(DEFAULT_SUFFIX, mod) except ldap.LDAPError as e: log.fatal('Failed to delete ACI: error (%s)' % (e.message['desc'])) assert False diff --git a/dirsrvtests/tests/suites/attr_encryption/attr_encrypt_test.py b/dirsrvtests/tests/suites/attr_encryption/attr_encrypt_test.py index 7d14a76..9b704d6 100644 --- a/dirsrvtests/tests/suites/attr_encryption/attr_encrypt_test.py +++ b/dirsrvtests/tests/suites/attr_encryption/attr_encrypt_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -54,6 +54,10 @@ def topology(request): # Clear out the tmp dir standalone.clearTmpDir(__file__)
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + return TopologyStandalone(standalone)
@@ -69,13 +73,8 @@ def test_attr_encrypt_(topology): ''' Write a single test here... ''' - - return - - -def test_attr_encrypt_final(topology): - topology.standalone.delete() log.info('attr_encrypt test suite PASSED') + return
def run_isolated(): @@ -85,7 +84,6 @@ def run_isolated(): topo = topology(True) test_attr_encrypt_init(topo) test_attr_encrypt_(topo) - test_attr_encrypt_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py b/dirsrvtests/tests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py index 06e7425..9786210 100644 --- a/dirsrvtests/tests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py +++ b/dirsrvtests/tests/suites/attr_uniqueness_plugin/attr_uniqueness_test.py @@ -1,19 +1,16 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2016 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). # See LICENSE for details. # --- END COPYRIGHT BLOCK --- # -import os -import sys import time import ldap import logging import pytest -from lib389 import DirSrv, Entry, tools, tasks -from lib389.tools import DirSrvTools +from lib389 import DirSrv, Entry from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -55,6 +52,10 @@ def topology(request): # Clear out the tmp dir standalone.clearTmpDir(__file__)
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + return TopologyStandalone(standalone)
@@ -228,11 +229,6 @@ def test_attr_uniqueness(topology): log.info('test_attr_uniqueness: PASS\n')
-def test_attr_uniqueness_final(topology): - topology.standalone.delete() - log.info('attr_uniqueness test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -240,7 +236,6 @@ def run_isolated(): topo = topology(True) test_attr_uniqueness_init(topo) test_attr_uniqueness(topo) - test_attr_uniqueness_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/automember_plugin/automember_test.py b/dirsrvtests/tests/suites/automember_plugin/automember_test.py index 3e5f020..940dd7f 100644 --- a/dirsrvtests/tests/suites/automember_plugin/automember_test.py +++ b/dirsrvtests/tests/suites/automember_plugin/automember_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -54,6 +54,10 @@ def topology(request): # Clear out the tmp dir standalone.clearTmpDir(__file__)
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + return TopologyStandalone(standalone)
@@ -69,13 +73,8 @@ def test_automember_(topology): ''' Write a single test here... ''' - - return - - -def test_automember_final(topology): - topology.standalone.delete() log.info('automember test suite PASSED') + return
def run_isolated(): @@ -85,7 +84,6 @@ def run_isolated(): topo = topology(True) test_automember_init(topo) test_automember_(topo) - test_automember_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py index d2f81ff..517ace6 100644 --- a/dirsrvtests/tests/suites/basic/basic_test.py +++ b/dirsrvtests/tests/suites/basic/basic_test.py @@ -81,9 +81,6 @@ def topology(request): standalone.delete() request.addfinalizer(fin)
- # clear the tmp directory - standalone.clearTmpDir(__file__) - # Here we have standalone instance up and running return TopologyStandalone(standalone)
@@ -94,7 +91,9 @@ def import_example_ldif(topology):
log.info('Initializing the "basic" test suite')
- import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix) + ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix) + import_ldif = topology.standalone.get_ldif_dir() + "/Example.ldif" + shutil.copyfile(ldif, import_ldif) try: topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, @@ -261,14 +260,15 @@ def test_basic_import_export(topology, import_example_ldif):
log.info('Running test_basic_import_export...')
- tmp_dir = topology.standalone.getDir(__file__, TMP_DIR) + tmp_dir = '/tmp'
# # Test online/offline LDIF imports #
# Generate a test ldif (50k entries) - import_ldif = tmp_dir + '/basic_import.ldif' + ldif_dir = topology.standalone.get_ldif_dir() + import_ldif = ldif_dir + '/basic_import.ldif' try: topology.standalone.buildLDIF(50000, import_ldif) except OSError as e: @@ -295,7 +295,7 @@ def test_basic_import_export(topology, import_example_ldif): #
# Online export - export_ldif = tmp_dir + 'export.ldif' + export_ldif = ldif_dir + '/export.ldif' exportTask = Tasks(topology.standalone) try: args = {TASK_WAIT: True} @@ -313,7 +313,9 @@ def test_basic_import_export(topology, import_example_ldif): # # Cleanup - Import the Example LDIF for the other tests in this suite # - import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix) + ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix) + import_ldif = topology.standalone.get_ldif_dir() + "/Example.ldif" + shutil.copyfile(ldif, import_ldif) try: topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, @@ -330,7 +332,7 @@ def test_basic_backup(topology, import_example_ldif):
log.info('Running test_basic_backup...')
- backup_dir = '%sbasic_backup/' % topology.standalone.getDir(__file__, TMP_DIR) + backup_dir = topology.standalone.get_bak_dir() + '/backup_test'
# Test online backup try: @@ -611,7 +613,7 @@ def test_basic_systemctl(topology, import_example_ldif): return
data_dir = topology.standalone.getDir(__file__, DATA_DIR) - tmp_dir = topology.standalone.getDir(__file__, TMP_DIR) + tmp_dir = '/tmp' config_dir = topology.standalone.confdir start_ds = 'sudo systemctl start dirsrv@' + topology.standalone.serverid + '.service' stop_ds = 'sudo systemctl stop dirsrv@' + topology.standalone.serverid + '.service' @@ -667,7 +669,7 @@ def test_basic_systemctl(topology, import_example_ldif): # 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) + shutil.copy(tmp_dir + '/dse.ldif', config_dir) log.info('Starting the server with good dse.ldif...') rc = os.system(start_ds) time.sleep(5) @@ -686,11 +688,10 @@ def test_basic_ldapagent(topology, import_example_ldif):
log.info('Running test_basic_ldapagent...')
- tmp_dir = topology.standalone.getDir(__file__, TMP_DIR) var_dir = topology.standalone.prefix + '/var' - config_file = tmp_dir + '/agent.conf' + config_file = topology.standalone.prefix + '/etc/dirsrv/config/agent.conf' cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix), - config_file) + config_file)
agent_config_file = open(config_file, 'w') agent_config_file.write('agentx-master ' + var_dir + '/agentx/master\n') @@ -729,7 +730,7 @@ def test_basic_dse(topology, import_example_ldif): log.fatal('test_basic_dse: dse.ldif's content was incorrectly removed!') assert False
- topology.standalone.start(timeout=10) + topology.standalone.start(timeout=60) log.info('dse.ldif was not corrupted, and the server was restarted')
log.info('test_basic_dse: PASSED') diff --git a/dirsrvtests/tests/suites/betxns/betxn_test.py b/dirsrvtests/tests/suites/betxns/betxn_test.py index 7bef791..97c1725 100644 --- a/dirsrvtests/tests/suites/betxns/betxn_test.py +++ b/dirsrvtests/tests/suites/betxns/betxn_test.py @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -236,11 +237,6 @@ def test_betxn_memberof(topology): log.info('test_betxn_memberof: PASSED')
-def test_betxn_final(topology): - topology.standalone.delete() - log.info('betxn test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -250,7 +246,6 @@ def run_isolated(): test_betxt_7bit(topo) test_betxn_attr_uniqueness(topo) test_betxn_memberof(topo) - test_betxn_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/chaining_plugin/chaining_test.py b/dirsrvtests/tests/suites/chaining_plugin/chaining_test.py index 50eed9a..fe00ce0 100644 --- a/dirsrvtests/tests/suites/chaining_plugin/chaining_test.py +++ b/dirsrvtests/tests/suites/chaining_plugin/chaining_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -69,13 +70,8 @@ def test_chaining_(topology): ''' Write a single test here... ''' - - return - - -def test_chaining_final(topology): - topology.standalone.delete() log.info('chaining test suite PASSED') + return
def run_isolated(): @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_chaining_init(topo) test_chaining_(topo) - test_chaining_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/clu/clu_test.py b/dirsrvtests/tests/suites/clu/clu_test.py index 4f2804f..824fa74 100644 --- a/dirsrvtests/tests/suites/clu/clu_test.py +++ b/dirsrvtests/tests/suites/clu/clu_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -89,11 +90,6 @@ def test_clu_pwdhash(topology): log.info('test_clu_pwdhash: PASSED')
-def test_clu_final(topology): - topology.standalone.delete() - log.info('clu test suite PASSED') - - def run_isolated(): ''' This test is for the simple scripts that don't have a lot of options or @@ -104,11 +100,8 @@ def run_isolated():
topo = topology(True) test_clu_init(topo) - test_clu_pwdhash(topo)
- test_clu_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/clu/db2ldif_test.py b/dirsrvtests/tests/suites/clu/db2ldif_test.py index dbfb0d0..3769dc4 100644 --- a/dirsrvtests/tests/suites/clu/db2ldif_test.py +++ b/dirsrvtests/tests/suites/clu/db2ldif_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -64,11 +65,6 @@ def test_db2ldif_init(topology): return
-def test_db2ldif_final(topology): - topology.standalone.delete() - log.info('db2ldif test suite PASSED') - - def run_isolated(): ''' Test db2lidf/db2ldif.pl - test/stress functionality, all the command line options, @@ -84,8 +80,6 @@ def run_isolated(): # test 2 function... # ...
- test_db2ldif_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/collation_plugin/collatation_test.py b/dirsrvtests/tests/suites/collation_plugin/collatation_test.py index 1a918c6..b941c8e 100644 --- a/dirsrvtests/tests/suites/collation_plugin/collatation_test.py +++ b/dirsrvtests/tests/suites/collation_plugin/collatation_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -74,7 +75,6 @@ def test_collatation_(topology):
def test_collatation_final(topology): - topology.standalone.delete() log.info('collatation test suite PASSED')
diff --git a/dirsrvtests/tests/suites/cos_plugin/cos_test.py b/dirsrvtests/tests/suites/cos_plugin/cos_test.py index 2dc3ac9..2e0355f 100644 --- a/dirsrvtests/tests/suites/cos_plugin/cos_test.py +++ b/dirsrvtests/tests/suites/cos_plugin/cos_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_cos_(topology): return
-def test_cos_final(topology): - topology.standalone.delete() - log.info('cos test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_cos_init(topo) test_cos_(topo) - test_cos_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/deref_plugin/deref_test.py b/dirsrvtests/tests/suites/deref_plugin/deref_test.py index 9beaa38..d0200de 100644 --- a/dirsrvtests/tests/suites/deref_plugin/deref_test.py +++ b/dirsrvtests/tests/suites/deref_plugin/deref_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_deref_(topology): return
-def test_deref_final(topology): - topology.standalone.delete() - log.info('deref test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_deref_init(topo) test_deref_(topo) - test_deref_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/disk_monitoring/disk_monitor_test.py b/dirsrvtests/tests/suites/disk_monitoring/disk_monitor_test.py index 0b84c54..5e9a137 100644 --- a/dirsrvtests/tests/suites/disk_monitoring/disk_monitor_test.py +++ b/dirsrvtests/tests/suites/disk_monitoring/disk_monitor_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_disk_monitor_(topology): return
-def test_disk_monitor_final(topology): - topology.standalone.delete() - log.info('disk_monitor test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_disk_monitor_init(topo) test_disk_monitor_(topo) - test_disk_monitor_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/distrib_plugin/distrib_test.py b/dirsrvtests/tests/suites/distrib_plugin/distrib_test.py index ab1cf87..69ce344 100644 --- a/dirsrvtests/tests/suites/distrib_plugin/distrib_test.py +++ b/dirsrvtests/tests/suites/distrib_plugin/distrib_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_distrib_(topology): return
-def test_distrib_final(topology): - topology.standalone.delete() - log.info('distrib test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_distrib_init(topo) test_distrib_(topo) - test_distrib_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py index 9d870d4..5c07e0f 100644 --- a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py +++ b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_ds_logs_(topology): return
-def test_ds_logs_final(topology): - topology.standalone.delete() - log.info('ds_logs test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_ds_logs_init(topo) test_ds_logs_(topo) - test_ds_logs_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py b/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py index c05c402..3b40488 100644 --- a/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py +++ b/dirsrvtests/tests/suites/dynamic-plugins/test_dynamic_plugins.py @@ -75,6 +75,10 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + # Here we have standalone instance up and running return TopologyStandalone(standalone)
@@ -469,10 +473,6 @@ def test_dynamic_plugins(topology): log.info('#####################################################\n')
-def test_dynamic_plugins_final(topology): - topology.standalone.delete() - - def run_isolated(): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) @@ -486,7 +486,6 @@ def run_isolated():
topo = topology(True) test_dynamic_plugins(topo) - test_dynamic_plugins_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/filter/filter_test.py b/dirsrvtests/tests/suites/filter/filter_test.py index d212f6a..7b1d19c 100644 --- a/dirsrvtests/tests/suites/filter/filter_test.py +++ b/dirsrvtests/tests/suites/filter/filter_test.py @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -129,11 +130,6 @@ def test_filter_search_original_attrs(topology): log.info('test_filter_search_original_attrs: PASSED')
-def test_filter_final(topology): - topology.standalone.delete() - log.info('Testcase PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -144,8 +140,6 @@ def run_isolated(): test_filter_escaped(topo) test_filter_search_original_attrs(topo)
- test_filter_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py index efea5a5..0fc207e 100644 --- a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py +++ b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py @@ -49,7 +49,7 @@ TEST_PARAMS = [(DN_ROOT, False, [ 'nsUniqueId', 'numSubordinates', 'parentid' ]), (DN_PEOPLE, True, [ - 'aci', 'createTimestamp', 'creatorsName', 'entrydn', + 'createTimestamp', 'creatorsName', 'entrydn', 'entryid', 'modifyTimestamp', 'nsUniqueId', 'numSubordinates', 'parentid' ]), diff --git a/dirsrvtests/tests/suites/get_effective_rights/ger_test.py b/dirsrvtests/tests/suites/get_effective_rights/ger_test.py index f87d0a1..561d18e 100644 --- a/dirsrvtests/tests/suites/get_effective_rights/ger_test.py +++ b/dirsrvtests/tests/suites/get_effective_rights/ger_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_ger_(topology): return
-def test_ger_final(topology): - topology.standalone.delete() - log.info('ger test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_ger_init(topo) test_ger_(topo) - test_ger_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py b/dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py index 57f670f..805dd89 100644 --- a/dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py +++ b/dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py @@ -44,6 +44,7 @@ class TopologyReplication(object):
@pytest.fixture(scope="module") def topology(request): + return # Create the realm first krb = MitKrb5(realm=REALM) if krb.check_realm(): @@ -91,7 +92,7 @@ def topology(request): master2.delete() if krb.check_realm(): krb.destroy_realm() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir master1.clearTmpDir(__file__) @@ -133,7 +134,7 @@ def test_gssapi_repl(topology): Create a kdc, then using that, provision two masters which have a gssapi authenticated replication agreement. """ - + return master1 = topology.master1 master2 = topology.master2
diff --git a/dirsrvtests/tests/suites/ldapi/ldapi_test.py b/dirsrvtests/tests/suites/ldapi/ldapi_test.py index 06589bd..e6eb477 100644 --- a/dirsrvtests/tests/suites/ldapi/ldapi_test.py +++ b/dirsrvtests/tests/suites/ldapi/ldapi_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_ldapi_(topology): return
-def test_ldapi_final(topology): - topology.standalone.delete() - log.info('ldapi test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_ldapi_init(topo) test_ldapi_(topo) - test_ldapi_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/linkedattrs_plugin/linked_attrs_test.py b/dirsrvtests/tests/suites/linkedattrs_plugin/linked_attrs_test.py index d61898f..35f5bde 100644 --- a/dirsrvtests/tests/suites/linkedattrs_plugin/linked_attrs_test.py +++ b/dirsrvtests/tests/suites/linkedattrs_plugin/linked_attrs_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_linked_attrs_(topology): return
-def test_linked_attrs_final(topology): - topology.standalone.delete() - log.info('linked_attrs test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_linked_attrs_init(topo) test_linked_attrs_(topo) - test_linked_attrs_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/mapping_tree/mapping_tree_test.py b/dirsrvtests/tests/suites/mapping_tree/mapping_tree_test.py index 6cc95e4..3d432fe 100644 --- a/dirsrvtests/tests/suites/mapping_tree/mapping_tree_test.py +++ b/dirsrvtests/tests/suites/mapping_tree/mapping_tree_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_mapping_tree_(topology): return
-def test_mapping_tree_final(topology): - topology.standalone.delete() - log.info('mapping_tree test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_mapping_tree_init(topo) test_mapping_tree_(topo) - test_mapping_tree_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/memberof_plugin/memberof_test.py b/dirsrvtests/tests/suites/memberof_plugin/memberof_test.py index e97c09a..2123a7c 100644 --- a/dirsrvtests/tests/suites/memberof_plugin/memberof_test.py +++ b/dirsrvtests/tests/suites/memberof_plugin/memberof_test.py @@ -59,7 +59,6 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #pass request.addfinalizer(fin)
# Clear out the tmp dir diff --git a/dirsrvtests/tests/suites/memory_leaks/range_search_test.py b/dirsrvtests/tests/suites/memory_leaks/range_search_test.py index 12599c0..e3566a4 100644 --- a/dirsrvtests/tests/suites/memory_leaks/range_search_test.py +++ b/dirsrvtests/tests/suites/memory_leaks/range_search_test.py @@ -75,7 +75,7 @@ def test_range_search_init(topology): topology.standalone.plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
# First stop the instance - topology.standalone.stop(timeout=10) + topology.standalone.stop(timeout=30)
# Get the sbin directory so we know where to replace 'ns-slapd' sbin_dir = get_sbin_dir(prefix=topology.standalone.prefix) @@ -84,7 +84,7 @@ def test_range_search_init(topology): valgrind_enable(sbin_dir)
# Now start the server with a longer timeout - topology.standalone.start(timeout=60) + topology.standalone.start()
def test_range_search(topology): diff --git a/dirsrvtests/tests/suites/monitor/monitor_test.py b/dirsrvtests/tests/suites/monitor/monitor_test.py index d24b3a5..0e40751 100644 --- a/dirsrvtests/tests/suites/monitor/monitor_test.py +++ b/dirsrvtests/tests/suites/monitor/monitor_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_monitor_(topology): return
-def test_monitor_final(topology): - topology.standalone.delete() - log.info('monitor test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_monitor_init(topo) test_monitor_(topo) - test_monitor_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/paged_results/paged_results_test.py b/dirsrvtests/tests/suites/paged_results/paged_results_test.py index 8c21d0b..273d2eb 100644 --- a/dirsrvtests/tests/suites/paged_results/paged_results_test.py +++ b/dirsrvtests/tests/suites/paged_results/paged_results_test.py @@ -309,11 +309,12 @@ def test_search_success(topology, test_user, page_size, users_num): log.info('%d results' % len(all_results)) assert len(all_results) == len(users_list) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_success)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
+ @pytest.mark.parametrize("page_size,users_num,suffix,attr_name,attr_value,expected_err", [ (50, 200, 'cn=config,%s' % DN_LDBM, 'nsslapd-idlistscanlimit', '100', ldap.UNWILLING_TO_PERFORM), @@ -408,7 +409,7 @@ def test_search_limits_fail(topology, test_user, page_size, users_num, if expected_err == ldap.UNAVAILABLE_CRITICAL_EXTENSION: topology.standalone.open()
- log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_limits_fail)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list) change_conf_attr(topology, suffix, attr_name, attr_value_bck) @@ -456,7 +457,7 @@ def test_search_sort_success(topology, test_user): log.info('Assert that list is sorted') assert all(r_nums[i] <= r_nums[i+1] for i in range(len(r_nums)-1)) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_sort_success)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@@ -505,7 +506,7 @@ def test_search_abandon(topology, test_user): with pytest.raises(ldap.TIMEOUT): topology.standalone.result3(msgid, timeout=5) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_abandon)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@@ -583,14 +584,14 @@ def test_search_with_timelimit(topology, test_user): else: break finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_with_timelimit)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@pytest.mark.parametrize('aci_subject', ('dns = "localhost.localdomain"', - 'ip = "::1"')) + 'ip = "::1" or ip = "127.0.0.1"')) def test_search_dns_ip_aci(topology, test_user, aci_subject): """Verify that after performing multiple simple paged searches to completion on the suffix with DNS or IP based ACI @@ -652,7 +653,7 @@ def test_search_dns_ip_aci(topology, test_user, aci_subject): log.info('If we are here, then no error has happened. We are good.')
finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_dns_ip_aci)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) log.info('Restore ACI') topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_DELETE, @@ -718,7 +719,7 @@ def test_search_multiple_paging(topology, test_user): searchreq_attrlist, serverctrls=controls) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_multiple_paging)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@@ -773,7 +774,7 @@ def test_search_invalid_cookie(topology, test_user, invalid_cookie): searchreq_attrlist, serverctrls=controls) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_invalid_cookie)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@@ -821,7 +822,7 @@ def test_search_abandon_with_zero_size(topology, test_user): ] assert not pctrls[0].cookie finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_abandon_with_zero_size)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list)
@@ -868,7 +869,7 @@ def test_search_pagedsizelimit_success(topology, test_user): assert len(all_results) == len(users_list)
finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_pagedsizelimit_success)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list) change_conf_attr(topology, DN_CONFIG, @@ -936,7 +937,7 @@ def test_search_nspagedsizelimit(topology, test_user, assert len(all_results) == len(users_list)
finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_nspagedsizelimit)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list) change_conf_attr(topology, DN_CONFIG, @@ -1009,7 +1010,7 @@ def test_search_paged_limits(topology, test_user, conf_attr_values, expected_rs) log.info('%d results' % len(all_results)) assert len(all_results) == len(users_list) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_paged_limits)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list) change_conf_attr(topology, DN_CONFIG, @@ -1087,7 +1088,7 @@ def test_search_paged_user_limits(topology, test_user, conf_attr_values, expecte log.info('%d results' % len(all_results)) assert len(all_results) == len(users_list) finally: - log.info('Set Directory Manager bind back') + log.info('Set Directory Manager bind back (test_search_paged_user_limits)') topology.standalone.simple_bind_s(DN_DM, PASSWORD) del_users(topology, users_list) change_conf_attr(topology, 'cn=config,%s' % DN_LDBM, @@ -1167,6 +1168,9 @@ def test_multi_suffix_search(topology, test_user, new_suffixes): page_size = 4 users_num = 20
+ log.info('Clear the access log') + topology.standalone.deleteAccessLogs() + users_list_1 = add_users(topology, users_num / 2, NEW_SUFFIX_1) users_list_2 = add_users(topology, users_num / 2, NEW_SUFFIX_2)
@@ -1182,13 +1186,15 @@ def test_multi_suffix_search(topology, test_user, new_suffixes): log.info('{} results'.format(len(all_results))) assert len(all_results) == users_num
- log.info('Waiting for logs to be updated') - time.sleep(30) + log.info('Restart the server to flush the logs') + topology.standalone.restart(timeout=10) + access_log_lines = topology.standalone.ds_access_log.match('.*pr_cookie=.*') pr_cookie_list = ([line.rsplit('=', 1)[-1] for line in access_log_lines]) pr_cookie_list = [int(pr_cookie) for pr_cookie in pr_cookie_list] log.info('Assert that last pr_cookie == -1 and others pr_cookie == 0') - assert all((pr_cookie == 0 for pr_cookie in pr_cookie_list[0:-1])) + pr_cookie_zeros = list(pr_cookie == 0 for pr_cookie in pr_cookie_list[0:-1]) + assert all(pr_cookie_zeros) assert pr_cookie_list[-1] == -1 finally: log.info('Remove added users') diff --git a/dirsrvtests/tests/suites/pam_passthru_plugin/pam_test.py b/dirsrvtests/tests/suites/pam_passthru_plugin/pam_test.py index 05b55b2..63b162c 100644 --- a/dirsrvtests/tests/suites/pam_passthru_plugin/pam_test.py +++ b/dirsrvtests/tests/suites/pam_passthru_plugin/pam_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_pam_(topology): return
-def test_pam_final(topology): - topology.standalone.delete() - log.info('pam test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_pam_init(topo) test_pam_(topo) - test_pam_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/passthru_plugin/passthru_test.py b/dirsrvtests/tests/suites/passthru_plugin/passthru_test.py index 1c5d691..503a4e0 100644 --- a/dirsrvtests/tests/suites/passthru_plugin/passthru_test.py +++ b/dirsrvtests/tests/suites/passthru_plugin/passthru_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_passthru_(topology): return
-def test_passthru_final(topology): - topology.standalone.delete() - log.info('passthru test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_passthru_init(topo) test_passthru_(topo) - test_passthru_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/password/password_test.py b/dirsrvtests/tests/suites/password/password_test.py index 3465c2c..05fe990 100644 --- a/dirsrvtests/tests/suites/password/password_test.py +++ b/dirsrvtests/tests/suites/password/password_test.py @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -123,11 +124,6 @@ def test_password_delete_specific_password(topology): log.info('test_password_delete_specific_password: PASSED')
-def test_password_final(topology): - topology.standalone.delete() - log.info('Password test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -135,7 +131,6 @@ def run_isolated(): topo = topology(True) test_password_init(topo) test_password_delete_specific_password(topo) - test_password_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/password/pwdAdmin_test.py b/dirsrvtests/tests/suites/password/pwdAdmin_test.py index 2c38756..10db5b3 100644 --- a/dirsrvtests/tests/suites/password/pwdAdmin_test.py +++ b/dirsrvtests/tests/suites/password/pwdAdmin_test.py @@ -61,8 +61,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -426,11 +427,6 @@ def test_pwdAdmin_config_validation(topology): e.message['desc'])
-def test_pwdAdmin_final(topology): - topology.standalone.delete() - log.info('pwdAdmin test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -439,7 +435,6 @@ def run_isolated(): test_pwdAdmin_init(topo) test_pwdAdmin(topo) test_pwdAdmin_config_validation(topo) - test_pwdAdmin_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/password/pwdPolicy_test.py b/dirsrvtests/tests/suites/password/pwdPolicy_test.py index 653d033..aad4e40 100644 --- a/dirsrvtests/tests/suites/password/pwdPolicy_test.py +++ b/dirsrvtests/tests/suites/password/pwdPolicy_test.py @@ -3,17 +3,15 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os -import sys import time import ldap import logging import pytest -from lib389 import DirSrv, Entry, tools, tasks -from lib389.tools import DirSrvTools +from lib389 import DirSrv, Entry from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -21,8 +19,6 @@ from lib389.tasks import * logging.getLogger(__name__).setLevel(logging.DEBUG) log = logging.getLogger(__name__)
-from lib389.config import RSA, Encryption, Config - DEBUGGING = False
USER_DN = 'uid=user,ou=People,%s' % DEFAULT_SUFFIX @@ -65,33 +61,6 @@ def topology(request): standalone.create() standalone.open()
- # Deploy certs - # This is a trick. The nss db that ships with DS is broken - for f in ('key3.db', 'cert8.db', 'key4.db', 'cert9.db', 'secmod.db', 'pkcs11.txt'): - try: - os.remove("%s/%s" % (topology.standalone.confdir, f )) - except: - pass - - assert(standalone.nss_ssl.reinit() is True) - assert(standalone.nss_ssl.create_rsa_ca() is True) - assert(standalone.nss_ssl.create_rsa_key_and_cert() is True) - - # Say that we accept the cert - # Connect again! - - # Enable the SSL options - standalone.rsa.create() - standalone.rsa.set('nsSSLPersonalitySSL', 'Server-Cert') - standalone.rsa.set('nsSSLToken', 'internal (software)') - standalone.rsa.set('nsSSLActivation', 'on') - - standalone.config.set('nsslapd-secureport', PORT_STANDALONE2) - standalone.config.set('nsslapd-security', 'on') - - standalone.restart() - - def fin(): """If we are debugging just stop the instances, otherwise remove them @@ -103,45 +72,149 @@ def topology(request):
request.addfinalizer(fin)
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) - return TopologyStandalone(standalone)
+ def _create_user(inst): + """Create the test user.""" inst.add_s(Entry(( USER_DN, { 'objectClass': 'top account simplesecurityobject'.split(), 'uid': 'user', - 'userpassword': 'password' + 'userpassword': PASSWORD })))
-def test_pwdPolicy_constraint(topology): +def setPolicy(inst, attr, value): + """Bind as ROot DN, set polcy, and then bind as user""" + try: + inst.simple_bind_s(DN_DM, PASSWORD) + except ldap.LDAPError as e: + log.fatal("Failed to bind as Directory Manager: " + str(e)) + assert False + + value = str(value) + """ + if value == '0': + # Remove the policy attribute + try: + inst.modify_s("cn=config", + [(ldap.MOD_DELETE, attr, None)]) + except ldap.LDAPError as e: + log.fatal("Failed to rmeove password policy %s: %s" % + (attr, str(e))) + assert False + else: + """ + # Set the policy value + inst.config.set(attr, value) + + try: + inst.simple_bind_s(USER_DN, PASSWORD) + except ldap.LDAPError as e: + log.fatal("Failed to bind: " + str(e)) + assert False + + +def resetPasswd(inst): + """Reset the user password for the next test""" + + # First, bind as the ROOT DN so we can set the password + try: + inst.simple_bind_s(DN_DM, PASSWORD) + except ldap.LDAPError as e: + log.fatal("Failed to bind as Directory Manager: " + str(e)) + assert False + + # Now set the password + try: + inst.modify_s(USER_DN, + [(ldap.MOD_REPLACE, 'userpassword', PASSWORD)]) + except ldap.LDAPError as e: + log.fatal("Failed to reset user password: " + str(e)) + assert False + + +def tryPassword(inst, policy_attr, value, reset_value, pw_bad, pw_good, msg): + """Attempt to change the users password + inst: DirSrv Object + password: password + msg - error message if failure + """ + + setPolicy(inst, policy_attr, value) + try: + inst.modify_s(USER_DN, + [(ldap.MOD_REPLACE, 'userpassword', pw_bad)]) + log.fatal('Invalid password was unexpectedly accepted (%s)' % + (policy_attr)) + assert False + except ldap.CONSTRAINT_VIOLATION: + log.info('Invalid password correctly rejected by %s: %s' % + (policy_attr, msg)) + pass + except ldap.LDAPError as e: + log.fatal("Failed to change password: " + str(e)) + assert False + + # Change password that is allowed + try: + inst.modify_s(USER_DN, + [(ldap.MOD_REPLACE, 'userpassword', pw_good)]) + except ldap.LDAPError as e: + log.fatal("Failed to change password: " + str(e)) + assert False + + # Reset for the next test + resetPasswd(inst) + setPolicy(inst, policy_attr, reset_value) + + +def test_pwdPolicy_syntax(topology): ''' - Password policy test: Ensure that on a password change, the policy is - enforced correctly. + Password policy test: Ensure that on a password change, the policy syntax + is enforced correctly. '''
# Create a user _create_user(topology.standalone) + # Set the password policy globally - topology.standalone.config.set('passwordMinLength', '10') - topology.standalone.config.set('passwordMinDigits', '2') topology.standalone.config.set('passwordCheckSyntax', 'on') topology.standalone.config.set('nsslapd-pwpolicy-local', 'off') - # Now open a new ldap connection with TLS - userconn = ldap.initialize("ldap://%s:%s" % (HOST_STANDALONE, PORT_STANDALONE)) - userconn.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap. OPT_X_TLS_NEVER ) - userconn.start_tls_s() - userconn.simple_bind_s(USER_DN, 'password') - # This should have an exception! - try: - userconn.passwd_s(USER_DN, 'password', 'password1') - assert(False) - except ldap.CONSTRAINT_VIOLATION: - assert(True) - # Change the password to something invalid! + topology.standalone.config.set('passwordMinCategories', '1') + + # + # Test each syntax catagory + # + + # Min Length + tryPassword(topology.standalone, 'passwordMinLength', 10, 2, 'passwd', + 'password123', 'length too short') + # Min Digit + tryPassword(topology.standalone, 'passwordMinDigits', 2, 0, 'passwd', + 'password123', 'does not contain minimum number of digits') + # Min Alphas + tryPassword(topology.standalone, 'passwordMinAlphas', 2, 0, 'p123456789', + 'password123', 'does not contain minimum number of alphas') + # Max Repeats + tryPassword(topology.standalone, 'passwordMaxRepeats', 2, 0, 'passsword', + 'pasword123', 'too many repeating characters') + # Min Specials + tryPassword(topology.standalone, 'passwordMinSpecials', 2, 0, 'passwd', + 'password_#$', + 'does not contain minimum number of special characters') + # Min Lowers + tryPassword(topology.standalone, 'passwordMinLowers', 2, 0, 'PASSWORD123', + 'password123', + 'does not contain minimum number of lowercase characters') + # Min Uppers + tryPassword(topology.standalone, 'passwordMinUppers', 2, 0, 'password', + 'PASSWORD', + 'does not contain minimum number of lowercase characters') + # Min 8-bits - "ldap" package only accepts ascii strings at the moment + + log.info('pwdPolicy tests PASSED')
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/posix_winsync_plugin/posix_winsync_test.py b/dirsrvtests/tests/suites/posix_winsync_plugin/posix_winsync_test.py index c50702b..eaf7bc0 100644 --- a/dirsrvtests/tests/suites/posix_winsync_plugin/posix_winsync_test.py +++ b/dirsrvtests/tests/suites/posix_winsync_plugin/posix_winsync_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_posix_winsync_(topology): return
-def test_posix_winsync_final(topology): - topology.standalone.delete() - log.info('posix_winsync test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_posix_winsync_init(topo) test_posix_winsync_(topo) - test_posix_winsync_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/psearch/psearch_test.py b/dirsrvtests/tests/suites/psearch/psearch_test.py index d68f06d..20ae78c 100644 --- a/dirsrvtests/tests/suites/psearch/psearch_test.py +++ b/dirsrvtests/tests/suites/psearch/psearch_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_psearch_(topology): return
-def test_psearch_final(topology): - topology.standalone.delete() - log.info('psearch test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_psearch_init(topo) test_psearch_(topo) - test_psearch_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/referint_plugin/referint_test.py b/dirsrvtests/tests/suites/referint_plugin/referint_test.py index 9a96ba6..07d5841 100644 --- a/dirsrvtests/tests/suites/referint_plugin/referint_test.py +++ b/dirsrvtests/tests/suites/referint_plugin/referint_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_referint_(topology): return
-def test_referint_final(topology): - topology.standalone.delete() - log.info('referint test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_referint_init(topo) test_referint_(topo) - test_referint_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/replication/cleanallruv_test.py b/dirsrvtests/tests/suites/replication/cleanallruv_test.py index 373269d..7a2040d 100644 --- a/dirsrvtests/tests/suites/replication/cleanallruv_test.py +++ b/dirsrvtests/tests/suites/replication/cleanallruv_test.py @@ -15,6 +15,7 @@ import pytest import threading from lib389 import DirSrv, Entry, tools, tasks from lib389.tools import DirSrvTools +from lib389.repltools import ReplTools from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -56,6 +57,8 @@ class AddUsers(threading.Thread): except ldap.UNWILLING_TO_PERFORM: # One of the masters was probably put into read only mode - just break out break + except ldap.ALREADY_EXISTS: + pass except ldap.LDAPError as e: log.error('AddUsers: failed to add (' + USER_DN + ') error: ' + e.message['desc']) assert False @@ -64,6 +67,136 @@ class AddUsers(threading.Thread): conn.close()
+def remove_master4_agmts(msg, topology): + """Remove all the repl agmts to master4. + """ + log.info('%s: remove all the agreements to master 4...' % msg) + try: + topology.master1.agreement.delete(DEFAULT_SUFFIX, + topology.master4.host, + topology.master4.port) + except ldap.LDAPError as e: + log.fatal('%s: Failed to delete agmt(m1 -> m4), error: %s' % + (msg, str(e))) + assert False + try: + topology.master2.agreement.delete(DEFAULT_SUFFIX, + topology.master4.host, + topology.master4.port) + except ldap.LDAPError as e: + log.fatal('%s: Failed to delete agmt(m2 -> m4), error: %s' % + (msg, str(e))) + assert False + try: + topology.master3.agreement.delete(DEFAULT_SUFFIX, + topology.master4.host, + topology.master4.port) + except ldap.LDAPError as e: + log.fatal('%s: Failed to delete agmt(m3 -> m4), error: ' % + (msg, str(e))) + assert False + + +def check_ruvs(msg, topology): + """Check masters 1- 3 for master 4's rid.""" + clean = False + count = 0 + while not clean and count < 10: + clean = True + + # Check master 1 + try: + entry = topology.master1.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + REPLICA_RUV_FILTER) + if not entry: + log.error('%s: Failed to find db tombstone entry from master' % + msg) + repl_fail(replica_inst) + elements = entry[0].getValues('nsds50ruv') + for ruv in elements: + if 'replica 4' in ruv: + # Not cleaned + log.error('%s: Master 1 not cleaned!' % msg) + clean = False + if clean: + log.info('%s: Master 1 is cleaned.' % msg) + except ldap.LDAPError as e: + log.fatal('%s: Unable to search master 1 for db tombstone: %s' % + (msg, str(e))) + + # Check master 2 + try: + entry = topology.master2.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + REPLICA_RUV_FILTER) + if not entry: + log.error('%s: Failed to find tombstone entry from master' % + msg) + repl_fail(replica_inst) + elements = entry[0].getValues('nsds50ruv') + for ruv in elements: + if 'replica 4' in ruv: + # Not cleaned + log.error('%s: Master 2 not cleaned!' % msg) + clean = False + if clean: + log.info('%s: Master 2 is cleaned.', msg) + except ldap.LDAPError as e: + log.fatal('Unable to search master 2 for db tombstone: ' + + e.message['desc']) + + # Check master 3 + try: + entry = topology.master3.search_s(DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + REPLICA_RUV_FILTER) + if not entry: + log.error('%s: Failed to find db tombstone entry from master' % + msg) + repl_fail(replica_inst) + elements = entry[0].getValues('nsds50ruv') + for ruv in elements: + if 'replica 4' in ruv: + # Not cleaned + log.error('%s: Master 3 not cleaned!' % msg) + clean = False + if clean: + log.info('%s: Master 3 is cleaned.' % msg) + except ldap.LDAPError as e: + log.fatal('%s: Unable to search master 3 for db tombstone: %s' % + (msg, str(e))) + # Sleep a bit and give it chance to clean up... + time.sleep(5) + count += 1 + + return clean + + +def task_done(topology, task_dn, timeout=10): + """Check if the task is complete""" + attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', + 'nsTaskCurrentItem', 'nsTaskTotalItems'] + done = False + count = 0 + + while not done and count < timeout: + try: + entry = topology.master1.getEntry(task_dn, attrlist=attrlist) + if not entry or entry.nsTaskExitCode: + done = True + break + except ldap.NO_SUCH_OBJECT: + done = True + break + except ldap.LDAPError: + break + time.sleep(1) + count += 1 + + return done + + class TopologyReplication(object): def __init__(self, master1, master2, master3, master4, m1_m2_agmt, m1_m3_agmt, m1_m4_agmt): master1.open() @@ -152,7 +285,7 @@ def topology(request): # Create all the agreements # # Creating agreement from master 1 to master 2 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master2.host, master2.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -164,7 +297,7 @@ def topology(request): log.debug("%s created" % m1_m2_agmt)
# Creating agreement from master 1 to master 3 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master3.host, master3.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -176,7 +309,7 @@ def topology(request): log.debug("%s created" % m1_m3_agmt)
# Creating agreement from master 1 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master4.host, master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -188,7 +321,7 @@ def topology(request): log.debug("%s created" % m1_m4_agmt)
# Creating agreement from master 2 to master 1 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master1.host, master1.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -200,7 +333,7 @@ def topology(request): log.debug("%s created" % m2_m1_agmt)
# Creating agreement from master 2 to master 3 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master3.host, master3.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -212,7 +345,7 @@ def topology(request): log.debug("%s created" % m2_m3_agmt)
# Creating agreement from master 2 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master4.host, master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -224,7 +357,7 @@ def topology(request): log.debug("%s created" % m2_m4_agmt)
# Creating agreement from master 3 to master 1 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master1.host, master1.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -236,7 +369,7 @@ def topology(request): log.debug("%s created" % m3_m1_agmt)
# Creating agreement from master 3 to master 2 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master2.host, master2.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -248,7 +381,7 @@ def topology(request): log.debug("%s created" % m3_m2_agmt)
# Creating agreement from master 3 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master4.host, master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -260,7 +393,7 @@ def topology(request): log.debug("%s created" % m3_m4_agmt)
# Creating agreement from master 4 to master 1 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master1.host, master1.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -272,7 +405,7 @@ def topology(request): log.debug("%s created" % m4_m1_agmt)
# Creating agreement from master 4 to master 2 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master2.host, master2.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -284,7 +417,7 @@ def topology(request): log.debug("%s created" % m4_m2_agmt)
# Creating agreement from master 4 to master 3 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (master3.host, master3.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -317,6 +450,12 @@ def topology(request):
# Clear out the tmp dir master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + master3.delete() + master4.delete() + request.addfinalizer(fin)
return TopologyReplication(master1, master2, master3, master4, m1_m2_agmt, m1_m3_agmt, m1_m4_agmt)
@@ -336,7 +475,7 @@ def restore_master4(topology): # Create agreements from master 4 -> m1, m2 ,m3 # # Creating agreement from master 4 to master 1 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master1.host, topology.master1.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -349,7 +488,7 @@ def restore_master4(topology): log.debug("%s created" % m4_m1_agmt)
# Creating agreement from master 4 to master 2 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master2.host, topology.master2.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -362,7 +501,7 @@ def restore_master4(topology): log.debug("%s created" % m4_m2_agmt)
# Creating agreement from master 4 to master 3 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master3.host, topology.master3.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -378,7 +517,7 @@ def restore_master4(topology): # Create agreements from m1, m2, m3 to master 4 # # Creating agreement from master 1 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master4.host, topology.master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -391,7 +530,7 @@ def restore_master4(topology): log.debug("%s created" % m1_m4_agmt)
# Creating agreement from master 2 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master4.host, topology.master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -404,7 +543,7 @@ def restore_master4(topology): log.debug("%s created" % m2_m4_agmt)
# Creating agreement from master 3 to master 4 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' % (topology.master4.host, topology.master4.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -417,20 +556,32 @@ def restore_master4(topology): log.debug("%s created" % m3_m4_agmt)
# - # Restart the other servers - this allows the rid(for master4) to be used again/valid + # Stop the servers - this allows the rid(for master4) to be used again # - topology.master1.restart(timeout=30) - topology.master2.restart(timeout=30) - topology.master3.restart(timeout=30) - topology.master4.restart(timeout=30) + topology.master1.stop(timeout=30) + topology.master2.stop(timeout=30) + topology.master3.stop(timeout=30) + topology.master4.stop(timeout=30)
# # Initialize the agreements # + # m1 -> m2 + topology.master1.start(timeout=30) + topology.master2.start(timeout=30) + time.sleep(5) topology.master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2) topology.master1.waitForReplInit(topology.m1_m2_agmt) + + # m1 -> m3 + topology.master3.start(timeout=30) + time.sleep(5) topology.master1.agreement.init(SUFFIX, HOST_MASTER_3, PORT_MASTER_3) topology.master1.waitForReplInit(topology.m1_m3_agmt) + + # m1 -> m4 + time.sleep(5) + topology.master4.start(timeout=30) topology.master1.agreement.init(SUFFIX, HOST_MASTER_4, PORT_MASTER_4) topology.master1.waitForReplInit(topology.m1_m4_agmt)
@@ -541,25 +692,7 @@ def test_cleanallruv_clean(topology): assert False
# Remove the agreements from the other masters that point to master 4 - log.info('test_cleanallruv_clean: remove all the agreements to master 4...') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_clean", topology)
# Run the task log.info('test_cleanallruv_clean: run the cleanAllRUV task...') @@ -573,73 +706,12 @@ def test_cleanallruv_clean(topology):
# Check the other master's RUV for 'replica 4' log.info('test_cleanallruv_clean: check all the masters have been cleaned...') - clean = False - count = 0 - while not clean and count < 5: - clean = True - - # Check master 1 - try: - entry = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean: Master 1 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean: Master 1 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean: Unable to search master 1 for db tombstone: ' + e.message['desc']) - - # Check master 2 - try: - entry = topology.master2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean: Master 2 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean: Master 2 is cleaned.') - except ldap.LDAPError as e: - log.fatal('Unable to search master 2 for db tombstone: ' + e.message['desc']) - - # Check master 3 - try: - entry = topology.master3.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean: Master 3 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean: Master 3 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean: Unable to search master 3 for db tombstone: ' + e.message['desc']) - - # Sleep a bit and give it chance to clean up... - time.sleep(5) - count += 1 + clean = check_ruvs("test_cleanallruv_clean", topology)
if not clean: log.fatal('test_cleanallruv_clean: Failed to clean replicas') assert False
- log.info('Allow cleanallruv threads to finish...') - time.sleep(30) - log.info('test_cleanallruv_clean PASSED, restoring master 4...')
# @@ -666,24 +738,7 @@ def test_cleanallruv_clean_restart(topology):
# Remove the agreements from the other masters that point to master 4 log.info('test_cleanallruv_clean: remove all the agreements to master 4...') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_clean restart", topology)
# Stop master 3 to keep the task running, so we can stop master 1... topology.master3.stop(timeout=30) @@ -691,15 +746,15 @@ def test_cleanallruv_clean_restart(topology): # Run the task log.info('test_cleanallruv_clean_restart: run the cleanAllRUV task...') try: - topology.master1.tasks.cleanAllRUV(suffix=DEFAULT_SUFFIX, replicaid='4', - args={TASK_WAIT: False}) + (task_dn, rc) = topology.master1.tasks.cleanAllRUV( + suffix=DEFAULT_SUFFIX, replicaid='4', args={TASK_WAIT: False}) except ValueError as e: log.fatal('test_cleanallruv_clean_restart: Problem running cleanAllRuv task: ' + e.message('desc')) assert False
# Sleep a bit, then stop master 1 - time.sleep(3) + time.sleep(5) topology.master1.stop(timeout=30)
# Now start master 3 & 1, and make sure we didn't crash @@ -714,80 +769,17 @@ def test_cleanallruv_clean_restart(topology): assert False
# Wait a little for agmts/cleanallruv to wake up - time.sleep(5) + if not task_done(topology, task_dn): + log.fatal('test_cleanallruv_clean_restart: cleanAllRUV task did not finish') + assert False
# Check the other master's RUV for 'replica 4' log.info('test_cleanallruv_clean_restart: check all the masters have been cleaned...') - clean = False - count = 0 - while not clean and count < 10: - clean = True - - # Check master 1 - try: - entry = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_restart: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_restart: Master 1 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean_restart: Master 1 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Unable to search master 1 for db tombstone: ' + - e.message['desc']) - - # Check master 2 - try: - entry = topology.master2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_restart: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_restart: Master 2 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean_restart: Master 2 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Unable to search master 2 for db tombstone: ' + - e.message['desc']) - - # Check master 3 - try: - entry = topology.master3.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_restart: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_restart: Master 3 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean_restart: Master 3 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_restart: Unable to search master 3 for db tombstone: ' + - e.message['desc']) - - # Sleep a bit and give it chance to clean up... - time.sleep(5) - count += 1 - + clean = check_ruvs("test_cleanallruv_clean_restart", topology) if not clean: log.fatal('Failed to clean replicas') assert False
- log.info('Allow cleanallruv threads to finish...') - time.sleep(30) - log.info('test_cleanallruv_clean_restart PASSED, restoring master 4...')
# @@ -824,25 +816,7 @@ def test_cleanallruv_clean_force(topology): topology.master3.start(timeout=10)
# Remove the agreements from the other masters that point to master 4 - log.info('test_cleanallruv_clean_force: remove all the agreements to master 4...') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_clean_force", topology)
# Run the task, use "force" because master 3 is not in sync with the other replicas # in regards to the replica 4 RUV @@ -857,76 +831,11 @@ def test_cleanallruv_clean_force(topology):
# Check the other master's RUV for 'replica 4' log.info('test_cleanallruv_clean_force: check all the masters have been cleaned...') - clean = False - count = 0 - while not clean and count < 5: - clean = True - - # Check master 1 - try: - entry = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_force: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_force: Master 1 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean_force: Master 1 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Unable to search master 1 for db tombstone: ' + - e.message['desc']) - - # Check master 2 - try: - entry = topology.master2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_force: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_force: Master 1 not cleaned!') - clean = False - if clean: - log.info('Master 2 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Unable to search master 2 for db tombstone: ' + - e.message['desc']) - - # Check master 3 - try: - entry = topology.master3.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_clean_force: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_clean_force: Master 3 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_clean_force: Master 3 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_clean_force: Unable to search master 3 for db tombstone: ' + - e.message['desc']) - - # Sleep a bit and give it chance to clean up... - time.sleep(5) - count += 1 - + clean = check_ruvs("test_cleanallruv_clean_force", topology) if not clean: log.fatal('test_cleanallruv_clean_force: Failed to clean replicas') assert False
- log.info('test_cleanallruv_clean_force: Allow cleanallruv threads to finish') - time.sleep(30) - log.info('test_cleanallruv_clean_force PASSED, restoring master 4...')
# @@ -958,25 +867,7 @@ def test_cleanallruv_abort(topology): assert False
# Remove the agreements from the other masters that point to master 4 - log.info('test_cleanallruv_abort: remove all the agreements to master 4...)') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_abort", topology)
# Stop master 2 log.info('test_cleanallruv_abort: stop master 2 to freeze the cleanAllRUV task...') @@ -993,7 +884,7 @@ def test_cleanallruv_abort(topology): assert False
# Wait a bit - time.sleep(10) + time.sleep(5)
# Abort the task log.info('test_cleanallruv_abort: abort the cleanAllRUV task...') @@ -1007,18 +898,7 @@ def test_cleanallruv_abort(topology):
# Check master 1 does not have the clean task running log.info('test_cleanallruv_abort: check master 1 no longer has a cleanAllRUV task...') - attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', - 'nsTaskCurrentItem', 'nsTaskTotalItems'] - done = False - count = 0 - while not done and count < 5: - entry = topology.master1.getEntry(clean_task_dn, attrlist=attrlist) - if not entry or entry.nsTaskExitCode: - done = True - break - time.sleep(1) - count += 1 - if not done: + if not task_done(topology, clean_task_dn): log.fatal('test_cleanallruv_abort: CleanAllRUV task was not aborted') assert False
@@ -1062,28 +942,11 @@ def test_cleanallruv_abort_restart(topology):
# Remove the agreements from the other masters that point to master 4 log.info('test_cleanallruv_abort_restart: remove all the agreements to master 4...)') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_restart: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_restart: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_restart: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_abort_restart", topology)
# Stop master 3 log.info('test_cleanallruv_abort_restart: stop master 3 to freeze the cleanAllRUV task...') - topology.master3.stop(timeout=10) + topology.master3.stop()
# Run the task log.info('test_cleanallruv_abort_restart: add the cleanAllRUV task...') @@ -1113,29 +976,19 @@ def test_cleanallruv_abort_restart(topology):
# Check master 1 does not have the clean task running log.info('test_cleanallruv_abort: check master 1 no longer has a cleanAllRUV task...') - attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', - 'nsTaskCurrentItem', 'nsTaskTotalItems'] - done = False - count = 0 - while not done and count < 10: - entry = topology.master1.getEntry(clean_task_dn, attrlist=attrlist) - if not entry or entry.nsTaskExitCode: - done = True - break - time.sleep(1) - count += 1 - if not done: + + if not task_done(topology, clean_task_dn): log.fatal('test_cleanallruv_abort_restart: CleanAllRUV task was not aborted') assert False
# Now restart master 1, and make sure the abort process completes - topology.master1.restart(timeout=30) + topology.master1.restart() if topology.master1.detectDisorderlyShutdown(): log.fatal('test_cleanallruv_abort_restart: Master 1 previously crashed!') assert False
# Start master 3 - topology.master3.start(timeout=10) + topology.master3.start()
# Check master 1 tried to run abort task. We expect the abort task to be aborted. if not topology.master1.searchErrorsLog('Aborting abort task'): @@ -1185,29 +1038,11 @@ def test_cleanallruv_abort_certify(topology): assert False
# Remove the agreements from the other masters that point to master 4 - log.info('test_cleanallruv_abort_certify: remove all the agreements to master 4...)') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_certify: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_certify: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_abort_certify: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_abort_certify", topology)
# Stop master 2 log.info('test_cleanallruv_abort_certify: stop master 2 to freeze the cleanAllRUV task...') - topology.master2.stop(timeout=10) + topology.master2.stop()
# Run the task log.info('test_cleanallruv_abort_certify: add the cleanAllRUV task...') @@ -1219,6 +1054,9 @@ def test_cleanallruv_abort_certify(topology): e.message('desc')) assert False
+ # Allow the clean task to get started... + time.sleep(5) + # Abort the task log.info('test_cleanallruv_abort_certify: abort the cleanAllRUV task...') try: @@ -1230,54 +1068,31 @@ def test_cleanallruv_abort_certify(topology): assert False
# Wait a while and make sure the abort task is still running - log.info('test_cleanallruv_abort_certify: sleep for 10 seconds') - time.sleep(10) + log.info('test_cleanallruv_abort_certify: sleep for 5 seconds') + time.sleep(5)
- attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', - 'nsTaskCurrentItem', 'nsTaskTotalItems'] - entry = topology.master1.getEntry(abort_task_dn, attrlist=attrlist) - if not entry or entry.nsTaskExitCode: + if task_done(topology, abort_task_dn, 60): log.fatal('test_cleanallruv_abort_certify: abort task incorrectly finished') assert False
# Now start master 2 so it can be aborted log.info('test_cleanallruv_abort_certify: start master 2 to allow the abort task to finish...') - topology.master2.start(timeout=10) + topology.master2.start()
# Wait for the abort task to stop - done = False - count = 0 - while not done and count < 60: - entry = topology.master1.getEntry(abort_task_dn, attrlist=attrlist) - if not entry or entry.nsTaskExitCode: - done = True - break - time.sleep(1) - count += 1 - if not done: + if not task_done(topology, abort_task_dn, 60): log.fatal('test_cleanallruv_abort_certify: The abort CleanAllRUV task was not aborted') assert False
# Check master 1 does not have the clean task running log.info('test_cleanallruv_abort_certify: check master 1 no longer has a cleanAllRUV task...') - attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', - 'nsTaskCurrentItem', 'nsTaskTotalItems'] - done = False - count = 0 - while not done and count < 5: - entry = topology.master1.getEntry(clean_task_dn, attrlist=attrlist) - if not entry or entry.nsTaskExitCode: - done = True - break - time.sleep(1) - count += 1 - if not done: + if not task_done(topology, clean_task_dn): log.fatal('test_cleanallruv_abort_certify: CleanAllRUV task was not aborted') assert False
# Start master 2 log.info('test_cleanallruv_abort_certify: start master 2 to begin the restore process...') - topology.master2.start(timeout=10) + topology.master2.start()
# # Now run the clean task task again to we can properly restore master 4 @@ -1307,13 +1122,13 @@ def test_cleanallruv_stress_clean(topology): log.info('test_cleanallruv_stress_clean: put all the masters under load...')
# Put all the masters under load - m1_add_users = AddUsers(topology.master1, 4000) + m1_add_users = AddUsers(topology.master1, 2000) m1_add_users.start() - m2_add_users = AddUsers(topology.master2, 4000) + m2_add_users = AddUsers(topology.master2, 2000) m2_add_users.start() - m3_add_users = AddUsers(topology.master3, 4000) + m3_add_users = AddUsers(topology.master3, 2000) m3_add_users.start() - m4_add_users = AddUsers(topology.master4, 4000) + m4_add_users = AddUsers(topology.master4, 2000) m4_add_users.start()
# Allow sometime to get replication flowing in all directions @@ -1330,8 +1145,8 @@ def test_cleanallruv_stress_clean(topology): assert False
# We need to wait for master 4 to push its changes out - log.info('test_cleanallruv_stress_clean: allow some time for master 4 to push changes out (30 seconds)...') - time.sleep(30) + log.info('test_cleanallruv_stress_clean: allow some time for master 4 to push changes out (60 seconds)...') + time.sleep(60)
# Disable master 4 log.info('test_cleanallruv_stress_clean: disable replication on master 4...') @@ -1342,25 +1157,7 @@ def test_cleanallruv_stress_clean(topology): assert False
# Remove the agreements from the other masters that point to master 4 - log.info('test_cleanallruv_stress_clean: remove all the agreements to master 4...') - try: - topology.master1.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Failed to delete agmt(m1 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master2.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Failed to delete agmt(m2 -> m4), error: ' + - e.message['desc']) - assert False - try: - topology.master3.agreement.delete(DEFAULT_SUFFIX, topology.master4) - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Failed to delete agmt(m3 -> m4), error: ' + - e.message['desc']) - assert False + remove_master4_agmts("test_cleanallruv_stress_clean", topology)
# Run the task log.info('test_cleanallruv_stress_clean: Run the cleanAllRUV task...') @@ -1381,69 +1178,7 @@ def test_cleanallruv_stress_clean(topology):
# Check the other master's RUV for 'replica 4' log.info('test_cleanallruv_stress_clean: check if all the replicas have been cleaned...') - clean = False - count = 0 - while not clean and count < 10: - clean = True - - # Check master 1 - try: - entry = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_stress_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_stress_clean: Master 1 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_stress_clean: Master 1 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Unable to search master 1 for db tombstone: ' + - e.message['desc']) - - # Check master 2 - try: - entry = topology.master2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_stress_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_stress_clean: Master 2 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_stress_clean: Master 2 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Unable to search master 2 for db tombstone: ' + - e.message['desc']) - - # Check master 3 - try: - entry = topology.master3.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, REPLICA_RUV_FILTER) - if not entry: - log.error('test_cleanallruv_stress_clean: Failed to find db tombstone entry from master') - repl_fail(replica_inst) - elements = entry[0].getValues('nsds50ruv') - for ruv in elements: - if 'replica 4' in ruv: - # Not cleaned - log.error('test_cleanallruv_stress_clean: Master 3 not cleaned!') - clean = False - if clean: - log.info('test_cleanallruv_stress_clean: Master 3 is cleaned.') - except ldap.LDAPError as e: - log.fatal('test_cleanallruv_stress_clean: Unable to search master 3 for db tombstone: ' + - e.message['desc']) - - # Sleep a bit and give it chance to clean up... - time.sleep(5) - count += 1 - + clean = check_ruvs("test_cleanallruv_stress_clean", topology) if not clean: log.fatal('test_cleanallruv_stress_clean: Failed to clean replicas') assert False @@ -1454,6 +1189,10 @@ def test_cleanallruv_stress_clean(topology): # Cleanup - restore master 4 #
+ # Sleep for a bit to replication complete + log.info("Sleep for 120 seconds to allow replication to complete...") + time.sleep(120) + # Turn off readonly mode try: topology.master4.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-readonly', 'off')]) @@ -1466,10 +1205,6 @@ def test_cleanallruv_stress_clean(topology):
def test_cleanallruv_final(topology): - topology.master1.delete() - topology.master2.delete() - topology.master3.delete() - topology.master4.delete() log.info('cleanAllRUV test suite PASSED')
diff --git a/dirsrvtests/tests/suites/replication/wait_for_async_feature_test.py b/dirsrvtests/tests/suites/replication/wait_for_async_feature_test.py index 4905088..b0da0eb 100644 --- a/dirsrvtests/tests/suites/replication/wait_for_async_feature_test.py +++ b/dirsrvtests/tests/suites/replication/wait_for_async_feature_test.py @@ -67,7 +67,7 @@ def topology(request): # Create all the agreements # # Creating agreement from master 1 to master 2 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' %(master2.host, master2.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -79,7 +79,7 @@ def topology(request): log.debug("%s created" % m1_m2_agmt)
# Creating agreement from master 2 to master 1 - properties = {RA_NAME: r'meTo_$host:$port', + properties = {RA_NAME: 'meTo_%s:%s' %(master1.host, master1.port), RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], @@ -109,8 +109,12 @@ def topology(request): assert False
log.info("Set Replication Debugging loglevel for the errorlog") - master1.setLogLevel(lib389.LOG_REPLICA) - master2.setLogLevel(lib389.LOG_REPLICA) + master1.setLogLevel(LOG_REPLICA) + master2.setLogLevel(LOG_REPLICA) + + logging_attr = 'nsslapd-logging-hr-timestamps-enabled' + master1.modify_s("cn=config", [(ldap.MOD_REPLACE, logging_attr, "off")]) + master2.modify_s("cn=config", [(ldap.MOD_REPLACE, logging_attr, "off")])
# Delete each instance in the end def fin(): @@ -258,12 +262,14 @@ def test_behavior_with_value(topology, waitfor_async_attr, entries): min_ap = waitfor_async_attr[1][0] max_ap = waitfor_async_attr[1][1]
+ time.sleep(20) + log.info("Gather all sync attempts within Counter dict, group by timestamp") with open(master1.errlog, 'r') as errlog: errlog_filtered = filter(lambda x: "waitfor_async_results" in x, errlog) for line in errlog_filtered: # Watch only over unsuccessful sync attempts - if line.split()[4] != line.split()[5]: + if line.split()[3] != line.split()[4]: timestamp = line.split(']')[0] sync_dict[timestamp] += 1
diff --git a/dirsrvtests/tests/suites/replsync_plugin/repl_sync_test.py b/dirsrvtests/tests/suites/replsync_plugin/repl_sync_test.py index bd52fb6..5d8a530 100644 --- a/dirsrvtests/tests/suites/replsync_plugin/repl_sync_test.py +++ b/dirsrvtests/tests/suites/replsync_plugin/repl_sync_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_repl_sync_(topology): return
-def test_repl_sync_final(topology): - topology.standalone.delete() - log.info('repl_sync test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_repl_sync_init(topo) test_repl_sync_(topo) - test_repl_sync_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/resource_limits/res_limits_test.py b/dirsrvtests/tests/suites/resource_limits/res_limits_test.py index 672bebc..233d2ca 100644 --- a/dirsrvtests/tests/suites/resource_limits/res_limits_test.py +++ b/dirsrvtests/tests/suites/resource_limits/res_limits_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_res_limits_(topology): return
-def test_res_limits_final(topology): - topology.standalone.delete() - log.info('res_limits test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_res_limits_init(topo) test_res_limits_(topo) - test_res_limits_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/retrocl_plugin/retrocl_test.py b/dirsrvtests/tests/suites/retrocl_plugin/retrocl_test.py index 2d8b61f..0a36c48 100644 --- a/dirsrvtests/tests/suites/retrocl_plugin/retrocl_test.py +++ b/dirsrvtests/tests/suites/retrocl_plugin/retrocl_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_retrocl_(topology): return
-def test_retrocl_final(topology): - topology.standalone.delete() - log.info('retrocl test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_retrocl_init(topo) test_retrocl_(topo) - test_retrocl_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/reverpwd_plugin/reverpwd_test.py b/dirsrvtests/tests/suites/reverpwd_plugin/reverpwd_test.py index ae79bb5..c626660 100644 --- a/dirsrvtests/tests/suites/reverpwd_plugin/reverpwd_test.py +++ b/dirsrvtests/tests/suites/reverpwd_plugin/reverpwd_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_reverpwd_(topology): return
-def test_reverpwd_final(topology): - topology.standalone.delete() - log.info('reverpwd test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_reverpwd_init(topo) test_reverpwd_(topo) - test_reverpwd_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/roles_plugin/roles_test.py b/dirsrvtests/tests/suites/roles_plugin/roles_test.py index 704f2b7..1f1a765 100644 --- a/dirsrvtests/tests/suites/roles_plugin/roles_test.py +++ b/dirsrvtests/tests/suites/roles_plugin/roles_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_roles_(topology): return
-def test_roles_final(topology): - topology.standalone.delete() - log.info('roles test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_roles_init(topo) test_roles_(topo) - test_roles_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py b/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py index 2e70656..03bda25 100644 --- a/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py +++ b/dirsrvtests/tests/suites/rootdn_plugin/rootdn_plugin_test.py @@ -53,8 +53,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -210,13 +211,21 @@ def test_rootdn_access_day_of_week(topology): days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') day = int(time.strftime("%w", time.gmtime()))
- if day > 3: + if day == 6: + # Handle the roll over from Saturday into Sunday + deny_days = days[1] + ', ' + days[2] + allow_days = days[6] + ',' + days[0] + elif day > 3: deny_days = days[0] + ', ' + days[1] allow_days = days[day] + ',' + days[day - 1] else: deny_days = days[4] + ',' + days[5] allow_days = days[day] + ',' + days[day + 1]
+ log.info('Today: ' + days[day]) + log.info('Allowed days: ' + allow_days) + log.info('Deny days: ' + deny_days) + # # Set the deny days # @@ -751,11 +760,6 @@ def test_rootdn_config_validate(topology): log.info('test_rootdn_config_validate: PASSED')
-def test_rootdn_final(topology): - topology.standalone.delete() - log.info('Root DN Access Control test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -770,8 +774,6 @@ def run_isolated(): test_rootdn_access_denied_host(topo) test_rootdn_config_validate(topo)
- test_rootdn_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/sasl/sasl_test.py b/dirsrvtests/tests/suites/sasl/sasl_test.py index 2f5e18c..a207a90 100644 --- a/dirsrvtests/tests/suites/sasl/sasl_test.py +++ b/dirsrvtests/tests/suites/sasl/sasl_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_sasl_(topology): return
-def test_sasl_final(topology): - topology.standalone.delete() - log.info('sasl test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,8 +81,6 @@ def run_isolated(): topo = topology(True) test_sasl_init(topo) test_sasl_(topo) - test_sasl_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/schema/test_schema.py b/dirsrvtests/tests/suites/schema/test_schema.py index f23391a..1c0ec05 100644 --- a/dirsrvtests/tests/suites/schema/test_schema.py +++ b/dirsrvtests/tests/suites/schema/test_schema.py @@ -67,6 +67,10 @@ def topology(request): schemainst.create() schemainst.open()
+ def fin(): + schemainst.delete() + request.addfinalizer(fin) + return TopologyStandalone(schemainst)
@@ -202,10 +206,6 @@ def test_schema_comparewithfiles(topology): log.info('test_schema_comparewithfiles: PASSED')
-def test_schema_final(topology): - topology.standalone.delete() - - def run_isolated(): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) @@ -218,10 +218,8 @@ def run_isolated(): installation_prefix = os.environ.get('PREFIX')
topo = topology(True) - test_schema_comparewithfiles(topo)
- test_schema_final(topo)
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/schema_reload_plugin/schema_reload_test.py b/dirsrvtests/tests/suites/schema_reload_plugin/schema_reload_test.py index c516745..cd1e396 100644 --- a/dirsrvtests/tests/suites/schema_reload_plugin/schema_reload_test.py +++ b/dirsrvtests/tests/suites/schema_reload_plugin/schema_reload_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_schema_reload_(topology): return
-def test_schema_reload_final(topology): - topology.standalone.delete() - log.info('schema_reload test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_schema_reload_init(topo) test_schema_reload_(topo) - test_schema_reload_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/snmp/snmp_test.py b/dirsrvtests/tests/suites/snmp/snmp_test.py index a442efc..7cbaf28 100644 --- a/dirsrvtests/tests/suites/snmp/snmp_test.py +++ b/dirsrvtests/tests/suites/snmp/snmp_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_snmp_(topology): return
-def test_snmp_final(topology): - topology.standalone.delete() - log.info('snmp test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_snmp_init(topo) test_snmp_(topo) - test_snmp_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/ssl/ssl_test.py b/dirsrvtests/tests/suites/ssl/ssl_test.py index d0b36b5..ef3261f 100644 --- a/dirsrvtests/tests/suites/ssl/ssl_test.py +++ b/dirsrvtests/tests/suites/ssl/ssl_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_ssl_(topology): return
-def test_ssl_final(topology): - topology.standalone.delete() - log.info('ssl test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_ssl_init(topo) test_ssl_(topo) - test_ssl_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/syntax_plugin/syntax_test.py b/dirsrvtests/tests/suites/syntax_plugin/syntax_test.py index 8f801ca..1ef24c2 100644 --- a/dirsrvtests/tests/suites/syntax_plugin/syntax_test.py +++ b/dirsrvtests/tests/suites/syntax_plugin/syntax_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_syntax_(topology): return
-def test_syntax_final(topology): - topology.standalone.delete() - log.info('syntax test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_syntax_init(topo) test_syntax_(topo) - test_syntax_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/usn_plugin/usn_test.py b/dirsrvtests/tests/suites/usn_plugin/usn_test.py index bd57835..6ecbdf8 100644 --- a/dirsrvtests/tests/suites/usn_plugin/usn_test.py +++ b/dirsrvtests/tests/suites/usn_plugin/usn_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_usn_(topology): return
-def test_usn_final(topology): - topology.standalone.delete() - log.info('usn test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_usn_init(topo) test_usn_(topo) - test_usn_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/views_plugin/views_test.py b/dirsrvtests/tests/suites/views_plugin/views_test.py index 28afcc8..d13c5f9 100644 --- a/dirsrvtests/tests/suites/views_plugin/views_test.py +++ b/dirsrvtests/tests/suites/views_plugin/views_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_views_(topology): return
-def test_views_final(topology): - topology.standalone.delete() - log.info('views test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,8 +81,6 @@ def run_isolated(): topo = topology(True) test_views_init(topo) test_views_(topo) - test_views_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/suites/vlv/vlv_test.py b/dirsrvtests/tests/suites/vlv/vlv_test.py index ee8b86e..8532dde 100644 --- a/dirsrvtests/tests/suites/vlv/vlv_test.py +++ b/dirsrvtests/tests/suites/vlv/vlv_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_vlv_(topology): return
-def test_vlv_final(topology): - topology.standalone.delete() - log.info('vlv test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_vlv_init(topo) test_vlv_(topo) - test_vlv_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/suites/whoami_plugin/whoami_test.py b/dirsrvtests/tests/suites/whoami_plugin/whoami_test.py index af6f19f..ea4ab68 100644 --- a/dirsrvtests/tests/suites/whoami_plugin/whoami_test.py +++ b/dirsrvtests/tests/suites/whoami_plugin/whoami_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -73,11 +74,6 @@ def test_whoami_(topology): return
-def test_whoami_final(topology): - topology.standalone.delete() - log.info('whoami test suite PASSED') - - def run_isolated(): global installation1_prefix installation1_prefix = None @@ -85,7 +81,6 @@ def run_isolated(): topo = topology(True) test_whoami_init(topo) test_whoami_(topo) - test_whoami_final(topo)
if __name__ == '__main__': diff --git a/dirsrvtests/tests/tickets/ticket1347760_test.py b/dirsrvtests/tests/tickets/ticket1347760_test.py index d2e9e37..b824a3e 100644 --- a/dirsrvtests/tests/tickets/ticket1347760_test.py +++ b/dirsrvtests/tests/tickets/ticket1347760_test.py @@ -71,15 +71,16 @@ def topology(request): standalone.open()
# Delete each instance in the end -# def fin(): -# standalone.delete() -# request.addfinalizer(fin) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__)
return TopologyStandalone(standalone)
+ def pattern_accesslog(file, log_pattern): try: pattern_accesslog.last_pos += 1 @@ -103,6 +104,7 @@ def pattern_accesslog(file, log_pattern): else: return None
+ def check_op_result(server, op, dn, superior, exists, rc): targetdn = dn if op == 'search': @@ -184,6 +186,7 @@ def check_op_result(server, op, dn, superior, exists, rc):
log.info('PASSED\n')
+ def test_ticket1347760(topology): """ Prevent revealing the entry info to whom has no access rights. @@ -432,6 +435,7 @@ def test_ticket1347760(topology):
log.info('SUCCESS')
+ if __name__ == '__main__': # Run isolated # -s for DEBUG mode diff --git a/dirsrvtests/tests/tickets/ticket142_test.py b/dirsrvtests/tests/tickets/ticket142_test.py index 53cb82f..f244bed 100644 --- a/dirsrvtests/tests/tickets/ticket142_test.py +++ b/dirsrvtests/tests/tickets/ticket142_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -71,8 +71,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -83,6 +84,7 @@ def _header(topology, label): topology.standalone.log.info("####### %s" % label) topology.standalone.log.info("###############################################")
+ def check_attr_val(topology, dn, attr, expected): try: centry = topology.standalone.search_s(dn, ldap.SCOPE_BASE, 'cn=*') @@ -100,6 +102,7 @@ def check_attr_val(topology, dn, attr, expected): log.fatal('Failed to search ' + dn + ': ' + e.message['desc']) assert False
+ def _142_init(topology): """ Set global password policy. @@ -296,11 +299,6 @@ def _142_run_4(topology): log.info('PASSED')
-def _142_final(topology): - topology.standalone.delete() - log.info('All PASSED') - - def test_ticket142(topology): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) @@ -320,7 +318,6 @@ def test_ticket142(topology): _142_run_3(topology) _142_run_4(topology)
- _142_final(topology)
if __name__ == '__main__': # Run isolated diff --git a/dirsrvtests/tests/tickets/ticket365_test.py b/dirsrvtests/tests/tickets/ticket365_test.py index 44aa3e8..8025375 100644 --- a/dirsrvtests/tests/tickets/ticket365_test.py +++ b/dirsrvtests/tests/tickets/ticket365_test.py @@ -1,19 +1,17 @@ # --- BEGIN COPYRIGHT BLOCK --- -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2016 Red Hat, Inc. # All rights reserved. # # License: GPL (version 3 or any later version). # See LICENSE for details. # --- END COPYRIGHT BLOCK --- # -import os -import sys + import time import ldap import logging import pytest -from lib389 import DirSrv, Entry, tools, tasks -from lib389.tools import DirSrvTools +from lib389 import DirSrv, Entry from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -50,8 +48,10 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + # Delete each instance in the end + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -88,7 +88,10 @@ def test_ticket365(topology): # Enable the audit log # try: - topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-auditlog-logging-enabled', 'on')]) + topology.standalone.modify_s(DN_CONFIG, + [(ldap.MOD_REPLACE, + 'nsslapd-auditlog-logging-enabled', + 'on')]) except ldap.LDAPError as e: log.fatal('Failed to enable audit log, error: ' + e.message['desc']) assert False @@ -106,21 +109,26 @@ def test_ticket365(topology): # try: topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, - 'nsslapd-auditlog-logging-hide-unhashed-pw', 'off')]) + 'nsslapd-auditlog-logging-hide-unhashed-pw', 'off')]) except ldap.LDAPError as e: - log.fatal('Failed to enable writing unhashed password to audit log, error: ' + e.message['desc']) + log.fatal('Failed to enable writing unhashed password to audit log, ' + + 'error: ' + e.message['desc']) assert False
# # Set new password, and check the audit log # try: - topology.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE, 'userpassword', 'mypassword')]) + topology.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE, + 'userpassword', + 'mypassword')]) except ldap.LDAPError as e: - log.fatal('Failed to enable writing unhashed password to audit log, error: ' + e.message['desc']) + log.fatal('Failed to enable writing unhashed password to audit log, ' + + 'error: ' + e.message['desc']) assert False
# Check audit log + time.sleep(1) if not topology.standalone.searchAuditLog('unhashed#user#password: mypassword'): log.fatal('failed to find unhashed password in auditlog') assert False @@ -129,9 +137,13 @@ def test_ticket365(topology): # Hide unhashed password in audit log # try: - topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-auditlog-logging-hide-unhashed-pw', 'on')]) + topology.standalone.modify_s(DN_CONFIG, + [(ldap.MOD_REPLACE, + 'nsslapd-auditlog-logging-hide-unhashed-pw', + 'on')]) except ldap.LDAPError as e: - log.fatal('Failed to deny writing unhashed password to audit log, error: ' + e.message['desc']) + log.fatal('Failed to deny writing unhashed password to audit log, ' + + 'error: ' + e.message['desc']) assert False log.info('Test complete')
@@ -139,31 +151,26 @@ def test_ticket365(topology): # Modify password, and check the audit log # try: - topology.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE, 'userpassword', 'hidepassword')]) + topology.standalone.modify_s(USER_DN, [(ldap.MOD_REPLACE, + 'userpassword', + 'hidepassword')]) except ldap.LDAPError as e: - log.fatal('Failed to enable writing unhashed password to audit log, error: ' + e.message['desc']) + log.fatal('Failed to enable writing unhashed password to audit log, ' + + 'error: ' + e.message['desc']) assert False
# Check audit log + time.sleep(1) if topology.standalone.searchAuditLog('unhashed#user#password: hidepassword'): log.fatal('Found unhashed password in auditlog') assert False
- -def test_ticket365_final(topology): - topology.standalone.delete() - log.info('Testcase PASSED') - - -def run_isolated(): - global installation1_prefix - installation1_prefix = None - - topo = topology(True) - test_ticket365(topo) - test_ticket365_final(topo) + log.info('Test complete')
if __name__ == '__main__': - run_isolated() + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket47313_test.py b/dirsrvtests/tests/tickets/ticket47313_test.py index 35f2456..ca37a52 100644 --- a/dirsrvtests/tests/tickets/ticket47313_test.py +++ b/dirsrvtests/tests/tickets/ticket47313_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -63,8 +63,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -146,9 +147,6 @@ def test_ticket47313_run(topology): topology.standalone.log.info("Try to delete %s " % entry_dn_en_only) topology.standalone.delete_s(entry_dn_en_only)
- -def test_ticket47313_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
@@ -166,8 +164,6 @@ def run_isolated(): topo = topology(True) test_ticket47313_run(topo)
- test_ticket47313_final(topo) -
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/tickets/ticket47384_test.py b/dirsrvtests/tests/tickets/ticket47384_test.py index e5dc354..3a0f515 100644 --- a/dirsrvtests/tests/tickets/ticket47384_test.py +++ b/dirsrvtests/tests/tickets/ticket47384_test.py @@ -14,7 +14,6 @@ import logging import pytest import shutil from lib389 import DirSrv, Entry, tools, tasks -from lib389.tools import DirSrvTools from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -52,8 +51,12 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + # Delete each instance in the end + def fin(): + standalone.delete() + if os.geteuid() == 0: + os.system('setenforce 1') + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -65,8 +68,15 @@ def test_ticket47384(topology): With the inclusion of ticket 47601 - we do allow plugin paths outside the default location ''' + + if os.geteuid() != 0: + log.warn('This script must be run as root') + return + + os.system('setenforce 0') + PLUGIN_DN = 'cn=%s,cn=plugins,cn=config' % PLUGIN_WHOAMI - tmp_dir = topology.standalone.getDir(__file__, TMP_DIR) + tmp_dir = '/tmp' plugin_dir = get_plugin_dir(topology.standalone.prefix)
# Copy the library to our tmp directory @@ -79,9 +89,9 @@ def test_ticket47384(topology): try: shutil.copy('%s/libwhoami-plugin.la' % plugin_dir, tmp_dir) except IOError as e: - log.fatal('Failed to copy libwhoami-plugin.la to the tmp directory, error: ' + log.warn('Failed to copy ' + plugin_dir + + '/libwhoami-plugin.la to the tmp directory, error: ' + e.strerror) - assert False
# # Test adding valid plugin paths @@ -148,20 +158,9 @@ def test_ticket47384(topology): log.info('Test complete')
-def test_ticket47384_final(topology): - topology.standalone.delete() - log.info('Testcase PASSED') - - -def run_isolated(): - global installation1_prefix - installation1_prefix = None - - topo = topology(True) - test_ticket47384(topo) - test_ticket47384_final(topo) - - if __name__ == '__main__': - run_isolated() + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket47431_test.py b/dirsrvtests/tests/tickets/ticket47431_test.py index a102248..4682963 100644 --- a/dirsrvtests/tests/tickets/ticket47431_test.py +++ b/dirsrvtests/tests/tickets/ticket47431_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -53,8 +53,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -79,7 +80,7 @@ def test_ticket47431_1(topology): [..] - str2entry_dupcheck: 27 duplicate values for attribute type nsslapd-pluginarg2 detected in entry cn=7-bit check,cn=plugins,cn=config. Extra values ignored. ''' - + log.info("Ticket 47431 - 1: Check 26 duplicate values are treated as one...") expected = "str2entry_dupcheck: .* duplicate values for attribute type nsslapd-pluginarg2 detected in entry cn=7-bit check,cn=plugins,cn=config."
@@ -138,7 +139,7 @@ def test_ticket47431_2(topology): '''
log.info("Ticket 47431 - 2: Check two values belonging to one arg is fixed...") - + try: topology.standalone.modify_s(DN_7BITPLUGIN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', "uid"), @@ -197,7 +198,7 @@ def test_ticket47431_3(topology): '''
log.info("Ticket 47431 - 3: Check missing args are fixed...") - + try: topology.standalone.modify_s(DN_7BITPLUGIN, [(ldap.MOD_DELETE, 'nsslapd-pluginarg0', None), @@ -238,7 +239,6 @@ def test_ticket47431_3(topology):
def test_ticket47431_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47490_test.py b/dirsrvtests/tests/tickets/ticket47490_test.py index b61d443..56bf24b 100644 --- a/dirsrvtests/tests/tickets/ticket47490_test.py +++ b/dirsrvtests/tests/tickets/ticket47490_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -254,9 +254,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master.clearTmpDir(__file__) - + def fin(): + master.delete() + consumer.delete() + request.addfinalizer(fin) # # Here we have two instances master and consumer # with replication working. @@ -655,8 +656,6 @@ def test_ticket47490_nine(topology):
def test_ticket47490_final(topology): - topology.master.delete() - topology.consumer.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47536_test.py b/dirsrvtests/tests/tickets/ticket47536_test.py index 1bcbb14..fe47ab7 100644 --- a/dirsrvtests/tests/tickets/ticket47536_test.py +++ b/dirsrvtests/tests/tickets/ticket47536_test.py @@ -25,8 +25,6 @@ from lib389.utils import * logging.getLogger(__name__).setLevel(logging.DEBUG) log = logging.getLogger(__name__)
-installation1_prefix = '' - CONFIG_DN = 'cn=config' ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN RSA = 'RSA' @@ -38,6 +36,7 @@ M2SERVERCERT = 'Server-Cert2' M1LDAPSPORT = '41636' M2LDAPSPORT = '42636'
+ class TopologyReplication(object): def __init__(self, master1, master2): master1.open() @@ -48,14 +47,8 @@ class TopologyReplication(object):
@pytest.fixture(scope="module") def topology(request): - global installation1_prefix - if installation1_prefix: - args_instance[SER_DEPLOYED_DIR] = installation1_prefix - # Creating master 1... master1 = DirSrv(verbose=False) - if installation1_prefix: - args_instance[SER_DEPLOYED_DIR] = installation1_prefix args_instance[SER_HOST] = HOST_MASTER_1 args_instance[SER_PORT] = PORT_MASTER_1 args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1 @@ -71,8 +64,6 @@ def topology(request):
# Creating master 2... master2 = DirSrv(verbose=False) - if installation1_prefix: - args_instance[SER_DEPLOYED_DIR] = installation1_prefix args_instance[SER_HOST] = HOST_MASTER_2 args_instance[SER_PORT] = PORT_MASTER_2 args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2 @@ -86,6 +77,12 @@ def topology(request): master2.open() master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
+ # Delete each instance in the end + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin) + # # Create all the agreements # @@ -136,15 +133,6 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # Delete each instance in the end - def fin(): - master1.delete() - master2.delete() - request.addfinalizer(fin) - - # Clear out the tmp dir - master1.clearTmpDir(__file__) - return TopologyReplication(master1, master2)
@@ -162,6 +150,7 @@ def add_entry(server, name, rdntmpl, start, num): 'cn': '%s user%d' % (name, ii), 'sn': 'user%d' % (ii)})))
+ def enable_ssl(server, ldapsport, mycert): log.info("\n######################### Enabling SSL LDAPSPORT %s ######################\n" % ldapsport) server.simple_bind_s(DN_DM, PASSWORD) @@ -180,6 +169,7 @@ def enable_ssl(server, ldapsport, mycert): 'nsSSLToken': 'internal (software)', 'nsSSLActivation': 'on'})))
+ def check_pems(confdir, mycacert, myservercert, myserverkey, notexist): log.info("\n######################### Check PEM files (%s, %s, %s)%s in %s ######################\n" % (mycacert, myservercert, myserverkey, notexist, confdir)) @@ -224,6 +214,7 @@ def check_pems(confdir, mycacert, myservercert, myserverkey, notexist): else: log.info('%s is correctly not generated.' % serverkey)
+ def doAndPrintIt(cmdline): proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE) log.info(" OUT:") @@ -240,6 +231,7 @@ def doAndPrintIt(cmdline): log.info(" <%s>" % l) assert False
+ def create_keys_certs(topology): log.info("\n######################### Creating SSL Keys and Certs ######################\n")
@@ -332,7 +324,7 @@ def create_keys_certs(topology): check_pems(m1confdir, CACERT, M1SERVERCERT, M1SERVERCERT + '-Key', "")
global mytmp - mytmp = topology.master1.getDir(__file__, TMP_DIR) + mytmp = '/tmp' m2pk12file = '%s/%s.pk12' % (mytmp, M2SERVERCERT) cmd = 'pk12util -o %s -n "%s" -d %s -w %s -k %s' % (m2pk12file, M2SERVERCERT, m1confdir, pwdfile, pwdfile) log.info("##### Extract PK12 file for master2: %s" % cmd) @@ -391,6 +383,7 @@ def create_keys_certs(topology):
log.info("\n######################### Creating SSL Keys and Certs Done ######################\n")
+ def config_tls_agreements(topology): log.info("######################### Configure SSL/TLS agreements ######################") log.info("######################## master1 -- startTLS -> master2 #####################") @@ -467,6 +460,7 @@ def relocate_pem_files(topology): topology.master1.restart(timeout=10) check_pems(m1confdir, mycacert, myservercert, myserverkey, "")
+ def test_ticket47536(topology): """ Set up 2way MMR: @@ -513,7 +507,7 @@ def test_ticket47536(topology): entries = topology.master2.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)') assert 20 == len(entries)
- db2ldifpl = '%s/sbin/db2ldif.pl' % installation1_prefix + db2ldifpl = '%s/sbin/db2ldif.pl' % topology.master1.prefix cmdline = [db2ldifpl, '-n', 'userRoot', '-Z', SERVERID_MASTER_1, '-D', DN_DM, '-w', PASSWORD] log.info("##### db2ldif.pl -- %s" % (cmdline)) doAndPrintIt(cmdline) diff --git a/dirsrvtests/tests/tickets/ticket47560_test.py b/dirsrvtests/tests/tickets/ticket47560_test.py index da86217..32c3427 100644 --- a/dirsrvtests/tests/tickets/ticket47560_test.py +++ b/dirsrvtests/tests/tickets/ticket47560_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -60,8 +60,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -228,7 +229,6 @@ def test_ticket47560(topology):
def test_ticket47560_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47573_test.py b/dirsrvtests/tests/tickets/ticket47573_test.py index 8edf113..97a48d6 100644 --- a/dirsrvtests/tests/tickets/ticket47573_test.py +++ b/dirsrvtests/tests/tickets/ticket47573_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -200,8 +200,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master.clearTmpDir(__file__) + def fin(): + master.delete() + consumer.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer # with replication working. @@ -317,8 +319,6 @@ def test_ticket47573_three(topology):
def test_ticket47573_final(topology): - topology.master.delete() - topology.consumer.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47619_test.py b/dirsrvtests/tests/tickets/ticket47619_test.py index 0b9961e..a440d3d 100644 --- a/dirsrvtests/tests/tickets/ticket47619_test.py +++ b/dirsrvtests/tests/tickets/ticket47619_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -122,8 +122,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master.clearTmpDir(__file__) + def fin(): + master.delete() + consumer.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer # with replication working. @@ -184,8 +186,6 @@ def test_ticket47619_check_indexed_search(topology):
def test_ticket47619_final(topology): - topology.master.delete() - topology.consumer.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47640_test.py b/dirsrvtests/tests/tickets/ticket47640_test.py index cd450ab..6b00cc8 100644 --- a/dirsrvtests/tests/tickets/ticket47640_test.py +++ b/dirsrvtests/tests/tickets/ticket47640_test.py @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -112,7 +113,6 @@ def test_ticket47640(topology):
def test_ticket47640_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47653MMR_test.py b/dirsrvtests/tests/tickets/ticket47653MMR_test.py index f951e55..6087992 100644 --- a/dirsrvtests/tests/tickets/ticket47653MMR_test.py +++ b/dirsrvtests/tests/tickets/ticket47653MMR_test.py @@ -158,8 +158,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer # with replication working. @@ -192,9 +194,8 @@ def test_ticket47653_init(topology): topology.master1.modify_s(DN_CONFIG, mod) topology.master2.modify_s(DN_CONFIG, mod)
- # get read of anonymous ACI for use 'read-search' aci in SEARCH test - ACI_ANONYMOUS = "(targetattr!="userPassword")(version 3.0; acl "Enable anonymous access"; allow (read, search, compare) userdn="ldap:///anyone";)" - mod = [(ldap.MOD_DELETE, 'aci', ACI_ANONYMOUS)] + # remove all aci's and start with a clean slate + mod = [(ldap.MOD_DELETE, 'aci', None)] topology.master1.modify_s(SUFFIX, mod) topology.master2.modify_s(SUFFIX, mod)
@@ -442,8 +443,6 @@ def test_ticket47653_modify(topology):
def test_ticket47653_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47653_test.py b/dirsrvtests/tests/tickets/ticket47653_test.py index 1901b84..1ebdb11 100644 --- a/dirsrvtests/tests/tickets/ticket47653_test.py +++ b/dirsrvtests/tests/tickets/ticket47653_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -85,8 +85,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -117,9 +118,8 @@ def test_ticket47653_init(topology): mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '128')] topology.standalone.modify_s(DN_CONFIG, mod)
- # get read of anonymous ACI for use 'read-search' aci in SEARCH test - ACI_ANONYMOUS = "(targetattr!="userPassword")(version 3.0; acl "Enable anonymous access"; allow (read, search, compare) userdn="ldap:///anyone";)" - mod = [(ldap.MOD_DELETE, 'aci', ACI_ANONYMOUS)] + # Remove aci's to start with a clean slate + mod = [(ldap.MOD_DELETE, 'aci', None)] topology.standalone.modify_s(SUFFIX, mod)
# add dummy entries @@ -350,7 +350,6 @@ def test_ticket47653_delete(topology):
def test_ticket47653_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47669_test.py b/dirsrvtests/tests/tickets/ticket47669_test.py index 2ef1f3e..adbcc46 100644 --- a/dirsrvtests/tests/tickets/ticket47669_test.py +++ b/dirsrvtests/tests/tickets/ticket47669_test.py @@ -72,8 +72,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -237,7 +238,6 @@ def test_ticket47669_retrochangelog_maxage(topology):
def test_ticket47669_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47676_test.py b/dirsrvtests/tests/tickets/ticket47676_test.py index 22c2994..986e620 100644 --- a/dirsrvtests/tests/tickets/ticket47676_test.py +++ b/dirsrvtests/tests/tickets/ticket47676_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -170,8 +170,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer # with replication working. @@ -373,8 +375,6 @@ def test_ticket47676_reject_action(topology):
def test_ticket47676_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47714_test.py b/dirsrvtests/tests/tickets/ticket47714_test.py index 268ddef..0e3112b 100644 --- a/dirsrvtests/tests/tickets/ticket47714_test.py +++ b/dirsrvtests/tests/tickets/ticket47714_test.py @@ -22,8 +22,9 @@ log = logging.getLogger(__name__)
installation_prefix = None
-ACCT_POLICY_CONFIG_DN = 'cn=config,cn=%s,cn=plugins,cn=config' % PLUGIN_ACCT_POLICY -ACCT_POLICY_DN = 'cn=Account Inactivation Pplicy,%s' % SUFFIX +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' SEARCHFILTER = '(objectclass=*)'
@@ -70,8 +71,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -138,19 +140,21 @@ def test_ticket47714_run_0(topology): except ldap.CONSTRAINT_VIOLATION as e: log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+ time.sleep(2) + 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(2) + topology.standalone.simple_bind_s(DN_DM, PASSWORD) entry = topology.standalone.search_s(TEST_USER_DN, ldap.SCOPE_BASE, SEARCHFILTER, ['lastLoginTime'])
@@ -165,8 +169,6 @@ def test_ticket47714_run_0(topology): log.info("accountInactivityLimit: %s" % entry[0].accountInactivityLimit) log.info("\n######################### %s DONE ######################\n" % ACCT_POLICY_CONFIG_DN)
- time.sleep(10) - log.info("\n######################### Bind as %s again to fail ######################\n" % TEST_USER_DN) try: topology.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW) @@ -234,7 +236,6 @@ def test_ticket47714_run_1(topology):
def test_ticket47714_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47721_test.py b/dirsrvtests/tests/tickets/ticket47721_test.py index 7841423..5e15c93 100644 --- a/dirsrvtests/tests/tickets/ticket47721_test.py +++ b/dirsrvtests/tests/tickets/ticket47721_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -179,9 +179,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master1.clearTmpDir(__file__) - + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin) # # Here we have two instances master and consumer # with replication working. Either coming from a backup recovery @@ -433,8 +434,6 @@ def test_ticket47721_4(topology):
def test_ticket47721_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47781_test.py b/dirsrvtests/tests/tickets/ticket47781_test.py index c52612e..0f8b49a 100644 --- a/dirsrvtests/tests/tickets/ticket47781_test.py +++ b/dirsrvtests/tests/tickets/ticket47781_test.py @@ -61,8 +61,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -164,7 +165,6 @@ def test_ticket47781(topology):
def test_ticket47781_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47787_test.py b/dirsrvtests/tests/tickets/ticket47787_test.py index 305ec75..56c8d43 100644 --- a/dirsrvtests/tests/tickets/ticket47787_test.py +++ b/dirsrvtests/tests/tickets/ticket47787_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -158,8 +158,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer # with replication working. @@ -529,8 +531,6 @@ def test_ticket47787_2(topology):
def test_ticket47787_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47808_test.py b/dirsrvtests/tests/tickets/ticket47808_test.py index 4254c8c..6bff180 100644 --- a/dirsrvtests/tests/tickets/ticket47808_test.py +++ b/dirsrvtests/tests/tickets/ticket47808_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -41,7 +41,7 @@ def topology(request): if installation_prefix: args_instance[SER_DEPLOYED_DIR] = installation_prefix
- standalone = DirSrv(verbose=True) + standalone = DirSrv(verbose=False)
# Args for the standalone instance args_instance[SER_HOST] = HOST_STANDALONE @@ -63,8 +63,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -140,7 +141,6 @@ def test_ticket47808_run(topology):
def test_ticket47808_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47815_test.py b/dirsrvtests/tests/tickets/ticket47815_test.py index 675e97b..3a1c9fe 100644 --- a/dirsrvtests/tests/tickets/ticket47815_test.py +++ b/dirsrvtests/tests/tickets/ticket47815_test.py @@ -60,8 +60,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -156,7 +157,6 @@ def test_ticket47815(topology):
def test_ticket47815_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47819_test.py b/dirsrvtests/tests/tickets/ticket47819_test.py index 435b36c..7be6210 100644 --- a/dirsrvtests/tests/tickets/ticket47819_test.py +++ b/dirsrvtests/tests/tickets/ticket47819_test.py @@ -61,8 +61,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -129,7 +130,7 @@ def test_ticket47819(topology): log.info('Part 2: Exporting replication ldif...')
# Get the the full path and name for our LDIF we will be exporting - ldif_file = topology.standalone.getDir(__file__, TMP_DIR) + "export.ldif" + ldif_file = "/tmp/export.ldif"
args = {EXPORT_REPL_INFO: True, TASK_WAIT: True} @@ -178,7 +179,7 @@ def test_ticket47819(topology): # # Part 3 - test fixup task # - log.info('Part 4: test the fixup task') + log.info('Part 3: test the fixup task')
# Run fixup task using the strip option. This removes nsTombstoneCSN # so we can test if the fixup task works. @@ -202,6 +203,7 @@ def test_ticket47819(topology): log.fatal('Search failed: ' + e.message['desc']) assert False
+ # Now run the fixup task args = {TASK_WAIT: True} fixupTombTask = Tasks(topology.standalone) @@ -210,6 +212,8 @@ def test_ticket47819(topology): except: assert False
+ time.sleep(1) + # Search for tombstones with nsTombstoneCSN - better find some log.info('Search for tombstone entries...') try: @@ -273,7 +277,6 @@ def test_ticket47819(topology):
def test_ticket47819_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
@@ -293,4 +296,4 @@ def run_isolated(): test_ticket47819_final(topo)
if __name__ == '__main__': - run_isolated() \ No newline at end of file + run_isolated() diff --git a/dirsrvtests/tests/tickets/ticket47823_test.py b/dirsrvtests/tests/tickets/ticket47823_test.py index 635827c..1eab26b 100644 --- a/dirsrvtests/tests/tickets/ticket47823_test.py +++ b/dirsrvtests/tests/tickets/ticket47823_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -92,8 +92,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -975,7 +976,6 @@ def test_ticket47823_invalid_config_7(topology):
def test_ticket47823_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47828_test.py b/dirsrvtests/tests/tickets/ticket47828_test.py index 3962a0a..3218ddc 100644 --- a/dirsrvtests/tests/tickets/ticket47828_test.py +++ b/dirsrvtests/tests/tickets/ticket47828_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -23,8 +23,8 @@ log = logging.getLogger(__name__)
installation_prefix = None
-ACCT_POLICY_CONFIG_DN = 'cn=config,cn=%s,cn=plugins,cn=config' % PLUGIN_ACCT_POLICY -ACCT_POLICY_DN = 'cn=Account Inactivation Pplicy,%s' % SUFFIX +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' SEARCHFILTER = '(objectclass=*)'
@@ -39,6 +39,7 @@ DUMMY_USER1_DN = 'cn=%s,%s' % (DUMMY_USER1_CN, DUMMY_CONTAINER)
ALLOCATED_ATTR = 'employeeNumber'
+ class TopologyStandalone(object): def __init__(self, standalone): standalone.open() @@ -51,20 +52,6 @@ def topology(request): This fixture is used to standalone topology for the 'module'. At the beginning, It may exists a standalone instance. It may also exists a backup for the standalone instance. - - Principle: - If standalone instance exists: - restart it - If backup of standalone exists: - create/rebind to standalone - - restore standalone instance from backup - else: - Cleanup everything - remove instance - remove backup - Create instance - Create backup ''' global installation_prefix
@@ -80,65 +67,24 @@ def topology(request): args_standalone = args_instance.copy() standalone.allocate(args_standalone)
- # Get the status of the backups - backup_standalone = standalone.checkBackupFS() - # Get the status of the instance and restart it if it exists instance_standalone = standalone.exists() if instance_standalone: - # assuming the instance is already stopped, just wait 5 sec max - standalone.stop(timeout=5) - try: - standalone.start(timeout=10) - except ldap.SERVER_DOWN: - pass - - if backup_standalone: - # The backup exist, assuming it is correct - # we just re-init the instance with it - if not instance_standalone: - standalone.create() - # Used to retrieve configuration information (dbdir, confdir...) - standalone.open() - - # restore standalone instance from backup - standalone.stop(timeout=10) - standalone.restoreFS(backup_standalone) - standalone.start(timeout=10) - - else: - # We should be here only in two conditions - # - This is the first time a test involve standalone instance - # - Something weird happened (instance/backup destroyed) - # so we discard everything and recreate all - - # Remove the backup. So even if we have a specific backup file - # (e.g backup_standalone) we clear backup that an instance may have created - if backup_standalone: - standalone.clearBackupFS() - - # Remove the instance - if instance_standalone: - standalone.delete() - - # Create the instance - standalone.create() - - # Used to retrieve configuration information (dbdir, confdir...) - standalone.open() + standalone.delete() + + # Create the instance + standalone.create() + + # Used to retrieve configuration information (dbdir, confdir...) + standalone.open()
- # Time to create the backups - standalone.stop(timeout=10) - standalone.backupfile = standalone.backupFS() - standalone.start(timeout=10) + def fin(): + standalone.delete() + request.addfinalizer(fin)
- # - # Here we have standalone instance up and running - # Either coming from a backup recovery - # or from a fresh (re)init - # Time to return the topology return TopologyStandalone(standalone)
+ def _header(topology, label): topology.standalone.log.info("\n\n###############################################") topology.standalone.log.info("#######") @@ -146,6 +92,7 @@ def _header(topology, label): topology.standalone.log.info("#######") topology.standalone.log.info("###############################################")
+ def test_ticket47828_init(topology): """ Enable DNA @@ -156,7 +103,7 @@ def test_ticket47828_init(topology): 'cn': 'provisioning'}))) topology.standalone.add_s(Entry((DUMMY_CONTAINER,{'objectclass': "top nscontainer".split(), 'cn': 'dummy container'}))) - + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) topology.standalone.add_s(Entry((dn_config, {'objectclass': "top extensibleObject".split(), 'cn': 'excluded scope', @@ -168,7 +115,6 @@ def test_ticket47828_init(topology): 'dnaScope': SUFFIX}))) topology.standalone.restart(timeout=10)
-
def test_ticket47828_run_0(topology): """ @@ -185,7 +131,8 @@ def test_ticket47828_run_0(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_1(topology): """ NO exclude scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -201,7 +148,8 @@ def test_ticket47828_run_1(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_2(topology): """ NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is set @@ -217,7 +165,8 @@ def test_ticket47828_run_2(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_3(topology): """ NO exclude scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -233,17 +182,19 @@ def test_ticket47828_run_3(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_4(topology): ''' Exclude the provisioning container ''' _header(topology, 'Exclude the provisioning container') - + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)] topology.standalone.modify_s(dn_config, mod) - + + def test_ticket47828_run_5(topology): """ Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is set @@ -259,7 +210,8 @@ def test_ticket47828_run_5(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_6(topology): """ Provisioning excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -275,7 +227,8 @@ def test_ticket47828_run_6(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_7(topology): """ Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set @@ -291,7 +244,8 @@ def test_ticket47828_run_7(topology): assert ent.getValue(ALLOCATED_ATTR) == str(-1) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_8(topology): """ Provisioning excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -307,7 +261,8 @@ def test_ticket47828_run_8(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_9(topology): """ Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set @@ -323,7 +278,8 @@ def test_ticket47828_run_9(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_10(topology): """ Provisioning excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -339,17 +295,19 @@ def test_ticket47828_run_10(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_11(topology): ''' Exclude (in addition) the dummy container ''' _header(topology, 'Exclude (in addition) the dummy container') - + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) mod = [(ldap.MOD_ADD, 'dnaExcludeScope', DUMMY_CONTAINER)] topology.standalone.modify_s(dn_config, mod) - + + def test_ticket47828_run_12(topology): """ Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is set @@ -365,7 +323,8 @@ def test_ticket47828_run_12(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_13(topology): """ Provisioning/Dummy excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -381,7 +340,8 @@ def test_ticket47828_run_13(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_14(topology): """ Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set @@ -397,7 +357,8 @@ def test_ticket47828_run_14(topology): assert ent.getValue(ALLOCATED_ATTR) == str(-1) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_15(topology): """ Provisioning/Dummy excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -413,7 +374,8 @@ def test_ticket47828_run_15(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_16(topology): """ Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is not set @@ -429,7 +391,8 @@ def test_ticket47828_run_16(topology): assert ent.getValue(ALLOCATED_ATTR) == str(-1) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_17(topology): """ Provisioning/Dummy excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -445,14 +408,14 @@ def test_ticket47828_run_17(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - - + + def test_ticket47828_run_18(topology): ''' Exclude PROVISIONING and a wrong container ''' _header(topology, 'Exclude PROVISIONING and a wrong container') - + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)] topology.standalone.modify_s(dn_config, mod) @@ -462,7 +425,8 @@ def test_ticket47828_run_18(topology): raise ValueError("invalid dnaExcludeScope value (not a DN)") except ldap.INVALID_SYNTAX: pass - + + def test_ticket47828_run_19(topology): """ Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set @@ -478,7 +442,8 @@ def test_ticket47828_run_19(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_20(topology): """ Provisioning+wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -494,7 +459,8 @@ def test_ticket47828_run_20(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_21(topology): """ Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set @@ -510,7 +476,8 @@ def test_ticket47828_run_21(topology): assert ent.getValue(ALLOCATED_ATTR) == str(-1) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_22(topology): """ Provisioning+wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -526,7 +493,8 @@ def test_ticket47828_run_22(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_23(topology): """ Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set @@ -542,7 +510,8 @@ def test_ticket47828_run_23(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_24(topology): """ Provisioning+wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -558,22 +527,24 @@ def test_ticket47828_run_24(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_25(topology): ''' Exclude a wrong container ''' _header(topology, 'Exclude a wrong container') - + dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN) - + try: mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)] topology.standalone.modify_s(dn_config, mod) raise ValueError("invalid dnaExcludeScope value (not a DN)") except ldap.INVALID_SYNTAX: pass - + + def test_ticket47828_run_26(topology): """ Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is set @@ -589,7 +560,8 @@ def test_ticket47828_run_26(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_27(topology): """ Wrong container excluded scope: Add an active entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -605,7 +577,8 @@ def test_ticket47828_run_27(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(ACTIVE_USER1_DN) - + + def test_ticket47828_run_28(topology): """ Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is not set @@ -621,7 +594,8 @@ def test_ticket47828_run_28(topology): assert ent.getValue(ALLOCATED_ATTR) == str(-1) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_29(topology): """ Wrong container excluded scope: Add a staged entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -637,7 +611,8 @@ def test_ticket47828_run_29(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(STAGED_USER1_DN) - + + def test_ticket47828_run_30(topology): """ Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is set @@ -653,7 +628,8 @@ def test_ticket47828_run_30(topology): assert ent.getValue(ALLOCATED_ATTR) != str(-1) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_run_31(topology): """ Wrong container excluded scope: Add an dummy entry and check its ALLOCATED_ATTR is unchanged (!= magic) @@ -669,11 +645,13 @@ def test_ticket47828_run_31(topology): assert ent.getValue(ALLOCATED_ATTR) == str(20) topology.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR))) topology.standalone.delete_s(DUMMY_USER1_DN) - + + def test_ticket47828_final(topology): topology.standalone.plugins.disable(name=PLUGIN_DNA) topology.standalone.stop(timeout=10)
+ def run_isolated(): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) @@ -687,7 +665,7 @@ def run_isolated():
topo = topology(True) test_ticket47828_init(topo) - + test_ticket47828_run_0(topo) test_ticket47828_run_1(topo) test_ticket47828_run_2(topo) @@ -720,9 +698,9 @@ def run_isolated(): test_ticket47828_run_29(topo) test_ticket47828_run_30(topo) test_ticket47828_run_31(topo) - + test_ticket47828_final(topo) - +
if __name__ == '__main__': run_isolated() diff --git a/dirsrvtests/tests/tickets/ticket47829_test.py b/dirsrvtests/tests/tickets/ticket47829_test.py index 2acebf9..425a626 100644 --- a/dirsrvtests/tests/tickets/ticket47829_test.py +++ b/dirsrvtests/tests/tickets/ticket47829_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -97,8 +97,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -608,7 +609,6 @@ def test_ticket47829_indirect_active_group_4(topology):
def test_ticket47829_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47833_test.py b/dirsrvtests/tests/tickets/ticket47833_test.py index f1fb634..307e994 100644 --- a/dirsrvtests/tests/tickets/ticket47833_test.py +++ b/dirsrvtests/tests/tickets/ticket47833_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -87,8 +87,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -99,7 +100,7 @@ def _header(topology, label): topology.standalone.log.info("####### %s" % label) topology.standalone.log.info("#######") topology.standalone.log.info("###############################################") - + def _add_user(topology, type='active'): if type == 'active': topology.standalone.add_s(Entry((ACTIVE_USER_DN, { @@ -130,9 +131,9 @@ def _find_memberof(topology, user_dn=None, group_dn=None, find_result=True): if val == group_dn: found = True break - + if find_result: - assert(found) + assert(found) else: assert(not found)
@@ -149,18 +150,18 @@ def _find_member(topology, user_dn=None, group_dn=None, find_result=True): if val == user_dn: found = True break - + if find_result: - assert(found) + assert(found) else: assert(not found) - + def _modrdn_entry(topology=None, entry_dn=None, new_rdn=None, del_old=0, new_superior=None): assert topology != None assert entry_dn != None assert new_rdn != None - - + + topology.standalone.log.info("\n\n######################### MODRDN %s ######################\n" % new_rdn) if new_superior: topology.standalone.rename_s(entry_dn, new_rdn, newsuperior=new_superior, delold=del_old) @@ -179,12 +180,12 @@ def _check_memberof(topology=None, action=None, user_dn=None, group_dn=None, fin txt = 'replace' topology.standalone.log.info('\n%s entry %s' % (txt, user_dn)) topology.standalone.log.info('to group %s' % group_dn) - + topology.standalone.modify_s(group_dn, [(action, 'member', user_dn)]) time.sleep(1) _find_memberof(topology, user_dn=user_dn, group_dn=group_dn, find_result=find_result) - - + +
def test_ticket47829_init(topology): @@ -206,7 +207,7 @@ def test_ticket47829_init(topology): topology.standalone.add_s(Entry((DELETE_DN, { 'objectclass': "top nscontainer".split(), 'cn': DELETE_CN}))) - + # add groups topology.standalone.add_s(Entry((ACTIVE_GROUP_DN, { 'objectclass': "top groupOfNames".split(), @@ -217,38 +218,38 @@ def test_ticket47829_init(topology): topology.standalone.add_s(Entry((OUT_GROUP_DN, { 'objectclass': "top groupOfNames".split(), 'cn': OUT_GROUP_CN}))) - + # add users _add_user(topology, 'active') _add_user(topology, 'stage') _add_user(topology, 'out') - - + +
# enable memberof of with scope account topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF) dn = "cn=%s,%s" % (PLUGIN_MEMBER_OF, DN_PLUGIN) topology.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScope', ACTIVE_DN)]) - - - + + + topology.standalone.restart(timeout=10)
- - + + def test_ticket47829_mod_stage_user_modrdn_stage_user_1(topology): _header(topology, 'add an Stage user to a Active group. Then move Stage user to Stage') - + old_stage_user_dn = STAGE_USER_DN old_stage_user_rdn = "cn=%s" % STAGE_USER_CN new_stage_user_rdn = "cn=x%s" % STAGE_USER_CN new_stage_user_dn = "%s,%s" % (new_stage_user_rdn, STAGE_DN) - + # add Stage user to active group _check_memberof(topology, action=ldap.MOD_ADD, user_dn=old_stage_user_dn, group_dn=ACTIVE_GROUP_DN, find_result=False) _find_member (topology, user_dn=old_stage_user_dn, group_dn=ACTIVE_GROUP_DN, find_result=True) - + # move the Stage entry to Stage, expect no 'member' and 'memberof' _modrdn_entry (topology, entry_dn=old_stage_user_dn, new_rdn=new_stage_user_rdn, new_superior=STAGE_DN) _find_memberof(topology, user_dn=new_stage_user_dn, group_dn=ACTIVE_GROUP_DN, find_result=False) @@ -256,7 +257,6 @@ def test_ticket47829_mod_stage_user_modrdn_stage_user_1(topology):
def test_ticket47833_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47838_test.py b/dirsrvtests/tests/tickets/ticket47838_test.py index 6685fb8..bc84474 100644 --- a/dirsrvtests/tests/tickets/ticket47838_test.py +++ b/dirsrvtests/tests/tickets/ticket47838_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -27,7 +27,6 @@ CONFIG_DN = 'cn=config' ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN RSA = 'RSA' RSA_DN = 'cn=%s,%s' % (RSA, ENCRYPTION_DN) -LDAPSPORT = '10636' SERVERCERT = 'Server-Cert' plus_all_ecount = 0 plus_all_dcount = 0 @@ -37,6 +36,7 @@ plus_all_dcount_noweak = 0 nss_version = '' NSS320 = '3.20.0'
+ class TopologyStandalone(object): def __init__(self, standalone): standalone.open() @@ -75,8 +75,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + #request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -166,7 +167,7 @@ def _47838_init(topology):
topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', 'on'), (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', 'off'), - (ldap.MOD_REPLACE, 'nsslapd-secureport', LDAPSPORT)]) + (ldap.MOD_REPLACE, 'nsslapd-secureport', str(DEFAULT_SECURE_PORT))])
topology.standalone.add_s(Entry((RSA_DN, {'objectclass': "top nsEncryptionModule".split(), 'cn': RSA, @@ -204,7 +205,7 @@ def _47838_run_0(topology):
topology.standalone.simple_bind_s(DN_DM, PASSWORD) topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')]) - + time.sleep(5) log.info("\n######################### Restarting the server ######################\n") topology.standalone.restart(timeout=120)
@@ -244,6 +245,7 @@ def _47838_run_1(topology):
topology.standalone.simple_bind_s(DN_DM, PASSWORD) topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')]) + time.sleep(5) # Make sure allowWeakCipher is not set. topology.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'allowWeakCipher', None)])
@@ -365,7 +367,7 @@ def _47838_run_4(topology): log.info("Disabled ciphers: %d" % dcount) global plus_all_ecount global plus_all_dcount - assert ecount == 20 + assert ecount == 23 assert dcount == (plus_all_ecount + plus_all_dcount - ecount) weak = os.popen('egrep "SSL alert:" %s | egrep ": enabled" | egrep "WEAK CIPHER" | wc -l' % topology.standalone.errlog) wcount = int(weak.readline().rstrip()) @@ -402,7 +404,7 @@ def _47838_run_5(topology): global plus_all_ecount global plus_all_dcount if nss_version >= NSS320: - assert ecount == 20 + assert ecount == 23 else: assert ecount == 12 assert dcount == (plus_all_ecount + plus_all_dcount - ecount) @@ -507,7 +509,7 @@ def _47838_run_8(topology): global plus_all_ecount global plus_all_dcount if nss_version >= NSS320: - assert ecount == 20 + assert ecount == 23 else: assert ecount == 12 assert dcount == (plus_all_ecount + plus_all_dcount - ecount) @@ -547,7 +549,7 @@ def _47838_run_9(topology): log.info("Enabled ciphers: %d" % ecount) log.info("Disabled ciphers: %d" % dcount) if nss_version >= NSS320: - assert ecount == 27 + assert ecount == 30 else: assert ecount == 23 assert dcount == 0 @@ -655,6 +657,7 @@ def _47928_run_0(topology): (ldap.MOD_DELETE, 'sslVersionMin', None), (ldap.MOD_DELETE, 'sslVersionMax', None)]) topology.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')]) + time.sleep(5)
log.info("\n######################### Restarting the server ######################\n") topology.standalone.stop(timeout=10) @@ -823,7 +826,6 @@ def _47838_run_last(topology):
def _47838_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47869MMR_test.py b/dirsrvtests/tests/tickets/ticket47869MMR_test.py index 630cb93..02408d0 100644 --- a/dirsrvtests/tests/tickets/ticket47869MMR_test.py +++ b/dirsrvtests/tests/tickets/ticket47869MMR_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -132,8 +132,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
# Here we have two instances master and consumer return TopologyMaster1Master2(master1, master2) @@ -315,8 +317,6 @@ def test_ticket47869_check(topology):
def test_ticket47869_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47871_test.py b/dirsrvtests/tests/tickets/ticket47871_test.py index d6ea214..7e7b56d 100644 --- a/dirsrvtests/tests/tickets/ticket47871_test.py +++ b/dirsrvtests/tests/tickets/ticket47871_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -123,9 +123,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # clear the tmp directory - master.clearTmpDir(__file__) - + def fin(): + master.delete() + consumer.delete() + request.addfinalizer(fin) # # Here we have two instances master and consumer # with replication working. Either coming from a backup recovery @@ -198,8 +199,6 @@ def test_ticket47871_2(topology):
def test_ticket47871_final(topology): - topology.master.delete() - topology.consumer.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47900_test.py b/dirsrvtests/tests/tickets/ticket47900_test.py index c01b733..a3500d4 100644 --- a/dirsrvtests/tests/tickets/ticket47900_test.py +++ b/dirsrvtests/tests/tickets/ticket47900_test.py @@ -68,8 +68,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -321,7 +322,6 @@ def test_ticket47900(topology):
def test_ticket47900_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47910_test.py b/dirsrvtests/tests/tickets/ticket47910_test.py index afcfd88..bb8ffc6 100644 --- a/dirsrvtests/tests/tickets/ticket47910_test.py +++ b/dirsrvtests/tests/tickets/ticket47910_test.py @@ -55,11 +55,11 @@ def topology(request):
# Clear out the tmp dir standalone.clearTmpDir(__file__) - + def fin(): standalone.delete() request.addfinalizer(fin) - + return TopologyStandalone(standalone)
@@ -73,13 +73,13 @@ def log_dir(topology):
log.info("Diable access log buffering") topology.standalone.setAccessLogBuffering(False) - + log.info("Do a ldapsearch operation") topology.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, "(objectclass=*)") - + log.info("sleep for sometime so that access log file get generated") time.sleep( 1 ) - + return topology.standalone.accesslog
@@ -95,7 +95,7 @@ def execute_logconv(start_time_stamp, end_time_stamp, access_log): assign these values to -S and -E options of logconv and, it will execute logconv and return result value ''' - + log.info("Executing logconv.pl with -S current time and -E end time") cmd = ['logconv.pl', '-S', start_time_stamp, '-E', end_time_stamp, access_log] log.info(" ".join(cmd)) @@ -115,20 +115,20 @@ def test_ticket47910_logconv_start_end_positive(topology, log_dir): # Execute logconv.pl -S -E with random timestamp # log.info('Running test_ticket47910 - Execute logconv.pl -S -E with random values') - + log.info("taking current time with offset of 2 mins and formatting it to feed -S") start_time_stamp = (datetime.now() - timedelta(minutes=2)) formatted_start_time_stamp = format_time(start_time_stamp) - + log.info("taking current time with offset of 2 mins and formatting it to feed -E") end_time_stamp = (datetime.now() + timedelta(minutes=2)) formatted_end_time_stamp = format_time(end_time_stamp) - + log.info("Executing logconv.pl with -S and -E") result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir) assert result == 0
- + def test_ticket47910_logconv_start_end_negative(topology, log_dir): ''' Execute logconv.pl with -S and -E(endtime) with random time stamp @@ -136,20 +136,20 @@ def test_ticket47910_logconv_start_end_negative(topology, log_dir): starttime This should give error message ''' - + # # Execute logconv.pl -S and -E with random timestamp # log.info('Running test_ticket47910 - Execute logconv.pl -S -E with starttime>endtime') - + log.info("taking current time with offset of 2 mins and formatting it to feed -S") start_time_stamp = (datetime.now() + timedelta(minutes=2)) formatted_start_time_stamp = format_time(start_time_stamp) - + log.info("taking current time with offset of 2 mins and formatting it to feed -E") end_time_stamp = (datetime.now() - timedelta(minutes=2)) formatted_end_time_stamp = format_time(end_time_stamp) - + log.info("Executing logconv.pl with -S and -E") result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir) assert result == 1 @@ -167,24 +167,24 @@ def test_ticket47910_logconv_start_end_invalid(topology, log_dir): log.info("Set start time and end time to invalid values") start_time_stamp = "invalid" end_time_stamp = "invalid" - + log.info("Executing logconv.pl with -S and -E") result = execute_logconv(start_time_stamp, end_time_stamp, log_dir) assert result == 1
- + def test_ticket47910_logconv_noaccesslogs(topology, log_dir): - + ''' Execute logconv.pl -S(starttime) without specify - access logs location + access logs location ''' - + # # Execute logconv.pl -S with random timestamp and no access log location # log.info('Running test_ticket47910 - Execute logconv.pl without access logs') - + log.info("taking current time with offset of 2 mins and formatting it to feed -S") time_stamp = (datetime.now() - timedelta(minutes=2)) formatted_time_stamp = format_time(time_stamp) @@ -195,10 +195,10 @@ def test_ticket47910_logconv_noaccesslogs(topology, log_dir): stdout, stderr = proc.communicate() log.info("standard output" + stdout) log.info("standard errors" + stderr) - + assert proc.returncode == 1
- + if __name__ == '__main__': # Run isolated # -s for DEBUG mode diff --git a/dirsrvtests/tests/tickets/ticket47920_test.py b/dirsrvtests/tests/tickets/ticket47920_test.py index d4f6a53..99cc478 100644 --- a/dirsrvtests/tests/tickets/ticket47920_test.py +++ b/dirsrvtests/tests/tickets/ticket47920_test.py @@ -101,8 +101,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -169,7 +170,6 @@ def test_ticket47920_mod_readentry_ctrl(topology):
def test_ticket47920_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47921_test.py b/dirsrvtests/tests/tickets/ticket47921_test.py index 4f3d54e..3465fc7 100644 --- a/dirsrvtests/tests/tickets/ticket47921_test.py +++ b/dirsrvtests/tests/tickets/ticket47921_test.py @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -145,7 +146,6 @@ def test_ticket47921(topology):
def test_ticket47921_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47927_test.py b/dirsrvtests/tests/tickets/ticket47927_test.py index 78e0b29..c449b69 100644 --- a/dirsrvtests/tests/tickets/ticket47927_test.py +++ b/dirsrvtests/tests/tickets/ticket47927_test.py @@ -69,8 +69,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -289,7 +290,6 @@ def test_ticket47927_six(topology):
def test_ticket47927_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47937_test.py b/dirsrvtests/tests/tickets/ticket47937_test.py index 6c09cf8..009fbd3 100644 --- a/dirsrvtests/tests/tickets/ticket47937_test.py +++ b/dirsrvtests/tests/tickets/ticket47937_test.py @@ -60,8 +60,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -164,7 +165,6 @@ def test_ticket47937(topology):
def test_ticket47937_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47950_test.py b/dirsrvtests/tests/tickets/ticket47950_test.py index 7226637..c55c4ea 100644 --- a/dirsrvtests/tests/tickets/ticket47950_test.py +++ b/dirsrvtests/tests/tickets/ticket47950_test.py @@ -64,8 +64,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -199,7 +200,6 @@ def test_ticket47950(topology):
def test_ticket47953_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47953_test.py b/dirsrvtests/tests/tickets/ticket47953_test.py index f64d899..5dff58b 100644 --- a/dirsrvtests/tests/tickets/ticket47953_test.py +++ b/dirsrvtests/tests/tickets/ticket47953_test.py @@ -12,6 +12,7 @@ import time import ldap import logging import pytest +import shutil from lib389 import DirSrv, Entry, tools, tasks from lib389.tools import DirSrvTools from lib389._constants import * @@ -61,8 +62,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + #request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -80,7 +82,15 @@ def test_ticket47953(topology): # # Import an invalid ldif # - ldif_file = topology.standalone.getDir(__file__, DATA_DIR) + "ticket47953/ticket47953.ldif" + ldif_file = (topology.standalone.getDir(__file__, DATA_DIR) + + "ticket47953/ticket47953.ldif") + try: + ldif_dir = topology.standalone.get_ldif_dir() + shutil.copy(ldif_file, ldif_dir) + ldif_file = ldif_dir + '/ticket47953.ldif' + except: + log.fatal('Failed to copy ldif to instance ldif dir') + assert False importTask = Tasks(topology.standalone) args = {TASK_WAIT: True} try: @@ -88,6 +98,8 @@ def test_ticket47953(topology): except ValueError: assert False
+ time.sleep(2) + # # Delete the invalid aci # @@ -104,7 +116,6 @@ def test_ticket47953(topology):
def test_ticket47953_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47963_test.py b/dirsrvtests/tests/tickets/ticket47963_test.py index deed905..a991173 100644 --- a/dirsrvtests/tests/tickets/ticket47963_test.py +++ b/dirsrvtests/tests/tickets/ticket47963_test.py @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -181,7 +182,6 @@ def test_ticket47963(topology):
def test_ticket47963_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47966_test.py b/dirsrvtests/tests/tickets/ticket47966_test.py index b311f47..3130f69 100644 --- a/dirsrvtests/tests/tickets/ticket47966_test.py +++ b/dirsrvtests/tests/tickets/ticket47966_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -114,8 +114,10 @@ def topology(request): log.fatal('Replication is not working.') assert False
- # Clear out the tmp dir - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
return TopologyReplication(master1, master2)
@@ -208,8 +210,6 @@ def test_ticket47966(topology):
def test_ticket47966_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47970_test.py b/dirsrvtests/tests/tickets/ticket47970_test.py index a748939..bea74bc 100644 --- a/dirsrvtests/tests/tickets/ticket47970_test.py +++ b/dirsrvtests/tests/tickets/ticket47970_test.py @@ -65,8 +65,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -134,7 +135,6 @@ def test_ticket47970(topology):
def test_ticket47970_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47973_test.py b/dirsrvtests/tests/tickets/ticket47973_test.py index 12bb789..d2fdcd5 100644 --- a/dirsrvtests/tests/tickets/ticket47973_test.py +++ b/dirsrvtests/tests/tickets/ticket47973_test.py @@ -65,8 +65,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -161,7 +162,6 @@ def test_ticket47973(topology):
def test_ticket47973_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47980_test.py b/dirsrvtests/tests/tickets/ticket47980_test.py index 34f0d3f..6b6b5bf 100644 --- a/dirsrvtests/tests/tickets/ticket47980_test.py +++ b/dirsrvtests/tests/tickets/ticket47980_test.py @@ -117,8 +117,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -638,7 +639,6 @@ def test_ticket47980(topology):
def test_ticket47980_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47981_test.py b/dirsrvtests/tests/tickets/ticket47981_test.py index b25d7dd..0fcf51e 100644 --- a/dirsrvtests/tests/tickets/ticket47981_test.py +++ b/dirsrvtests/tests/tickets/ticket47981_test.py @@ -73,8 +73,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -271,7 +272,6 @@ def test_ticket47981(topology):
def test_ticket47981_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket47988_test.py b/dirsrvtests/tests/tickets/ticket47988_test.py index db58e9d..45abba6 100644 --- a/dirsrvtests/tests/tickets/ticket47988_test.py +++ b/dirsrvtests/tests/tickets/ticket47988_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # ''' @@ -123,6 +123,11 @@ def topology(request): master2.create() master2.open()
+ def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin) + # # Now prepare the Master-Consumer topology # @@ -470,8 +475,6 @@ def test_ticket47988_6(topology):
def test_ticket47988_final(topology): - topology.master1.delete() - topology.master2.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48005_test.py b/dirsrvtests/tests/tickets/ticket48005_test.py index b2a93e1..116b1e9 100644 --- a/dirsrvtests/tests/tickets/ticket48005_test.py +++ b/dirsrvtests/tests/tickets/ticket48005_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -50,8 +50,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + #request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -75,7 +76,7 @@ def test_ticket48005_setup(topology): log.info('No ulimit -c in %s' % sysconfig_dirsrv) log.info('Adding it') cmdline = 'echo "ulimit -c unlimited" >> %s' % sysconfig_dirsrv - + sysconfig_dirsrv_systemd = sysconfig_dirsrv + ".systemd" cmdline = 'egrep LimitCORE=infinity %s' % sysconfig_dirsrv_systemd p = os.popen(cmdline, "r") @@ -87,7 +88,7 @@ def test_ticket48005_setup(topology):
topology.standalone.restart(timeout=10)
- ldif_file = topology.standalone.getDir(__file__, DATA_DIR) + "ticket48005.ldif" + ldif_file = topology.standalone.get_ldif_dir() + "/ticket48005.ldif" os.system('ls %s' % ldif_file) os.system('rm -f %s' % ldif_file) if hasattr(topology.standalone, 'prefix'): @@ -113,7 +114,7 @@ def test_ticket48005_memberof(topology): ''' Enable memberof and referint plugin Run fixmemberof task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. ''' @@ -132,7 +133,7 @@ def test_ticket48005_memberof(topology):
topology.standalone.stop(timeout=10)
- mytmp = topology.standalone.getDir(__file__, TMP_DIR) + mytmp = '/tmp' logdir = re.sub('errors', '', topology.standalone.errlog) cmdline = 'ls ' + logdir + 'core*' p = os.popen(cmdline, "r") @@ -157,15 +158,15 @@ def test_ticket48005_automember(topology): ''' Enable automember and referint plugin 1. Run automember rebuild membership task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. 2. Run automember export updates task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. 3. Run automember map updates task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. ''' @@ -198,7 +199,7 @@ def test_ticket48005_automember(topology):
topology.standalone.stop(timeout=10)
- mytmp = topology.standalone.getDir(__file__, TMP_DIR) + mytmp = '/tmp' logdir = re.sub('errors', '', topology.standalone.errlog) cmdline = 'ls ' + logdir + 'core*' p = os.popen(cmdline, "r") @@ -233,7 +234,7 @@ def test_ticket48005_automember(topology):
topology.standalone.start(timeout=10)
- ldif_in_file = topology.standalone.getDir(__file__, DATA_DIR) + "ticket48005.ldif" + ldif_in_file = topology.standalone.get_ldif_dir() + "/ticket48005.ldif" ldif_out_file = mytmp + "/ticket48005_automember_map.ldif" try: # run the automember map task @@ -267,7 +268,7 @@ def test_ticket48005_automember(topology): def test_ticket48005_syntaxvalidate(topology): ''' Run syntax validate task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. ''' @@ -282,7 +283,7 @@ def test_ticket48005_syntaxvalidate(topology):
topology.standalone.stop(timeout=10)
- mytmp = topology.standalone.getDir(__file__, TMP_DIR) + mytmp = '/tmp' logdir = re.sub('errors', '', topology.standalone.errlog) cmdline = 'ls ' + logdir + 'core*' p = os.popen(cmdline, "r") @@ -303,7 +304,7 @@ def test_ticket48005_usn(topology): Enable entryusn Delete all user entries. Run USN tombstone cleanup task - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. ''' @@ -337,7 +338,7 @@ def test_ticket48005_usn(topology):
topology.standalone.stop(timeout=10)
- mytmp = topology.standalone.getDir(__file__, TMP_DIR) + mytmp = '/tmp' logdir = re.sub('errors', '', topology.standalone.errlog) cmdline = 'ls ' + logdir + 'core*' p = os.popen(cmdline, "r") @@ -360,7 +361,7 @@ def test_ticket48005_usn(topology): def test_ticket48005_schemareload(topology): ''' Run schema reload task without waiting - Shutdown the server + Shutdown the server Check if a core file was generated or not If no core was found, this test case was successful. ''' @@ -380,7 +381,7 @@ def test_ticket48005_schemareload(topology): p = os.popen(cmdline, "r") lcore = p.readline() if lcore != "": - mytmp = topology.standalone.getDir(__file__, TMP_DIR) + mytmp = '/tmp' s.system('mv %score* %s/core.ticket48005_schema_reload' % (logdir, mytmp)) log.error('Schema reload: Moved core file(s) to %s; Test failed' % mytmp) assert False @@ -392,7 +393,6 @@ def test_ticket48005_schemareload(topology):
def test_ticket48005_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48013_test.py b/dirsrvtests/tests/tickets/ticket48013_test.py index 730f929..b6fe22e 100644 --- a/dirsrvtests/tests/tickets/ticket48013_test.py +++ b/dirsrvtests/tests/tickets/ticket48013_test.py @@ -70,8 +70,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -125,7 +126,6 @@ def test_ticket48013(topology):
def test_ticket48013_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48026_test.py b/dirsrvtests/tests/tickets/ticket48026_test.py index f8d440f..2f411aa 100644 --- a/dirsrvtests/tests/tickets/ticket48026_test.py +++ b/dirsrvtests/tests/tickets/ticket48026_test.py @@ -54,8 +54,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -150,7 +151,6 @@ def test_ticket48026(topology):
def test_ticket48026_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48170_test.py b/dirsrvtests/tests/tickets/ticket48170_test.py index cc71e37..2261c11 100644 --- a/dirsrvtests/tests/tickets/ticket48170_test.py +++ b/dirsrvtests/tests/tickets/ticket48170_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -51,8 +51,9 @@ def topology(request): standalone.create() standalone.open()
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
return TopologyStandalone(standalone)
@@ -78,7 +79,6 @@ def test_ticket48170(topology):
def test_ticket48170_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48194_test.py b/dirsrvtests/tests/tickets/ticket48194_test.py index fa4fe72..453a794 100644 --- a/dirsrvtests/tests/tickets/ticket48194_test.py +++ b/dirsrvtests/tests/tickets/ticket48194_test.py @@ -26,7 +26,7 @@ CONFIG_DN = 'cn=config' ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN RSA = 'RSA' RSA_DN = 'cn=%s,%s' % (RSA, ENCRYPTION_DN) -LDAPSPORT = '636' +LDAPSPORT = str(DEFAULT_SECURE_PORT) SERVERCERT = 'Server-Cert' plus_all_ecount = 0 plus_all_dcount = 0 @@ -68,8 +68,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -457,10 +458,11 @@ def my_test_run_11(topology): connectWithOpenssl(topology, 'RC4-SHA', False) connectWithOpenssl(topology, 'AES256-SHA256', False)
+ def my_test_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
+ def test_ticket48194(topology): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) diff --git a/dirsrvtests/tests/tickets/ticket48212_test.py b/dirsrvtests/tests/tickets/ticket48212_test.py index 82ec102..58a860f 100644 --- a/dirsrvtests/tests/tickets/ticket48212_test.py +++ b/dirsrvtests/tests/tickets/ticket48212_test.py @@ -91,7 +91,7 @@ def reindexUidNumber(topology): indexOUT = os.popen(indexCMD, "r") topology.standalone.log.info("Running %s" % indexCMD)
- time.sleep(15) + time.sleep(30)
tailCMD = "tail -n 3 " + topology.standalone.errlog tailOUT = os.popen(tailCMD, "r") @@ -117,6 +117,14 @@ def test_ticket48212(topology):
data_dir_path = topology.standalone.getDir(__file__, DATA_DIR) ldif_file = data_dir_path + "ticket48212/" + _MYLDIF + try: + ldif_dir = topology.standalone.get_ldif_dir() + shutil.copy(ldif_file, ldif_dir) + ldif_file = ldif_dir + '/' + _MYLDIF + except: + log.fatal('Failed to copy ldif to instance ldif dir') + assert False + topology.standalone.log.info("\n\n######################### Import Test data (%s) ######################\n" % ldif_file) args = {TASK_WAIT: True} importTask = Tasks(topology.standalone) diff --git a/dirsrvtests/tests/tickets/ticket48214_test.py b/dirsrvtests/tests/tickets/ticket48214_test.py index 14bf392..8c8bf40 100644 --- a/dirsrvtests/tests/tickets/ticket48214_test.py +++ b/dirsrvtests/tests/tickets/ticket48214_test.py @@ -56,12 +56,14 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone)
+ def getMaxBerSizeFromDseLdif(topology): topology.standalone.log.info(" +++++ Get maxbersize from dse.ldif +++++\n") dse_ldif = topology.standalone.confdir + '/dse.ldif' @@ -145,7 +147,6 @@ def test_ticket48214_run(topology):
def test_ticket48214_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48226_test.py b/dirsrvtests/tests/tickets/ticket48226_test.py index 6e244af..9f96d8a 100644 --- a/dirsrvtests/tests/tickets/ticket48226_test.py +++ b/dirsrvtests/tests/tickets/ticket48226_test.py @@ -110,16 +110,6 @@ def topology(request): master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2) master1.waitForReplInit(m1_m2_agmt)
- # Check replication is working... - if master1.testReplication(DEFAULT_SUFFIX, master2): - log.info('Replication is working.') - else: - log.fatal('Replication is not working.') - assert False - - # Clear out the tmp dir - master1.clearTmpDir(__file__) - def fin(): master1.delete() master2.delete() @@ -127,6 +117,13 @@ def topology(request): valgrind_disable(sbin_dir) request.addfinalizer(fin)
+ # Check replication is working... + if master1.testReplication(DEFAULT_SUFFIX, master2): + log.info('Replication is working.') + else: + log.fatal('Replication is not working.') + assert False + return TopologyReplication(master1, master2)
@@ -145,8 +142,8 @@ def test_ticket48226_set_purgedelay(topology): assert False topology.master1.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-auditlog-logging-enabled', 'on')]) topology.master2.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-auditlog-logging-enabled', 'on')]) - topology.master1.restart(10) - topology.master2.restart(10) + topology.master1.restart(30) + topology.master2.restart(30)
def test_ticket48226_1(topology): @@ -200,7 +197,7 @@ def test_ticket48226_1(topology): mods = [(ldap.MOD_ADD, 'description', '5')] topology.master2.modify_s(dn, mods)
- # sleep of purgedelay so that the next update will purge the CSN_7 + # sleep of purge delay so that the next update will purge the CSN_7 time.sleep(6)
# ADD 'description' by '6' that purge the state info @@ -208,13 +205,12 @@ def test_ticket48226_1(topology): topology.master2.modify_s(dn, mods)
# Restart master1 - topology.master1.start(10) + #topology.master1.start(30)
- # Get the results file results_file = valgrind_get_results_file(topology.master2)
# Stop master2 - topology.master2.stop(10) + topology.master2.stop(30)
# Check for leak if valgrind_check_file(results_file, VALGRIND_LEAK_STR, 'csnset_dup'): @@ -237,7 +233,6 @@ def test_ticket48226_1(topology): else: log.info('Valgrind is happy!')
- topology.master1.start(10) log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48228_test.py b/dirsrvtests/tests/tickets/ticket48228_test.py index f3657c4..f820cbe 100644 --- a/dirsrvtests/tests/tickets/ticket48228_test.py +++ b/dirsrvtests/tests/tickets/ticket48228_test.py @@ -72,8 +72,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -306,7 +307,6 @@ def test_ticket48228_test_subtree_policy(topology):
def test_ticket48228_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48252_test.py b/dirsrvtests/tests/tickets/ticket48252_test.py index 5970d70..2c4eeab 100644 --- a/dirsrvtests/tests/tickets/ticket48252_test.py +++ b/dirsrvtests/tests/tickets/ticket48252_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -64,12 +64,14 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone)
+ def test_ticket48252_setup(topology): """ Enable USN plug-in for enabling tombstones @@ -90,6 +92,8 @@ def test_ticket48252_setup(topology): 'objectclass': "top person".split(), 'sn': name, 'cn': name}))) + + def in_index_file(topology, id, index): key = "%s%s" % (TEST_USER, id) log.info(" dbscan - checking %s is in index file %s..." % (key, index)) @@ -104,6 +108,7 @@ def in_index_file(topology, id, index):
return found
+ def test_ticket48252_run_0(topology): """ Delete an entry cn=test_entry0 @@ -124,6 +129,7 @@ def test_ticket48252_run_0(topology): log.info(" entry %s is not in the cn index file after reindexed." % del_entry) log.info('Case 1 - PASSED')
+ def test_ticket48252_run_1(topology): """ Delete an entry cn=test_entry1 @@ -147,10 +153,11 @@ def test_ticket48252_run_1(topology): log.info(" entry %s is in the objectclass index file after reindexed." % del_entry) log.info('Case 2 - PASSED')
+ def test_ticket48252_final(topology): - topology.standalone.delete() log.info('Testing Ticket 48252 - PASSED.')
+ def run_isolated(): ''' run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..) diff --git a/dirsrvtests/tests/tickets/ticket48265_test.py b/dirsrvtests/tests/tickets/ticket48265_test.py index fb695c5..9bfa34d 100644 --- a/dirsrvtests/tests/tickets/ticket48265_test.py +++ b/dirsrvtests/tests/tickets/ticket48265_test.py @@ -54,6 +54,10 @@ def topology(request): standalone.create() standalone.open()
+ def fin(): + standalone.delete() + request.addfinalizer(fin) + return TopologyStandalone(standalone)
@@ -103,7 +107,6 @@ def test_ticket48265_test(topology):
def test_ticket48265_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48270_test.py b/dirsrvtests/tests/tickets/ticket48270_test.py index fb795d5..78b357d 100644 --- a/dirsrvtests/tests/tickets/ticket48270_test.py +++ b/dirsrvtests/tests/tickets/ticket48270_test.py @@ -4,8 +4,7 @@ import time import ldap import logging import pytest -from lib389 import DirSrv, Entry, tools, tasks -from lib389.tools import DirSrvTools +from lib389 import DirSrv, Entry from lib389._constants import * from lib389.properties import * from lib389.tasks import * @@ -36,14 +35,8 @@ class TopologyStandalone(object):
@pytest.fixture(scope="module") def topology(request): - global installation1_prefix - if installation1_prefix: - args_instance[SER_DEPLOYED_DIR] = installation1_prefix - # Creating standalone instance ... standalone = DirSrv(verbose=False) - if installation1_prefix: - args_instance[SER_DEPLOYED_DIR] = installation1_prefix args_instance[SER_HOST] = HOST_STANDALONE args_instance[SER_PORT] = PORT_STANDALONE args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE @@ -59,7 +52,7 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__) @@ -103,11 +96,11 @@ def test_ticket48270_homeDirectory_indexed_cis(topology): #topology.standalone.start(timeout=10) args = {TASK_WAIT: True} topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) - + log.info("Check indexing succeeded with a specified matching rule") file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) file_obj = open(file_path, "r") - + # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") while True: @@ -115,27 +108,29 @@ def test_ticket48270_homeDirectory_indexed_cis(topology): found = regex.search(line) if ((line == '') or (found)): break - + if (found): log.info("The configuration of a specific MR fails") log.info(line) #assert not found
+ def test_ticket48270_homeDirectory_mixed_value(topology): # Set a homedirectory value with mixed case name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) mod = [(ldap.MOD_REPLACE, 'homeDirectory', MIXED_VALUE)] topology.standalone.modify_s(name, mod)
+ def test_ticket48270_extensible_search(topology): name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) - + # check with the exact stored value log.info("Default: can retrieve an entry filter syntax with exact stored value") ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory=%s)" % MIXED_VALUE) log.info("Default: can retrieve an entry filter caseExactIA5Match with exact stored value") ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory:caseExactIA5Match:=%s)" % MIXED_VALUE) - + # check with a lower case value that is different from the stored value log.info("Default: can not retrieve an entry filter syntax match with lowered stored value") try: @@ -152,6 +147,7 @@ def test_ticket48270_extensible_search(topology): log.info("Default: can retrieve an entry filter caseIgnoreIA5Match with lowered stored value") ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory:caseIgnoreIA5Match:=%s)" % LOWER_VALUE)
+ def test_ticket48270(topology): """Write your testcase here...
@@ -165,13 +161,11 @@ def test_ticket48270(topology): if __name__ == '__main__': # Run isolated # -s for DEBUG mode - global installation1_prefix - installation1_prefix = '/home/tbordaz/install_master' topo = topology(True) test_ticket48270_init(topo) test_ticket48270_homeDirectory_indexed_cis(topo) test_ticket48270_homeDirectory_mixed_value(topo) test_ticket48270_extensible_search(topo) - + # CURRENT_FILE = os.path.realpath(__file__) # pytest.main("-s %s" % CURRENT_FILE) diff --git a/dirsrvtests/tests/tickets/ticket48294_test.py b/dirsrvtests/tests/tickets/ticket48294_test.py index 109a67e..ddb71bc 100644 --- a/dirsrvtests/tests/tickets/ticket48294_test.py +++ b/dirsrvtests/tests/tickets/ticket48294_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -67,8 +67,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -79,6 +80,7 @@ def _header(topology, label): topology.standalone.log.info("####### %s" % label) topology.standalone.log.info("###############################################")
+ def check_attr_val(topology, dn, attr, expected): try: centry = topology.standalone.search_s(dn, ldap.SCOPE_BASE, 'uid=*') @@ -259,7 +261,6 @@ def _48294_run_2(topology):
def _48294_final(topology): - topology.standalone.delete() log.info('All PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48295_test.py b/dirsrvtests/tests/tickets/ticket48295_test.py index 13a7f88..bcc8879 100644 --- a/dirsrvtests/tests/tickets/ticket48295_test.py +++ b/dirsrvtests/tests/tickets/ticket48295_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -67,8 +67,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -183,7 +184,6 @@ def _48295_run(topology):
def _48295_final(topology): - topology.standalone.delete() log.info('All PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48342_test.py b/dirsrvtests/tests/tickets/ticket48342_test.py index 104a938..6dd5506 100644 --- a/dirsrvtests/tests/tickets/ticket48342_test.py +++ b/dirsrvtests/tests/tickets/ticket48342_test.py @@ -180,10 +180,6 @@ def topology(request): # Delete each instance in the end def fin(): for master in (master1, master2, master3): - # master.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], encrypt=False, \ - # repl_data=True, outputfile='%s/ldif/%s.ldif' % (master.dbdir,SERVERID_STANDALONE )) - # master.clearBackupFS() - # master.backupFS() master.delete() request.addfinalizer(fin)
@@ -240,7 +236,7 @@ def test_ticket4026(topology): 'ou': 'people'}))) except ldap.ALREADY_EXISTS: pass - + topology.master1.add_s(Entry(('ou=ranges,' + SUFFIX, { 'objectclass': 'top organizationalunit'.split(), 'ou': 'ranges' @@ -255,7 +251,7 @@ def test_ticket4026(topology): 'gidNumber': '1', 'homeDirectory': '/home/%s' % name }))) - + # make master3 having more free slots that master2 # so master1 will contact master3 _dna_config(topology.master1, nextValue=100, maxValue=10) @@ -263,7 +259,7 @@ def test_ticket4026(topology): _dna_config(topology.master3, nextValue=300, maxValue=3000)
# Turn on lots of error logging now. - + mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '16384')] #mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '1')] topology.master1.modify_s('cn=config', mod) @@ -273,7 +269,7 @@ def test_ticket4026(topology): # We need to wait for the event in dna.c to fire to start the servers # see dna.c line 899 time.sleep(60) - + # add on master1 users with description DNA for cpt in range(10): name = "user_with_desc1_%d" % (cpt) diff --git a/dirsrvtests/tests/tickets/ticket48362_test.py b/dirsrvtests/tests/tickets/ticket48362_test.py index 0f56c01..dc03d3a 100644 --- a/dirsrvtests/tests/tickets/ticket48362_test.py +++ b/dirsrvtests/tests/tickets/ticket48362_test.py @@ -111,17 +111,14 @@ def topology(request): def fin(): master1.delete() master2.delete() - #request.addfinalizer(fin) - - # Clear out the tmp dir - master1.clearTmpDir(__file__) + request.addfinalizer(fin)
return TopologyReplication(master1, master2)
def _dna_config(server, nextValue=500, maxValue=510): log.info("Add dna plugin config entry...%s" % server) - + cfg_base_dn = 'cn=dna config,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config'
try: @@ -152,8 +149,8 @@ def _dna_config(server, nextValue=500, maxValue=510): time.sleep(1) server.start(timeout=120) time.sleep(3) - - + + SHARE_CFG_BASE = 'ou=ranges,' + SUFFIX
def _wait_shared_cfg_servers(server, expected): @@ -174,22 +171,22 @@ def _wait_shared_cfg_servers(server, expected): pass except lib389.NoSuchEntryError: pass - + def _shared_cfg_server_update(server, method=BINDMETHOD_VALUE, transport=PROTOCOLE_VALUE): log.info('\n======================== Update dnaPortNum=%d ============================\n'% server.port) try: ent = server.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % server.port) - mod = [(ldap.MOD_REPLACE, BINDMETHOD_ATTR, method), + mod = [(ldap.MOD_REPLACE, BINDMETHOD_ATTR, method), (ldap.MOD_REPLACE, PROTOCOLE_ATTR, transport)] server.modify_s(ent.dn, mod) - + log.info('\n======================== Update done\n') ent = server.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % server.port) except ldap.NO_SUCH_OBJECT: log.fatal("Unknown host") assert False - - + + def test_ticket48362(topology): """Write your replication testcase here.
@@ -206,7 +203,7 @@ def test_ticket48362(topology): 'ou': 'people'}))) except ldap.ALREADY_EXISTS: pass - + topology.master1.add_s(Entry((SHARE_CFG_BASE, { 'objectclass': 'top organizationalunit'.split(), 'ou': 'ranges' @@ -216,15 +213,15 @@ def test_ticket48362(topology): # will not contain master 2. So at restart, master 2 is recreated without the method/protocol attribute _dna_config(topology.master1, nextValue=1000, maxValue=100) _dna_config(topology.master2, nextValue=2000, maxValue=-1) - + # check we have all the servers available _wait_shared_cfg_servers(topology.master1, 2) _wait_shared_cfg_servers(topology.master2, 2) - + # now force the method/transport on the servers entry _shared_cfg_server_update(topology.master1) _shared_cfg_server_update(topology.master2) - +
log.info('\n======================== BEFORE RESTART ============================\n') @@ -240,10 +237,10 @@ def test_ticket48362(topology): assert(ent.hasAttr(PROTOCOLE_ATTR) and ent.getValue(PROTOCOLE_ATTR) == PROTOCOLE_VALUE) topology.master1.restart(10) topology.master2.restart(10) - + # to allow DNA plugin to recreate the local host entry time.sleep(40) - + log.info('\n=================== AFTER RESTART =================================\n') ent = topology.master1.getEntry(SHARE_CFG_BASE, ldap.SCOPE_ONELEVEL, "(dnaPortNum=%d)" % topology.master1.port) log.info('\n=================== AFTER RESTART =================================\n') diff --git a/dirsrvtests/tests/tickets/ticket48366_test.py b/dirsrvtests/tests/tickets/ticket48366_test.py index fb2dd97..2ce4ccf 100644 --- a/dirsrvtests/tests/tickets/ticket48366_test.py +++ b/dirsrvtests/tests/tickets/ticket48366_test.py @@ -3,7 +3,7 @@ # All rights reserved. # # License: GPL (version 3 or any later version). -# See LICENSE for details. +# See LICENSE for details. # --- END COPYRIGHT BLOCK --- # import os @@ -27,7 +27,7 @@ TEST_USER_DN = 'cn=test,ou=people,%s' % SUFFIX USER_PW = 'password'
-# subtrees used in test +# subtrees used in test SUBTREE_GREEN = "ou=green,%s" % SUFFIX SUBTREE_RED = "ou=red,%s" % SUFFIX SUBTREES = (SUBTREE_GREEN, SUBTREE_RED) @@ -67,8 +67,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -185,8 +186,8 @@ def test_ticket48366_search_dm(topology): ents = topology.standalone.search_ext_s(SUFFIX, ldap.SCOPE_SUBTREE, 'uid=test1', serverctrls=[proxy_ctrl]) assert (len(ents) == 0)
+ def test_ticket48366_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48497_test.py b/dirsrvtests/tests/tickets/ticket48497_test.py index f82e842..debe63f 100644 --- a/dirsrvtests/tests/tickets/ticket48497_test.py +++ b/dirsrvtests/tests/tickets/ticket48497_test.py @@ -59,7 +59,7 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__) @@ -83,16 +83,16 @@ def test_ticket48497_homeDirectory_mixed_value(topology): name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) mod = [(ldap.MOD_REPLACE, 'homeDirectory', MIXED_VALUE)] topology.standalone.modify_s(name, mod) - + def test_ticket48497_extensible_search(topology): name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) - + # check with the exact stored value log.info("Default: can retrieve an entry filter syntax with exact stored value") ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory=%s)" % MIXED_VALUE) log.info("Default: can retrieve an entry filter caseExactIA5Match with exact stored value") ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory:caseExactIA5Match:=%s)" % MIXED_VALUE) - + # check with a lower case value that is different from the stored value log.info("Default: can not retrieve an entry filter syntax match with lowered stored value") try: @@ -131,11 +131,11 @@ def test_ticket48497_homeDirectory_index_cfg(topology): def test_ticket48497_homeDirectory_index_run(topology): args = {TASK_WAIT: True} topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) - + log.info("Check indexing succeeded with a specified matching rule") file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) file_obj = open(file_path, "r") - + # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") while True: @@ -143,7 +143,7 @@ def test_ticket48497_homeDirectory_index_run(topology): found = regex.search(line) if ((line == '') or (found)): break - + if (found): log.info("The configuration of a specific MR fails") log.info(line) @@ -166,8 +166,8 @@ if __name__ == '__main__': # installation1_prefix = None # topo = topology(True) # test_ticket48497_init(topo) -# -# +# +# # test_ticket48497_homeDirectory_mixed_value(topo) # test_ticket48497_extensible_search(topo) # test_ticket48497_homeDirectory_index_cfg(topo) diff --git a/dirsrvtests/tests/tickets/ticket48745_test.py b/dirsrvtests/tests/tickets/ticket48745_test.py index adea76f..ca888da 100644 --- a/dirsrvtests/tests/tickets/ticket48745_test.py +++ b/dirsrvtests/tests/tickets/ticket48745_test.py @@ -59,7 +59,7 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__) @@ -102,11 +102,11 @@ def test_ticket48745_homeDirectory_indexed_cis(topology): #topology.standalone.start(timeout=10) args = {TASK_WAIT: True} topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) - + log.info("Check indexing succeeded with a specified matching rule") file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) file_obj = open(file_path, "r") - + # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") while True: @@ -114,7 +114,7 @@ def test_ticket48745_homeDirectory_indexed_cis(topology): found = regex.search(line) if ((line == '') or (found)): break - + if (found): log.info("The configuration of a specific MR fails") log.info(line) @@ -128,7 +128,7 @@ def test_ticket48745_homeDirectory_mixed_value(topology):
def test_ticket48745_extensible_search_after_index(topology): name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) - + # check with the exact stored value log.info("Default: can retrieve an entry filter syntax with exact stored value") ent = topology.standalone.getEntry(SUFFIX, ldap.SCOPE_SUBTREE, "(homeDirectory=%s)" % MIXED_VALUE) @@ -176,7 +176,7 @@ if __name__ == '__main__': # installation1_prefix = None # topo = topology(True) # test_ticket48745_init(topo) -# +# # test_ticket48745_homeDirectory_indexed_cis(topo) # test_ticket48745_homeDirectory_mixed_value(topo) # test_ticket48745_extensible_search_after_index(topo) diff --git a/dirsrvtests/tests/tickets/ticket48746_test.py b/dirsrvtests/tests/tickets/ticket48746_test.py index ce766ae..038f1dd 100644 --- a/dirsrvtests/tests/tickets/ticket48746_test.py +++ b/dirsrvtests/tests/tickets/ticket48746_test.py @@ -59,7 +59,7 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__) @@ -102,11 +102,11 @@ def test_ticket48746_homeDirectory_indexed_cis(topology): #topology.standalone.start(timeout=10) args = {TASK_WAIT: True} topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) - + log.info("Check indexing succeeded with a specified matching rule") file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) file_obj = open(file_path, "r") - + # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") while True: @@ -114,7 +114,7 @@ def test_ticket48746_homeDirectory_indexed_cis(topology): found = regex.search(line) if ((line == '') or (found)): break - + if (found): log.info("The configuration of a specific MR fails") log.info(line) @@ -128,7 +128,7 @@ def test_ticket48746_homeDirectory_mixed_value(topology):
def test_ticket48746_extensible_search_after_index(topology): name = "uid=%s1,%s" % (NEW_ACCOUNT, SUFFIX) - + # check with the exact stored value # log.info("Default: can retrieve an entry filter syntax with exact stored value") # ent = topology.standalone.getEntry(name, ldap.SCOPE_BASE, "(homeDirectory=%s)" % MIXED_VALUE) @@ -166,11 +166,11 @@ def test_ticket48746_homeDirectory_indexed_ces(topology): #topology.standalone.start(timeout=10) args = {TASK_WAIT: True} topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) - + log.info("Check indexing succeeded with a specified matching rule") file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) file_obj = open(file_path, "r") - + # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") while True: @@ -178,7 +178,7 @@ def test_ticket48746_homeDirectory_indexed_ces(topology): found = regex.search(line) if ((line == '') or (found)): break - + if (found): log.info("The configuration of a specific MR fails") log.info(line) @@ -201,13 +201,13 @@ if __name__ == '__main__': # installation1_prefix = None # topo = topology(True) # test_ticket48746_init(topo) -# -# +# +# # test_ticket48746_homeDirectory_indexed_cis(topo) # test_ticket48746_homeDirectory_mixed_value(topo) # test_ticket48746_extensible_search_after_index(topo) # # crash should occur here # test_ticket48746_homeDirectory_indexed_ces(topo) - + CURRENT_FILE = os.path.realpath(__file__) pytest.main("-s %s" % CURRENT_FILE) diff --git a/dirsrvtests/tests/tickets/ticket48759_test.py b/dirsrvtests/tests/tickets/ticket48759_test.py index 93c3223..63115c1 100644 --- a/dirsrvtests/tests/tickets/ticket48759_test.py +++ b/dirsrvtests/tests/tickets/ticket48759_test.py @@ -64,8 +64,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -108,9 +109,9 @@ def _find_memberof(topology, user_dn=None, group_dn=None, find_result=True): if val == group_dn: found = True break - + if find_result: - assert(found) + assert(found) else: assert(not found)
@@ -119,9 +120,9 @@ def test_ticket48759(topology): The fix for ticket 48759 has to prevent plugin calls for tombstone purging
The test uses the memberof and retrocl plugins to verify this. - In tombstone purging without the fix the mmeberof plugin is called, - if the tombstone entry is a group, - it modifies the user entries for the group + In tombstone purging without the fix the mmeberof plugin is called, + if the tombstone entry is a group, + it modifies the user entries for the group and if retrocl is enabled this mod is written to the retrocl
The test sequence is: @@ -262,7 +263,6 @@ def test_ticket48759(topology):
def test_ticket48759_final(topology): - topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket48784_test.py b/dirsrvtests/tests/tickets/ticket48784_test.py index 159301a..a970fc6 100644 --- a/dirsrvtests/tests/tickets/ticket48784_test.py +++ b/dirsrvtests/tests/tickets/ticket48784_test.py @@ -38,6 +38,7 @@ M2SERVERCERT = 'Server-Cert2' M1LDAPSPORT = '41636' M2LDAPSPORT = '42636'
+ class TopologyReplication(object): def __init__(self, master1, master2): master1.open() @@ -53,7 +54,7 @@ def topology(request): args_instance[SER_DEPLOYED_DIR] = installation1_prefix
# Creating master 1... - master1 = DirSrv(verbose=True) + master1 = DirSrv(verbose=False) if installation1_prefix: args_instance[SER_DEPLOYED_DIR] = installation1_prefix args_instance[SER_HOST] = HOST_MASTER_1 @@ -70,7 +71,7 @@ def topology(request): master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
# Creating master 2... - master2 = DirSrv(verbose=True) + master2 = DirSrv(verbose=False) if installation1_prefix: args_instance[SER_DEPLOYED_DIR] = installation1_prefix args_instance[SER_HOST] = HOST_MASTER_2 @@ -137,20 +138,15 @@ def topology(request): assert False
# Delete each instance in the end - #def fin(): - #master1.delete() - #master2.delete() - #request.addfinalizer(fin) - - # Clear out the tmp dir - master1.clearTmpDir(__file__) + def fin(): + master1.delete() + master2.delete() + request.addfinalizer(fin)
return TopologyReplication(master1, master2)
@pytest.fixture(scope="module") - - def add_entry(server, name, rdntmpl, start, num): log.info("\n######################### Adding %d entries to %s ######################" % (num, name))
@@ -166,6 +162,7 @@ def add_entry(server, name, rdntmpl, start, num): log.error('Failed to add %s ' % dn + e.message['desc']) assert False
+ def enable_ssl(server, ldapsport, mycert): log.info("\n######################### Enabling SSL LDAPSPORT %s ######################\n" % ldapsport) server.simple_bind_s(DN_DM, PASSWORD) @@ -210,6 +207,7 @@ def doAndPrintIt(cmdline, filename): if filename is not None: fd.close()
+ def create_keys_certs(topology): log.info("\n######################### Creating SSL Keys and Certs ######################\n")
@@ -291,7 +289,7 @@ def create_keys_certs(topology): topology.master2.stop(timeout=10)
global mytmp - mytmp = topology.master1.getDir(__file__, TMP_DIR) + mytmp = '/tmp' m2pk12file = '%s/%s.pk12' % (mytmp, M2SERVERCERT) cmd = 'pk12util -o %s -n "%s" -d %s -w %s -k %s' % (m2pk12file, M2SERVERCERT, m1confdir, pwdfile, pwdfile) log.info("##### Extract PK12 file for master2: %s" % cmd) @@ -338,6 +336,7 @@ def create_keys_certs(topology):
log.info("\n######################### Creating SSL Keys and Certs Done ######################\n")
+ def config_tls_agreements(topology): log.info("######################### Configure SSL/TLS agreements ######################") log.info("######################## master1 <-- startTLS -> master2 #####################") @@ -357,6 +356,7 @@ def config_tls_agreements(topology):
log.info("\n######################### Configure SSL/TLS agreements Done ######################\n")
+ def set_ssl_Version(server, name, version): log.info("\n######################### Set %s on %s ######################\n", (version, name)) server.simple_bind_s(DN_DM, PASSWORD) @@ -374,6 +374,7 @@ def set_ssl_Version(server, name, version): log.info("Invalid version %s", version) assert False
+ def test_ticket48784(topology): """ Set up 2way MMR: @@ -381,7 +382,7 @@ def test_ticket48784(topology):
Make sure the replication is working. Then, stop the servers and set only SSLv3 on master_1 while TLS1.2 on master_2 - Replication is supposed to fail. + Replication is supposed to fail. """ log.info("Ticket 48784 - Allow usage of OpenLDAP libraries that don't use NSS for crypto")
@@ -392,7 +393,7 @@ def test_ticket48784(topology): add_entry(topology.master2, 'master2', 'uid=m2user', 0, 5)
time.sleep(1) - + log.info('##### Searching for entries on master1...') entries = topology.master1.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)') assert 10 == len(entries) diff --git a/dirsrvtests/tests/tickets/ticket48798_test.py b/dirsrvtests/tests/tickets/ticket48798_test.py index 7289453..f6f3911 100644 --- a/dirsrvtests/tests/tickets/ticket48798_test.py +++ b/dirsrvtests/tests/tickets/ticket48798_test.py @@ -29,7 +29,7 @@ class TopologyStandalone(object): @pytest.fixture(scope="module") def topology(request): # Creating standalone instance ... - standalone = DirSrv(verbose=True) + standalone = DirSrv(verbose=False) args_instance[SER_HOST] = HOST_STANDALONE args_instance[SER_PORT] = PORT_STANDALONE args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE @@ -44,17 +44,13 @@ def topology(request):
# Delete each instance in the end def fin(): - pass - #standalone.delete() + standalone.delete() request.addfinalizer(fin)
- # Clear out the tmp dir - #standalone.clearTmpDir(__file__) - return TopologyStandalone(standalone)
def check_socket_dh_param_size(hostname, port): - ### You know why we have to do this? + ### You know why we have to do this? # Because TLS and SSL suck. Hard. They are impossible. It's all terrible, burn it all down. cmd = "echo quit | openssl s_client -connect {HOSTNAME}:{PORT} -msg -cipher DH | grep -A 1 ServerKeyExchange".format( HOSTNAME=hostname, diff --git a/dirsrvtests/tests/tickets/ticket48844_test.py b/dirsrvtests/tests/tickets/ticket48844_test.py index 5b720e3..308ec17 100644 --- a/dirsrvtests/tests/tickets/ticket48844_test.py +++ b/dirsrvtests/tests/tickets/ticket48844_test.py @@ -56,7 +56,7 @@ def topology(request): # Delete each instance in the end def fin(): standalone.delete() - #request.addfinalizer(fin) + request.addfinalizer(fin)
# Clear out the tmp dir standalone.clearTmpDir(__file__) diff --git a/dirsrvtests/tests/tickets/ticket48891_test.py b/dirsrvtests/tests/tickets/ticket48891_test.py index bf2d1dd..ad6fd3a 100644 --- a/dirsrvtests/tests/tickets/ticket48891_test.py +++ b/dirsrvtests/tests/tickets/ticket48891_test.py @@ -73,8 +73,9 @@ def topology(request): # Used to retrieve configuration information (dbdir, confdir...) standalone.open()
- # clear the tmp directory - standalone.clearTmpDir(__file__) + def fin(): + standalone.delete() + request.addfinalizer(fin)
# Here we have standalone instance up and running return TopologyStandalone(standalone) @@ -92,7 +93,7 @@ def test_ticket48891_setup(topology): # bind as directory manager topology.standalone.log.info("Bind as %s" % DN_DM) topology.standalone.simple_bind_s(DN_DM, PASSWORD) - + # check there is no core entry = topology.standalone.search_s(CONFIG_DN, ldap.SCOPE_BASE, "(cn=config)",['nsslapd-workingdir']) assert entry @@ -139,7 +140,7 @@ def test_ticket48891_setup(topology):
topology.standalone.stop(timeout=1) - +
cores = fnmatch.filter(os.listdir(path), 'core.*') for core in cores: @@ -150,7 +151,6 @@ def test_ticket48891_setup(topology):
def test_ticket48891_final(topology): - #topology.standalone.delete() log.info('Testcase PASSED')
diff --git a/dirsrvtests/tests/tickets/ticket548_test.py b/dirsrvtests/tests/tickets/ticket548_test.py index d29fa53..a8562c2 100644 --- a/dirsrvtests/tests/tickets/ticket548_test.py +++ b/dirsrvtests/tests/tickets/ticket548_test.py @@ -67,9 +67,6 @@ def topology(request): standalone.delete() request.addfinalizer(fin)
- # Clear out the tmp dir - standalone.clearTmpDir(__file__) - return TopologyStandalone(standalone)
def days_to_secs(days): @@ -421,4 +418,4 @@ if __name__ == '__main__': # Run isolated # -s for DEBUG mode CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) + pytest.main("-s %s" % CURRENT_FILE)
389-commits@lists.fedoraproject.org