From a2fcb9bde914a4f908fa5ca6591a193e025339d5 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 05 Jul 2010 10:52:50 +0000
Subject: [PATCH] Fix an regression with one level search due to incorrect Parent DN computing when unindexed.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java | 94 ++++++++++++++++++++++++++++++++++++++++++++++
opends/src/server/org/opends/server/backends/jeb/EntryContainer.java | 2
2 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java b/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
index 8e05b20..98f840f 100644
--- a/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -1361,7 +1361,7 @@
{
// Check if this entry is an immediate child.
if(JebFormat.findDNKeyParent(key.getData(), 0,
- key.getSize()) == baseDNKey.length)
+ key.getSize()) != baseDNKey.length)
{
isInScope = false;
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
index 90584dd..87f49db 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2009 Sun Microsystems, Inc.
+ * Copyright 2006-2010 Sun Microsystems, Inc.
*/
package org.opends.server.core;
@@ -57,6 +57,7 @@
import org.opends.server.protocols.ldap.SearchRequestProtocolOp;
import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp;
import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp;
+import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.ByteString;
@@ -1425,4 +1426,95 @@
assertTrue(actualNames.containsAll(expectedAttributes),
"Expected: " + expectedAttributes + " got " + actualNames);
}
+
+
+ /**
+ * Tests the one-level search with a lower allid threshold value.
+ */
+ @Test()
+ public void testOneLevelSearchWithAllIDThreshold() throws Exception
+ {
+ //Set a lower value for allid threshold. We set 2.
+ setAllIdThreshold(2);
+ //Add entries.
+ String filePath = TestCaseUtils.createTempFile(
+ "dn: ou=unit1,dc=example,dc=com\n" +
+ "objectclass: top\n" +
+ "objectclass: organizationalUnit\n" +
+ "ou: unit1\n" +
+ "\n" +
+ "dn: ou=unit2,dc=example,dc=com\n" +
+ "objectclass: top\n" +
+ "objectclass: organizationalUnit\n" +
+ "ou: unit2\n" +
+ "\n" +
+ "dn: ou=unit3,dc=example,dc=com\n" +
+ "objectclass: top\n" +
+ "objectclass: organizationalUnit\n" +
+ "ou: unit3\n");
+
+ String[] args = new String []
+ {
+ "-h", "127.0.0.1",
+ "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
+ "-D","cn=directory manager",
+ "-w","password",
+ "-a",
+ "-f", filePath
+ };
+ int err = LDAPModify.mainModify(args, false, null,null);
+
+ assertEquals(err,0);
+
+ //Search for the entries.
+ InternalClientConnection conn =
+ InternalClientConnection.getRootConnection();
+
+ InternalSearchOperation searchOperation =
+ new InternalSearchOperation(
+ conn,
+ InternalClientConnection.nextOperationID(),
+ InternalClientConnection.nextMessageID(),
+ new ArrayList<Control>(),
+ ByteString.valueOf("dc=example,dc=com"),
+ SearchScope.SINGLE_LEVEL,
+ DereferencePolicy.NEVER_DEREF_ALIASES,
+ Integer.MAX_VALUE,
+ Integer.MAX_VALUE,
+ false,
+ LDAPFilter.decode("(objectclass=organizationalUnit)"),
+ null, null);
+
+ searchOperation.run();
+ assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
+ assertEquals(searchOperation.getSearchEntries().size(),3);
+ //restore the allid threshold.
+ setAllIdThreshold(4000);
+ }
+
+
+ //Sets a value of the allid threshold.
+ private void setAllIdThreshold(int value) throws Exception
+ {
+ //Change the allid threshold value.
+ String filePath = TestCaseUtils.createTempFile(
+ "dn: ds-cfg-backend-id=userRoot,cn=Backends,cn=config",
+ "changetype: modify",
+ "delete: ds-cfg-index-entry-limit",
+ "-",
+ "add: ds-cfg-index-entry-limit",
+ "ds-cfg-index-entry-limit: "+value
+ );
+ String[] args = new String []
+ {
+ "-h", "127.0.0.1",
+ "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
+ "-D","cn=directory manager",
+ "-w","password",
+ "-a",
+ "-f", filePath
+ };
+ int err = LDAPModify.mainModify(args, false, null,null);
+ assertEquals(err, 0);
+ }
}
--
Gitblit v1.10.0