Wednesday, June 15, 2016

[389-commits] Branch '389-ds-base-1.3.4' - dirsrvtests/tests ldap/servers

dirsrvtests/tests/tickets/ticket48109_test.py | 41 ++++++++++----------------
ldap/servers/slapd/back-ldbm/ldbm_attr.c | 18 +++++------
2 files changed, 26 insertions(+), 33 deletions(-)

New commits:
commit e001de5a68d63c9256da2ca62ec7d75cac0b22ff
Author: Noriko Hosoi <nhosoi@redhat.com>
Date: Wed Jun 15 14:59:56 2016 -0700

Ticket #48109 - substring index with nssubstrbegin: 1 is not being used with filters like (attr=x*)

Description: In case, index entry has this style of substr width definition:
nsMatchingRule: nsSubstr{Begin,Middle,End}=<NUM>
it should be converted to
nssubstr{Begin,Middle,End}: <NUM>
and skip the following nsMatchingRule evaluation. There was a bug in the
logic to skip. The feature itself was not effected, but this bogus error
was logged in the error log:
[..] from ldbm instance init: line 0: unknown or invalid matching rule
"nssubstrbegin=3" in index configuration (ignored)

Plus, the test script ticket48109_test.py is adjusted to the new format.

https://fedorahosted.org/389/ticket/48109

Reviewed by mreynolds@redhat.com (Thank you, Mark!!)

(cherry picked from commit 230ace2aa657e931b4c6dfa742a28d072a8f5db7)

diff --git a/dirsrvtests/tests/tickets/ticket48109_test.py b/dirsrvtests/tests/tickets/ticket48109_test.py
index e4091e0..1d7a334 100644
--- a/dirsrvtests/tests/tickets/ticket48109_test.py
+++ b/dirsrvtests/tests/tickets/ticket48109_test.py
@@ -26,6 +26,13 @@ installation1_prefix = None

UID_INDEX = 'cn=uid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config'

+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
class TopologyStandalone(object):
def __init__(self, standalone):
standalone.open()
@@ -52,13 +59,18 @@ def topology(request):
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_ticket48109_0(topology):
+def test_ticket48109(topology):
'''
Set SubStr lengths to cn=uid,cn=index,...
objectClass: extensibleObject
@@ -147,8 +159,6 @@ def test_ticket48109_0(topology):
log.error('Failed to delete substr lengths: error ' + e.message['desc'])
assert False

-
-def test_ticket48109_1(topology):
'''
Set SubStr lengths to cn=uid,cn=index,...
nsIndexType: sub
@@ -234,8 +244,6 @@ def test_ticket48109_1(topology):
log.error('Failed to delete substr lengths: error ' + e.message['desc'])
assert False

-
-def test_ticket48109_2(topology):
'''
Set SubStr conflict formats/lengths to cn=uid,cn=index,...
objectClass: extensibleObject
@@ -369,26 +377,11 @@ def test_ticket48109_2(topology):
except ldap.LDAPError as e:
log.error('Failed to delete substr lengths: error ' + e.message['desc'])
assert False
-
- log.info('Test complete')
-
-
-def test_ticket48109_final(topology):
- topology.standalone.delete()
log.info('Testcase PASSED')


-def run_isolated():
- global installation1_prefix
- installation1_prefix = None
-
- topo = topology(True)
- test_ticket48109_0(topo)
- test_ticket48109_1(topo)
- test_ticket48109_2(topo)
- test_ticket48109_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/ldap/servers/slapd/back-ldbm/ldbm_attr.c b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
index 092b6b5..7e44cfe 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
@@ -790,23 +790,23 @@ attr_index_config(
* nsMatchingRule: nsSubstrMiddle=2
* nsMatchingRule: nsSubstrEnd=2
*/
- if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTRBEGIN]) {
- if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTRBEGIN)) {
+ if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTRBEGIN)) {
+ if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTRBEGIN]) {
_set_attr_substrlen(INDEX_SUBSTRBEGIN, attrValue->bv_val, &substrlens);
- do_continue = 1; /* done with j - next j */
}
+ do_continue = 1; /* done with j - next j */
}
- if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTRMIDDLE]) {
- if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTRMIDDLE)) {
+ if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTRMIDDLE)) {
+ if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTRMIDDLE]) {
_set_attr_substrlen(INDEX_SUBSTRMIDDLE, attrValue->bv_val, &substrlens);
- do_continue = 1; /* done with j - next j */
}
+ do_continue = 1; /* done with j - next j */
}
- if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTREND]) {
- if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTREND)) {
+ if (PL_strcasestr(attrValue->bv_val, INDEX_ATTR_SUBSTREND)) {
+ if (!a->ai_substr_lens || !a->ai_substr_lens[INDEX_SUBSTREND]) {
_set_attr_substrlen(INDEX_SUBSTREND, attrValue->bv_val, &substrlens);
- do_continue = 1; /* done with j - next j */
}
+ do_continue = 1; /* done with j - next j */
}
/* check if this is a simple ordering specification
for an attribute that has no ordering matching rule */

--
389-commits mailing list
389-commits@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/389-commits@lists.fedoraproject.org

No comments:

Post a Comment