Branch '389-ds-base-1.3.4' - ldap/servers
by Ludwig Krispenz
ldap/servers/plugins/dna/dna.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
New commits:
commit c6fd6a19b690c1a64bbd7bc413caa39376660cb6
Author: Ludwig Krispenz <lkrispen(a)redhat.com>
Date: Mon Aug 31 10:55:26 2015 +0200
Ticket 48258 - dna plugin needs to handle binddn groups for authorization
Bug Description: if binddngroups are used to define replication
credentials then dna authorization fails
Fix Description: if bound user is not defined as binddn in
the replica check if binddngroups are
defined and if bound user is a member
https://fedorahosted.org/389/ticket/48258
Reviewed by: Noriko, Thanks.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 17a3b5e..5bd1cd6 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -89,6 +89,7 @@
/* Replication types */
#define DNA_REPL_BIND_DN "nsds5ReplicaBindDN"
+#define DNA_REPL_BIND_DNGROUP "nsds5ReplicaBindDNGroup"
#define DNA_REPL_CREDS "nsds5ReplicaCredentials"
#define DNA_REPL_BIND_METHOD "nsds5ReplicaBindMethod"
#define DNA_REPL_TRANSPORT "nsds5ReplicaTransportInfo"
@@ -2776,7 +2777,7 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
Slapi_DN *replica_sdn = NULL;
Slapi_DN *range_sdn = NULL;
Slapi_Entry *e = NULL;
- char *attrs[2];
+ char *attrs[3];
Slapi_Backend *be = NULL;
const char *be_suffix = NULL;
int ret = 0;
@@ -2789,7 +2790,7 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
/* Fetch the "cn=replica" entry for the backend that stores
* the shared config. We need to see what the configured
- * replica bind DN is. */
+ * replica bind DN is or if a bind DN group is defined. */
if (be_suffix) {
/* This function converts the old DN style to the new one. */
replica_dn = slapi_create_dn_string("cn=replica,cn=\"%s\",cn=mapping tree,cn=config", be_suffix);
@@ -2803,7 +2804,8 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
replica_sdn = slapi_sdn_new_normdn_passin(replica_dn);
attrs[0] = DNA_REPL_BIND_DN;
- attrs[1] = 0;
+ attrs[1] = DNA_REPL_BIND_DNGROUP;
+ attrs[2] = 0;
/* Find cn=replica entry via search */
slapi_search_internal_get_entry(replica_sdn, attrs, &e, getPluginID());
@@ -2812,6 +2814,34 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
/* Check if the passed in bind dn matches any of the replica bind dns. */
Slapi_Value *bind_dn_sv = slapi_value_new_string(bind_dn);
ret = slapi_entry_attr_has_syntax_value(e, DNA_REPL_BIND_DN, bind_dn_sv);
+ if (ret == 0) {
+ /* check if binddn is member of binddn group */
+ int i = 0;
+ Slapi_DN *bind_group_sdn = NULL;
+ Slapi_Entry *bind_group_entry = NULL;
+ char **bind_group_dn = slapi_entry_attr_get_charray(e, DNA_REPL_BIND_DNGROUP);
+ attrs[0] = "member";
+ attrs[1] = "uniquemember";
+ attrs[2] = 0;
+ for (i=0; bind_group_dn != NULL && bind_group_dn[i] != NULL; i++) {
+ if (ret) {
+ /* already found a member, just free group */
+ slapi_ch_free_string(&bind_group_dn[i]);
+ continue;
+ }
+ bind_group_sdn = slapi_sdn_new_normdn_passin(bind_group_dn[i]);
+ slapi_search_internal_get_entry(bind_group_sdn, attrs, &bind_group_entry, getPluginID());
+ if (bind_group_entry) {
+ ret = slapi_entry_attr_has_syntax_value(bind_group_entry, "member", bind_dn_sv);
+ if (ret == 0) {
+ ret = slapi_entry_attr_has_syntax_value(bind_group_entry, "uniquemember", bind_dn_sv);
+ }
+ }
+ slapi_entry_free(bind_group_entry);
+ slapi_sdn_free(&bind_group_sdn);
+ }
+ slapi_ch_free((void **) &bind_group_dn);
+ }
slapi_value_free(&bind_dn_sv);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
ldap/servers
by Ludwig Krispenz
ldap/servers/plugins/dna/dna.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
New commits:
commit 123df4dc081acffefad9ea68c64a7df92d93b63c
Author: Ludwig Krispenz <lkrispen(a)redhat.com>
Date: Mon Aug 31 10:55:26 2015 +0200
Ticket 48258 - dna plugin needs to handle binddn groups for authorization
Bug Description: if binddngroups are used to define replication
credentials then dna authorization fails
Fix Description: if bound user is not defined as binddn in
the replica check if binddngroups are
defined and if bound user is a member
https://fedorahosted.org/389/ticket/48258
Reviewed by: Noriko, Thanks.
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 17a3b5e..5bd1cd6 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -89,6 +89,7 @@
/* Replication types */
#define DNA_REPL_BIND_DN "nsds5ReplicaBindDN"
+#define DNA_REPL_BIND_DNGROUP "nsds5ReplicaBindDNGroup"
#define DNA_REPL_CREDS "nsds5ReplicaCredentials"
#define DNA_REPL_BIND_METHOD "nsds5ReplicaBindMethod"
#define DNA_REPL_TRANSPORT "nsds5ReplicaTransportInfo"
@@ -2776,7 +2777,7 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
Slapi_DN *replica_sdn = NULL;
Slapi_DN *range_sdn = NULL;
Slapi_Entry *e = NULL;
- char *attrs[2];
+ char *attrs[3];
Slapi_Backend *be = NULL;
const char *be_suffix = NULL;
int ret = 0;
@@ -2789,7 +2790,7 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
/* Fetch the "cn=replica" entry for the backend that stores
* the shared config. We need to see what the configured
- * replica bind DN is. */
+ * replica bind DN is or if a bind DN group is defined. */
if (be_suffix) {
/* This function converts the old DN style to the new one. */
replica_dn = slapi_create_dn_string("cn=replica,cn=\"%s\",cn=mapping tree,cn=config", be_suffix);
@@ -2803,7 +2804,8 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
replica_sdn = slapi_sdn_new_normdn_passin(replica_dn);
attrs[0] = DNA_REPL_BIND_DN;
- attrs[1] = 0;
+ attrs[1] = DNA_REPL_BIND_DNGROUP;
+ attrs[2] = 0;
/* Find cn=replica entry via search */
slapi_search_internal_get_entry(replica_sdn, attrs, &e, getPluginID());
@@ -2812,6 +2814,34 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
/* Check if the passed in bind dn matches any of the replica bind dns. */
Slapi_Value *bind_dn_sv = slapi_value_new_string(bind_dn);
ret = slapi_entry_attr_has_syntax_value(e, DNA_REPL_BIND_DN, bind_dn_sv);
+ if (ret == 0) {
+ /* check if binddn is member of binddn group */
+ int i = 0;
+ Slapi_DN *bind_group_sdn = NULL;
+ Slapi_Entry *bind_group_entry = NULL;
+ char **bind_group_dn = slapi_entry_attr_get_charray(e, DNA_REPL_BIND_DNGROUP);
+ attrs[0] = "member";
+ attrs[1] = "uniquemember";
+ attrs[2] = 0;
+ for (i=0; bind_group_dn != NULL && bind_group_dn[i] != NULL; i++) {
+ if (ret) {
+ /* already found a member, just free group */
+ slapi_ch_free_string(&bind_group_dn[i]);
+ continue;
+ }
+ bind_group_sdn = slapi_sdn_new_normdn_passin(bind_group_dn[i]);
+ slapi_search_internal_get_entry(bind_group_sdn, attrs, &bind_group_entry, getPluginID());
+ if (bind_group_entry) {
+ ret = slapi_entry_attr_has_syntax_value(bind_group_entry, "member", bind_dn_sv);
+ if (ret == 0) {
+ ret = slapi_entry_attr_has_syntax_value(bind_group_entry, "uniquemember", bind_dn_sv);
+ }
+ }
+ slapi_entry_free(bind_group_entry);
+ slapi_sdn_free(&bind_group_sdn);
+ }
+ slapi_ch_free((void **) &bind_group_dn);
+ }
slapi_value_free(&bind_dn_sv);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.3.3' - dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47931_test.py | 207 ++++++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
New commits:
commit e7d3b2f120e0a3e9ce642733b803686fbcc49222
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Aug 28 15:01:58 2015 -0400
Ticket 47931 - lib389 test - memberof and retrocl deadlock
Description: lib389 test to verify deadlock is resolved by setting
the retrocl scope to a single backend.
https://fedorahosted.org/389/ticket/47931
Reviewed by: ?
(cherry picked from commit 48470e7a6b0a350149ced0a1377e625b836dba64)
diff --git a/dirsrvtests/tickets/ticket47931_test.py b/dirsrvtests/tickets/ticket47931_test.py
new file mode 100644
index 0000000..9aa54fc
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47931_test.py
@@ -0,0 +1,207 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import threading
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+SECOND_SUFFIX = "dc=deadlock"
+SECOND_BACKEND = "deadlock"
+RETROCL_PLUGIN_DN = ('cn=' + PLUGIN_RETRO_CHANGELOG + ',cn=plugins,cn=config')
+MEMBEROF_PLUGIN_DN = ('cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config')
+GROUP_DN = ("cn=group," + DEFAULT_SUFFIX)
+MEMBER_DN_COMP = "uid=member"
+TIME_OUT = 5
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+class modifySecondBackendThread(threading.Thread):
+ def __init__(self, inst, timeout):
+ threading.Thread.__init__(self)
+ self.daemon = True
+ self.inst = inst
+ self.timeout = timeout
+
+ def run(self):
+ conn = self.inst.openConnection()
+ conn.set_option(ldap.OPT_TIMEOUT, self.timeout)
+ log.info('Modify second suffix...')
+ for x in range(0, 5000):
+ try:
+ conn.modify_s(SECOND_SUFFIX,
+ [(ldap.MOD_REPLACE,
+ 'description',
+ 'new description')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify second suffix - error: %s' %
+ (e.message['desc']))
+ assert False
+
+ conn.close()
+ log.info('Finished modifying second suffix')
+
+
+(a)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)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket47931(topology):
+ """Test Retro Changelog and MemberOf deadlock fix.
+ Verification steps:
+ - Enable retro cl and memberOf.
+ - Create two backends: A & B.
+ - Configure retrocl scoping for backend A.
+ - Configure memberOf plugin for uniquemember
+ - Create group in backend A.
+ - In parallel, add members to the group on A, and make modifications
+ to entries in backend B.
+ - Make sure the server does not hang during the updates to both
+ backends.
+
+ """
+
+ # Enable dynamic plugins to make plugin configuration easier
+ try:
+ topology.standalone.modify_s(DN_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-dynamic-plugins',
+ 'on')])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to enable dynamic plugins! ' + e.message['desc'])
+ assert False
+
+ # Enable the plugins
+ topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF)
+ topology.standalone.plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
+
+ # Create second backend
+ topology.standalone.backend.create(SECOND_SUFFIX, {BACKEND_NAME: SECOND_BACKEND})
+ topology.standalone.mappingtree.create(SECOND_SUFFIX, bename=SECOND_BACKEND)
+
+ # Create the root node of the second backend
+ try:
+ topology.standalone.add_s(Entry((SECOND_SUFFIX,
+ {'objectclass': 'top domain'.split(),
+ 'dc': 'deadlock'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to create suffix entry: error ' + e.message['desc'])
+ assert False
+
+ # Configure retrocl scope
+ try:
+ topology.standalone.modify_s(RETROCL_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-include-suffix',
+ DEFAULT_SUFFIX)])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to configure retrocl plugin: ' + e.message['desc'])
+ assert False
+
+ # Configure memberOf group attribute
+ try:
+ topology.standalone.modify_s(MEMBEROF_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'memberofgroupattr',
+ 'uniquemember')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to configure memberOf plugin: error ' + e.message['desc'])
+ assert False
+
+ # Create group
+ try:
+ topology.standalone.add_s(Entry((GROUP_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'cn': 'group'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add grouo: error ' + e.message['desc'])
+ assert False
+
+ # Create 1500 entries (future members of the group)
+ for idx in range(1, 1500):
+ try:
+ USER_DN = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.add_s(Entry((USER_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'uid': 'member%d' % (x)})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add user (%s): error %s' % (USER_DN, e.message['desc']))
+ assert False
+
+ # Modify second backend (separate thread)
+ mod_backend_thrd = modifySecondBackendThread(topology.standalone, TIME_OUT)
+ mod_backend_thrd.start()
+
+ # Add members to the group - set timeout
+ log.info('Adding members to the group...')
+ topology.standalone.set_option(ldap.OPT_TIMEOUT, TIME_OUT)
+ for idx in range(1, 1500):
+ try:
+ MEMBER_VAL = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.modify_s(GROUP_DN,
+ [(ldap.MOD_ADD,
+ 'uniquemember',
+ MEMBER_VAL)])
+ except ldap.TIMEOUT:
+ log.fatal('Deadlock! Bug verification failed.')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to update group(not a deadlock) member (%s) - error: %s' %
+ (MEMBER_VAL, e.message['desc']))
+ assert False
+ log.info('Finished adding members to the group.')
+
+ # Wait for the thread to finish
+ mod_backend_thrd.join()
+
+ # No timeout, test passed!
+ log.info('Test complete\n')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
\ No newline at end of file
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.3.4' - dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47931_test.py | 207 ++++++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
New commits:
commit 22e4de79107e49af74e0ff7615552b61db240b71
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Aug 28 15:01:58 2015 -0400
Ticket 47931 - lib389 test - memberof and retrocl deadlock
Description: lib389 test to verify deadlock is resolved by setting
the retrocl scope to a single backend.
https://fedorahosted.org/389/ticket/47931
Reviewed by: ?
(cherry picked from commit 48470e7a6b0a350149ced0a1377e625b836dba64)
diff --git a/dirsrvtests/tickets/ticket47931_test.py b/dirsrvtests/tickets/ticket47931_test.py
new file mode 100644
index 0000000..9aa54fc
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47931_test.py
@@ -0,0 +1,207 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import threading
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+SECOND_SUFFIX = "dc=deadlock"
+SECOND_BACKEND = "deadlock"
+RETROCL_PLUGIN_DN = ('cn=' + PLUGIN_RETRO_CHANGELOG + ',cn=plugins,cn=config')
+MEMBEROF_PLUGIN_DN = ('cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config')
+GROUP_DN = ("cn=group," + DEFAULT_SUFFIX)
+MEMBER_DN_COMP = "uid=member"
+TIME_OUT = 5
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+class modifySecondBackendThread(threading.Thread):
+ def __init__(self, inst, timeout):
+ threading.Thread.__init__(self)
+ self.daemon = True
+ self.inst = inst
+ self.timeout = timeout
+
+ def run(self):
+ conn = self.inst.openConnection()
+ conn.set_option(ldap.OPT_TIMEOUT, self.timeout)
+ log.info('Modify second suffix...')
+ for x in range(0, 5000):
+ try:
+ conn.modify_s(SECOND_SUFFIX,
+ [(ldap.MOD_REPLACE,
+ 'description',
+ 'new description')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify second suffix - error: %s' %
+ (e.message['desc']))
+ assert False
+
+ conn.close()
+ log.info('Finished modifying second suffix')
+
+
+(a)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)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket47931(topology):
+ """Test Retro Changelog and MemberOf deadlock fix.
+ Verification steps:
+ - Enable retro cl and memberOf.
+ - Create two backends: A & B.
+ - Configure retrocl scoping for backend A.
+ - Configure memberOf plugin for uniquemember
+ - Create group in backend A.
+ - In parallel, add members to the group on A, and make modifications
+ to entries in backend B.
+ - Make sure the server does not hang during the updates to both
+ backends.
+
+ """
+
+ # Enable dynamic plugins to make plugin configuration easier
+ try:
+ topology.standalone.modify_s(DN_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-dynamic-plugins',
+ 'on')])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to enable dynamic plugins! ' + e.message['desc'])
+ assert False
+
+ # Enable the plugins
+ topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF)
+ topology.standalone.plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
+
+ # Create second backend
+ topology.standalone.backend.create(SECOND_SUFFIX, {BACKEND_NAME: SECOND_BACKEND})
+ topology.standalone.mappingtree.create(SECOND_SUFFIX, bename=SECOND_BACKEND)
+
+ # Create the root node of the second backend
+ try:
+ topology.standalone.add_s(Entry((SECOND_SUFFIX,
+ {'objectclass': 'top domain'.split(),
+ 'dc': 'deadlock'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to create suffix entry: error ' + e.message['desc'])
+ assert False
+
+ # Configure retrocl scope
+ try:
+ topology.standalone.modify_s(RETROCL_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-include-suffix',
+ DEFAULT_SUFFIX)])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to configure retrocl plugin: ' + e.message['desc'])
+ assert False
+
+ # Configure memberOf group attribute
+ try:
+ topology.standalone.modify_s(MEMBEROF_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'memberofgroupattr',
+ 'uniquemember')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to configure memberOf plugin: error ' + e.message['desc'])
+ assert False
+
+ # Create group
+ try:
+ topology.standalone.add_s(Entry((GROUP_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'cn': 'group'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add grouo: error ' + e.message['desc'])
+ assert False
+
+ # Create 1500 entries (future members of the group)
+ for idx in range(1, 1500):
+ try:
+ USER_DN = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.add_s(Entry((USER_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'uid': 'member%d' % (x)})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add user (%s): error %s' % (USER_DN, e.message['desc']))
+ assert False
+
+ # Modify second backend (separate thread)
+ mod_backend_thrd = modifySecondBackendThread(topology.standalone, TIME_OUT)
+ mod_backend_thrd.start()
+
+ # Add members to the group - set timeout
+ log.info('Adding members to the group...')
+ topology.standalone.set_option(ldap.OPT_TIMEOUT, TIME_OUT)
+ for idx in range(1, 1500):
+ try:
+ MEMBER_VAL = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.modify_s(GROUP_DN,
+ [(ldap.MOD_ADD,
+ 'uniquemember',
+ MEMBER_VAL)])
+ except ldap.TIMEOUT:
+ log.fatal('Deadlock! Bug verification failed.')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to update group(not a deadlock) member (%s) - error: %s' %
+ (MEMBER_VAL, e.message['desc']))
+ assert False
+ log.info('Finished adding members to the group.')
+
+ # Wait for the thread to finish
+ mod_backend_thrd.join()
+
+ # No timeout, test passed!
+ log.info('Test complete\n')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
\ No newline at end of file
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47931_test.py | 207 ++++++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
New commits:
commit 48470e7a6b0a350149ced0a1377e625b836dba64
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Aug 28 15:01:58 2015 -0400
Ticket 47931 - lib389 test - memberof and retrocl deadlock
Description: lib389 test to verify deadlock is resolved by setting
the retrocl scope to a single backend.
https://fedorahosted.org/389/ticket/47931
Reviewed by: ?
diff --git a/dirsrvtests/tickets/ticket47931_test.py b/dirsrvtests/tickets/ticket47931_test.py
new file mode 100644
index 0000000..9aa54fc
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47931_test.py
@@ -0,0 +1,207 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import threading
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+SECOND_SUFFIX = "dc=deadlock"
+SECOND_BACKEND = "deadlock"
+RETROCL_PLUGIN_DN = ('cn=' + PLUGIN_RETRO_CHANGELOG + ',cn=plugins,cn=config')
+MEMBEROF_PLUGIN_DN = ('cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config')
+GROUP_DN = ("cn=group," + DEFAULT_SUFFIX)
+MEMBER_DN_COMP = "uid=member"
+TIME_OUT = 5
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+class modifySecondBackendThread(threading.Thread):
+ def __init__(self, inst, timeout):
+ threading.Thread.__init__(self)
+ self.daemon = True
+ self.inst = inst
+ self.timeout = timeout
+
+ def run(self):
+ conn = self.inst.openConnection()
+ conn.set_option(ldap.OPT_TIMEOUT, self.timeout)
+ log.info('Modify second suffix...')
+ for x in range(0, 5000):
+ try:
+ conn.modify_s(SECOND_SUFFIX,
+ [(ldap.MOD_REPLACE,
+ 'description',
+ 'new description')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify second suffix - error: %s' %
+ (e.message['desc']))
+ assert False
+
+ conn.close()
+ log.info('Finished modifying second suffix')
+
+
+(a)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)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket47931(topology):
+ """Test Retro Changelog and MemberOf deadlock fix.
+ Verification steps:
+ - Enable retro cl and memberOf.
+ - Create two backends: A & B.
+ - Configure retrocl scoping for backend A.
+ - Configure memberOf plugin for uniquemember
+ - Create group in backend A.
+ - In parallel, add members to the group on A, and make modifications
+ to entries in backend B.
+ - Make sure the server does not hang during the updates to both
+ backends.
+
+ """
+
+ # Enable dynamic plugins to make plugin configuration easier
+ try:
+ topology.standalone.modify_s(DN_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-dynamic-plugins',
+ 'on')])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to enable dynamic plugins! ' + e.message['desc'])
+ assert False
+
+ # Enable the plugins
+ topology.standalone.plugins.enable(name=PLUGIN_MEMBER_OF)
+ topology.standalone.plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
+
+ # Create second backend
+ topology.standalone.backend.create(SECOND_SUFFIX, {BACKEND_NAME: SECOND_BACKEND})
+ topology.standalone.mappingtree.create(SECOND_SUFFIX, bename=SECOND_BACKEND)
+
+ # Create the root node of the second backend
+ try:
+ topology.standalone.add_s(Entry((SECOND_SUFFIX,
+ {'objectclass': 'top domain'.split(),
+ 'dc': 'deadlock'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to create suffix entry: error ' + e.message['desc'])
+ assert False
+
+ # Configure retrocl scope
+ try:
+ topology.standalone.modify_s(RETROCL_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-include-suffix',
+ DEFAULT_SUFFIX)])
+ except ldap.LDAPError as e:
+ ldap.error('Failed to configure retrocl plugin: ' + e.message['desc'])
+ assert False
+
+ # Configure memberOf group attribute
+ try:
+ topology.standalone.modify_s(MEMBEROF_PLUGIN_DN,
+ [(ldap.MOD_REPLACE,
+ 'memberofgroupattr',
+ 'uniquemember')])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to configure memberOf plugin: error ' + e.message['desc'])
+ assert False
+
+ # Create group
+ try:
+ topology.standalone.add_s(Entry((GROUP_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'cn': 'group'})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add grouo: error ' + e.message['desc'])
+ assert False
+
+ # Create 1500 entries (future members of the group)
+ for idx in range(1, 1500):
+ try:
+ USER_DN = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.add_s(Entry((USER_DN,
+ {'objectclass': 'top extensibleObject'.split(),
+ 'uid': 'member%d' % (x)})))
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add user (%s): error %s' % (USER_DN, e.message['desc']))
+ assert False
+
+ # Modify second backend (separate thread)
+ mod_backend_thrd = modifySecondBackendThread(topology.standalone, TIME_OUT)
+ mod_backend_thrd.start()
+
+ # Add members to the group - set timeout
+ log.info('Adding members to the group...')
+ topology.standalone.set_option(ldap.OPT_TIMEOUT, TIME_OUT)
+ for idx in range(1, 1500):
+ try:
+ MEMBER_VAL = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))
+ topology.standalone.modify_s(GROUP_DN,
+ [(ldap.MOD_ADD,
+ 'uniquemember',
+ MEMBER_VAL)])
+ except ldap.TIMEOUT:
+ log.fatal('Deadlock! Bug verification failed.')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to update group(not a deadlock) member (%s) - error: %s' %
+ (MEMBER_VAL, e.message['desc']))
+ assert False
+ log.info('Finished adding members to the group.')
+
+ # Wait for the thread to finish
+ mod_backend_thrd.join()
+
+ # No timeout, test passed!
+ log.info('Test complete\n')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
\ No newline at end of file
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 73 ++++++++++++++++++++++---------
1 file changed, 54 insertions(+), 19 deletions(-)
New commits:
commit 6a1f2f0977ef04dc06b13c7efa3fd35e8f858eab
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Aug 28 12:47:42 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Bug Description: When an entry is deleted, its indexed attribute values
are also removed from each index file. But if the entry is turned to be
a tombstone entry, reindexing adds the removed attribute value back to
the index file.
Fix Description: In the reindexing function ldbm_back_ldbm2index, if the
entry is a tombstone entry, it skips reindexing operation unless the target
attribute is entryrdn or objectclass. If it is reindexing the objectclass,
it indexes just for the key "=nstombstone".
https://fedorahosted.org/389/ticket/48252
Reviewed by mreynolds(a)redhat.com and rmeggins(a)redhat.com (Thank you, Mark and Rich!!)
(cherry picked from commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556)
(cherry picked from commit 86b96278871d8b08f7c6a75379935c2183f6668f)
(cherry picked from commit ef0a2954cba650364ba4c48038d69731ebe19387)
Note: This patch contains the memory leak fixes.
(commit 4277f2ba4f1bb24efc771ea0fa02354654db255c)
(commit 8c9c2fcb14843089a7b5abd02ab1738249b64516)
(commit f10e2e633ad9c55bc2b42bceef3f9635d7ac5b7c)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 76eea2c..2d99a01 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -54,9 +54,12 @@
static char *sourcefile = "ldif2ldbm.c";
-#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
-#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
-#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
+#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
+#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_OBJECTCLASS 0x10 /* for reindexing "objectclass: nstombstone" */
+
+#define LDIF2LDBM_EXTBITS(x) ((x) & 0xf)
typedef struct _export_args {
struct backentry *ep;
@@ -1679,6 +1682,8 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
struct vlvIndex *vlvip = NULL;
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
+ Slapi_Value **nstombstone_vals = NULL;
+ int istombstone = 0;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -1799,7 +1804,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (strcasecmp(attrs[i]+1, LDBM_ANCESTORID_STR) == 0) {
if (task) {
slapi_task_log_notice(task, "%s: Indexing %s",
- inst->inst_name, LDBM_ENTRYRDN_STR);
+ inst->inst_name, LDBM_ANCESTORID_STR);
}
LDAPDebug2Args(LDAP_DEBUG_ANY, "%s: Indexing %s\n",
inst->inst_name, LDBM_ANCESTORID_STR);
@@ -1852,6 +1857,9 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
inst->inst_name, attrs[i] + 1);
}
} else {
+ if (strcasecmp(attrs[i]+1, SLAPI_ATTR_OBJECTCLASS) == 0) {
+ index_ext |= DB2INDEX_OBJECTCLASS;
+ }
charray_add(&indexAttrs, attrs[i]+1);
ai->ai_indexmask |= INDEX_OFFLINE;
if (task) {
@@ -1897,7 +1905,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* idl composed from the ancestorid list, instead of traversing the
* entire database.
*/
- if (!indexAttrs && !index_ext && pvlv) {
+ if (!indexAttrs && !LDIF2LDBM_EXTBITS(index_ext) && pvlv) {
int err;
char **suffix_list = NULL;
@@ -2154,20 +2162,46 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
/*
+ * If this entry is a tombstone, set nstombstone_vals for reindexing "objectclass: nstombstone"
+ */
+ if (ep->ep_entry->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ istombstone = 1;
+ if (!nstombstone_vals) {
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ }
+ } else {
+ istombstone = 0;
+ }
+ /*
* Update the attribute indexes
*/
- if (indexAttrs != NULL) {
+ if (indexAttrs) {
+ if (istombstone && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ /* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
+ * need to be reindexed. the to-be-indexed list does not contain them. */
+ backentry_free( &ep );
+ continue;
+ }
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
i = slapi_entry_next_attr(ep->ep_entry, attr, &attr)) {
Slapi_Value **svals;
slapi_attr_get_type( attr, &type );
for ( j = 0; indexAttrs[j] != NULL; j++ ) {
+ int is_tombstone_obj = 0;
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if (slapi_attr_type_cmp(indexAttrs[j], type,
- SLAPI_TYPE_CMP_SUBTYPE) == 0 ) {
+ if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
+ if (istombstone) {
+ if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
+ is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
+ } else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
+ /* Entry is a tombstone && this index is not an entryrdn. */
+ continue;
+ }
+ }
svals = attr_get_present_values(attr);
if (!run_from_cmdline) {
@@ -2191,10 +2225,12 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
}
- rc = index_addordel_values_sv(
- be, indexAttrs[j], svals,
- NULL, ep->ep_id, BE_INDEX_ADD, &txn);
- if (rc != 0) {
+ if (is_tombstone_obj) {
+ rc = index_addordel_values_sv(be, indexAttrs[j], nstombstone_vals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ } else {
+ rc = index_addordel_values_sv(be, indexAttrs[j], svals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ }
+ if (rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to update index '%s'\n",
inst->inst_name, indexAttrs[j], 0);
@@ -2240,18 +2276,16 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
/*
- * Update the Virtual List View indexes
+ * If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ for (vlvidx = 0; !istombstone && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if(indexAttrs){
- if(indexAttrs[vlvidx]){
- ai = indexAttrs[vlvidx];
- }
+ if (indexAttrs && indexAttrs[vlvidx]) {
+ ai = indexAttrs[vlvidx];
}
if (!run_from_cmdline) {
rc = dblayer_txn_begin(li, NULL, &txn);
@@ -2305,7 +2339,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* Update the ancestorid and entryrdn index
*/
- if (!entryrdn_get_noancestorid() && index_ext & DB2INDEX_ANCESTORID) {
+ if (!entryrdn_get_noancestorid() && (index_ext & DB2INDEX_ANCESTORID)) {
rc = ldbm_ancestorid_index_entry(be, ep, BE_INDEX_ADD, NULL);
if (rc != 0) {
LDAPDebug(LDAP_DEBUG_ANY,
@@ -2469,6 +2503,7 @@ err_min:
}
}
+ valuearray_free(&nstombstone_vals);
if (indexAttrs) {
slapi_ch_free((void **)&indexAttrs);
}
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit f10e2e633ad9c55bc2b42bceef3f9635d7ac5b7c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Aug 27 17:04:53 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Description: Commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556 fixing
ticket #48252 introduced memory leaks.
. nstombstone_vals needs to be allocated just once and freed at the end.
. when skipping to index an entry for being a tombstone, the entry needs
to be freed.
https://fedorahosted.org/389/ticket/48252
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 4277f2ba4f1bb24efc771ea0fa02354654db255c)
(cherry picked from commit 8c9c2fcb14843089a7b5abd02ab1738249b64516)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 5d18bfc..68e596b 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1708,6 +1708,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
Slapi_Value **nstombstone_vals = NULL;
+ int istombstone = 0;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2192,8 +2193,11 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
const CSN *tombstone_csn = entry_get_deletion_csn(ep->ep_entry);
char deletion_csn_str[CSN_STRSIZE];
- nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
- *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ istombstone = 1;
+ if (!nstombstone_vals) {
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ }
if (tombstone_csn) {
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
@@ -2248,15 +2252,18 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
}
}
+ } else {
+ istombstone = 0;
}
/*
* Update the attribute indexes
*/
if (indexAttrs) {
- if (nstombstone_vals && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ if (istombstone && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
/* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
* need to be reindexed. the to-be-indexed list does not contain them. */
+ backentry_free( &ep );
continue;
}
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
@@ -2270,7 +2277,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
- if (nstombstone_vals) {
+ if (istombstone) {
if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
} else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
@@ -2354,7 +2361,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for (vlvidx = 0; !nstombstone_vals && (vlvidx < numvlv); vlvidx++) {
+ for (vlvidx = 0; !istombstone && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2579,6 +2586,7 @@ err_min:
}
}
+ valuearray_free(&nstombstone_vals);
if (indexAttrs) {
slapi_ch_free((void **)&indexAttrs);
}
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.3.4' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 8c9c2fcb14843089a7b5abd02ab1738249b64516
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Aug 27 17:04:53 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Description: Commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556 fixing
ticket #48252 introduced memory leaks.
. nstombstone_vals needs to be allocated just once and freed at the end.
. when skipping to index an entry for being a tombstone, the entry needs
to be freed.
https://fedorahosted.org/389/ticket/48252
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 4277f2ba4f1bb24efc771ea0fa02354654db255c)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 3d07b2e..150a008 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1679,6 +1679,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
Slapi_Value **nstombstone_vals = NULL;
+ int istombstone = 0;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2163,8 +2164,11 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
const CSN *tombstone_csn = entry_get_deletion_csn(ep->ep_entry);
char deletion_csn_str[CSN_STRSIZE];
- nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
- *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ istombstone = 1;
+ if (!nstombstone_vals) {
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ }
if (tombstone_csn) {
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
@@ -2219,15 +2223,18 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
}
}
+ } else {
+ istombstone = 0;
}
/*
* Update the attribute indexes
*/
if (indexAttrs) {
- if (nstombstone_vals && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ if (istombstone && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
/* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
* need to be reindexed. the to-be-indexed list does not contain them. */
+ backentry_free( &ep );
continue;
}
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
@@ -2241,7 +2248,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
- if (nstombstone_vals) {
+ if (istombstone) {
if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
} else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
@@ -2325,7 +2332,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for (vlvidx = 0; !nstombstone_vals && (vlvidx < numvlv); vlvidx++) {
+ for (vlvidx = 0; !istombstone && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2550,6 +2557,7 @@ err_min:
}
}
+ valuearray_free(&nstombstone_vals);
if (indexAttrs) {
slapi_ch_free((void **)&indexAttrs);
}
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 4277f2ba4f1bb24efc771ea0fa02354654db255c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Aug 27 17:04:53 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Description: Commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556 fixing
ticket #48252 introduced memory leaks.
. nstombstone_vals needs to be allocated just once and freed at the end.
. when skipping to index an entry for being a tombstone, the entry needs
to be freed.
https://fedorahosted.org/389/ticket/48252
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 3d07b2e..150a008 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1679,6 +1679,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
Slapi_Value **nstombstone_vals = NULL;
+ int istombstone = 0;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2163,8 +2164,11 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
const CSN *tombstone_csn = entry_get_deletion_csn(ep->ep_entry);
char deletion_csn_str[CSN_STRSIZE];
- nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
- *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ istombstone = 1;
+ if (!nstombstone_vals) {
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ }
if (tombstone_csn) {
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
@@ -2219,15 +2223,18 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
}
}
+ } else {
+ istombstone = 0;
}
/*
* Update the attribute indexes
*/
if (indexAttrs) {
- if (nstombstone_vals && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ if (istombstone && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
/* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
* need to be reindexed. the to-be-indexed list does not contain them. */
+ backentry_free( &ep );
continue;
}
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
@@ -2241,7 +2248,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
- if (nstombstone_vals) {
+ if (istombstone) {
if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
} else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
@@ -2325,7 +2332,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for (vlvidx = 0; !nstombstone_vals && (vlvidx < numvlv); vlvidx++) {
+ for (vlvidx = 0; !istombstone && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -2550,6 +2557,7 @@ err_min:
}
}
+ valuearray_free(&nstombstone_vals);
if (indexAttrs) {
slapi_ch_free((void **)&indexAttrs);
}
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months
Branch '389-ds-base-1.3.4' - dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 265 ++++++++++++++++-----------------
1 file changed, 132 insertions(+), 133 deletions(-)
New commits:
commit 326f73fe2d7897397f74250d6d815729d46c73a1
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Wed Aug 19 17:46:10 2015 +0200
Ticket 48251 - Improve the basic test suite
Description: Refactor basic suite code, because it should
correspond pytest and PEP 8 standarts.
Added a minor fix(that addresses false failures)
written by Mark Reynolds
https://fedorahosted.org/389/ticket/48251
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit ee96ec73de037ae666edaeef584f8b8e48527ab5)
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index d35f7d9..0c1b83b 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -40,9 +40,8 @@ class TopologyStandalone(object):
@pytest.fixture(scope="module")
def topology(request):
- '''
- This fixture is used to standalone topology for the 'module'.
- '''
+ """This fixture is used to standalone topology for the 'module'."""
+
global installation_prefix
if installation_prefix:
@@ -70,6 +69,11 @@ def topology(request):
# Used to retrieve configuration information (dbdir, confdir...)
standalone.open()
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
# clear the tmp directory
standalone.clearTmpDir(__file__)
@@ -77,27 +81,24 @@ def topology(request):
return TopologyStandalone(standalone)
-def test_basic_init(topology):
- '''
- Initialize our setup
- '''
- #
- # Import the Example LDIF for the tests in this suite
- #
+(a)pytest.fixture(scope="module")
+def import_example_ldif(topology):
+ """Import the Example LDIF for the tests in this suite"""
+
log.info('Initializing the "basic" test suite')
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.error('Online import failed')
assert False
-def test_basic_ops(topology):
- '''
- Test doing adds, mods, modrdns, and deletes
- '''
+def test_basic_ops(topology, import_example_ldif):
+ """Test doing adds, mods, modrdns, and deletes"""
log.info('Running test_basic_ops...')
@@ -113,31 +114,34 @@ def test_basic_ops(topology):
# Adds
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user1',
- 'uid': 'user1',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user1',
+ 'uid': 'user1',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER1_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user2',
- 'uid': 'user2',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user2',
+ 'uid': 'user2',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER2_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER3_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '3',
- 'cn': 'user3',
- 'uid': 'user3',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER3_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '3',
+ 'cn': 'user3',
+ 'uid': 'user3',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER3_DN + ': error ' + e.message['desc'])
assert False
@@ -146,19 +150,22 @@ def test_basic_ops(topology):
# Mods
#
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description', 'New description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description',
+ 'New description')])
except ldap.LDAPError, e:
log.error('Failed to add description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description', 'Modified description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description',
+ 'Modified description')])
except ldap.LDAPError, e:
log.error('Failed to modify description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description', None)])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description',
+ None)])
except ldap.LDAPError, e:
log.error('Failed to delete description: error ' + e.message['desc'])
assert False
@@ -180,7 +187,8 @@ def test_basic_ops(topology):
# Modrdn - New superior
try:
- topology.standalone.rename_s(USER3_DN, USER3_NEWDN, newsuperior=NEW_SUPERIOR, delold=1)
+ topology.standalone.rename_s(USER3_DN, USER3_NEWDN,
+ newsuperior=NEW_SUPERIOR, delold=1)
except ldap.LDAPError, e:
log.error('Failed to modrdn(new superior) user3: error ' + e.message['desc'])
assert False
@@ -209,10 +217,8 @@ def test_basic_ops(topology):
log.info('test_basic_ops: PASSED')
-def test_basic_import_export(topology):
- '''
- Test online and offline LDIF imports & exports
- '''
+def test_basic_import_export(topology, import_example_ldif):
+ """Test online and offline LDIF imports & exports"""
log.info('Running test_basic_import_export...')
@@ -227,12 +233,14 @@ def test_basic_import_export(topology):
try:
topology.standalone.buildLDIF(50000, import_ldif)
except OSError as e:
- log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
+ log.fatal('test_basic_import_export: failed to create test ldif,\
+ error: %s - %s' % (e.errno, e.strerror))
assert False
# Online
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif,
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
@@ -258,7 +266,8 @@ def test_basic_import_export(topology):
assert False
# Offline export
- if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,), None, None, None, export_ldif):
+ if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
+ None, None, None, export_ldif):
log.fatal('test_basic_import_export: Failed to run offline db2ldif')
assert False
@@ -267,7 +276,9 @@ def test_basic_import_export(topology):
#
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
assert False
@@ -275,10 +286,8 @@ def test_basic_import_export(topology):
log.info('test_basic_import_export: PASSED')
-def test_basic_backup(topology):
- '''
- Test online and offline back and restore
- '''
+def test_basic_backup(topology, import_example_ldif):
+ """Test online and offline back and restore"""
log.info('Running test_basic_backup...')
@@ -286,14 +295,16 @@ def test_basic_backup(topology):
# Test online backup
try:
- topology.standalone.tasks.db2bak(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.db2bak(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online backup failed')
assert False
# Test online restore
try:
- topology.standalone.tasks.bak2db(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.bak2db(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online restore failed')
assert False
@@ -311,10 +322,8 @@ def test_basic_backup(topology):
log.info('test_basic_backup: PASSED')
-def test_basic_acl(topology):
- '''
- Run some basic access control(ACL) tests
- '''
+def test_basic_acl(topology, import_example_ldif):
+ """Run some basic access control(ACL) tests"""
log.info('Running test_basic_acl...')
@@ -325,27 +334,32 @@ def test_basic_acl(topology):
# Add two users
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user 1',
- 'uid': 'user1',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user 1',
+ 'uid': 'user1',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user 2',
- 'uid': 'user2',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user 2',
+ 'uid': 'user2',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
#
- # Add an aci that denies USER1 from doing anything, and also set the default anonymous access
+ # Add an aci that denies USER1 from doing anything,
+ # and also set the default anonymous access
#
try:
topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', DENY_ACI)])
@@ -363,7 +377,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if entries:
log.fatal('test_basic_acl: User1 was incorrectly able to search the suffix!')
assert False
@@ -379,7 +395,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=user1)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=user1)')
if not entries:
log.fatal('test_basic_acl: User1 incorrectly not able to search the suffix')
assert False
@@ -400,7 +418,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if not entries:
log.fatal('test_basic_acl: Root DN incorrectly not able to search the suffix')
assert False
@@ -432,10 +452,8 @@ def test_basic_acl(topology):
log.info('test_basic_acl: PASSED')
-def test_basic_searches(topology):
- '''
- The search results are gathered from testing with Example.ldif
- '''
+def test_basic_searches(topology, import_example_ldif):
+ """The search results are gathered from testing with Example.ldif"""
log.info('Running test_basic_searches...')
@@ -458,9 +476,12 @@ def test_basic_searches(topology):
for (search_filter, search_result) in filters:
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter)
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ search_filter)
if len(entries) != search_result:
- log.fatal('test_basic_searches: An incorrect number of entries was returned from filter (%s): (%d) expected (%d)' %
+ log.fatal('test_basic_searches: An incorrect number of entries\
+ was returned from filter (%s): (%d) expected (%d)' %
(search_filter, len(entries), search_result))
assert False
except ldap.LDAPError, e:
@@ -470,10 +491,10 @@ def test_basic_searches(topology):
log.info('test_basic_searches: PASSED')
-def test_basic_referrals(topology):
- '''
- Set the server to referral mode, and make sure we recive the referal error(10)
- '''
+def test_basic_referrals(topology, import_example_ldif):
+ """Set the server to referral mode,
+ and make sure we recive the referal error(10)
+ """
log.info('Running test_basic_referrals...')
@@ -483,16 +504,20 @@ def test_basic_referrals(topology):
# Set the referral, adn the backend state
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-referral',
- 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
+ topology.standalone.modify_s(SUFFIX_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-referral',
+ 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
except ldap.LDAPError, e:
log.fatal('test_basic_referrals: Failed to set referral: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Referral')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Referral')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
#
@@ -516,26 +541,29 @@ def test_basic_referrals(topology):
# Cleanup
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Backend')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Backend')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE, 'nsslapd-referral', None)])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE,
+ 'nsslapd-referral', None)])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to delete referral: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to delete referral: error '
+ + e.message['desc'])
assert False
topology.standalone.set_option(ldap.OPT_REFERRALS, 1)
log.info('test_basic_referrals: PASSED')
-def test_basic_systemctl(topology):
- '''
- Test systemctl can stop and start the server. Also test that start reports an
+def test_basic_systemctl(topology, import_example_ldif):
+ """Test systemctl can stop and start the server. Also test that start reports an
error when the instance does not start. Only for RPM builds
- '''
+ """
log.info('Running test_basic_systemctl...')
@@ -596,12 +624,13 @@ def test_basic_systemctl(topology):
log.info('Server failed to start as expected')
#
- # Fix the dse.ldif, nad make sure the server starts up,
+ # Fix the dse.ldif, and make sure the server starts up,
# and systemctl correctly identifies the successful start
#
shutil.copy(tmp_dir + 'dse.ldif', config_dir)
log.info('Starting the server...')
rc = os.system(start_ds)
+ time.sleep(10)
log.info('Check the status...')
if rc != 0 or os.system(is_running) != 0:
log.fatal('test_basic_systemctl: Failed to start the server')
@@ -612,17 +641,16 @@ def test_basic_systemctl(topology):
log.info('test_basic_systemctl: PASSED')
-def test_basic_ldapagent(topology):
- '''
- Test that the ldap agnet starts
- '''
+def test_basic_ldapagent(topology, import_example_ldif):
+ """Test that the ldap agent starts"""
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'
- cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix), config_file)
+ cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix),
+ config_file)
agent_config_file = open(config_file, 'w')
agent_config_file.write('agentx-master ' + var_dir + '/agentx/master\n')
@@ -647,10 +675,10 @@ def test_basic_ldapagent(topology):
log.info('test_basic_ldapagent: PASSED')
-def test_basic_dse(topology):
- '''
- Test that the dse.ldif is not wipped out after the process is killed (bug 910581)
- '''
+def test_basic_dse(topology, import_example_ldif):
+ """Test that the dse.ldif is not wipped out
+ after the process is killed (bug 910581)
+ """
log.info('Running test_basic_dse...')
@@ -667,37 +695,8 @@ def test_basic_dse(topology):
log.info('test_basic_dse: PASSED')
-def test_basic_final(topology):
- topology.standalone.delete()
- log.info('Basic test suite PASSED')
-
-
-def run_isolated():
- '''
- run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
- To run isolated without py.test, you need to
- - edit this file and comment '@pytest.fixture' line before 'topology' function.
- - set the installation prefix
- - run this program
- '''
- global installation_prefix
- installation_prefix = None
-
- topo = topology(True)
-
- test_basic_init(topo)
- test_basic_ops(topo)
- test_basic_import_export(topo)
- test_basic_backup(topo)
- test_basic_acl(topo)
- test_basic_searches(topo)
- test_basic_referrals(topo)
- test_basic_systemctl(topo)
- test_basic_ldapagent(topo)
- test_basic_dse(topo)
-
- test_basic_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)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 6 months