From ffb9044301d1c169f934e0adf4f473e99da39a47 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 27 Aug 2007 18:58:10 +0000
Subject: [PATCH] This adds the numSubordinates and hasSubordinates operational attribute support in OpenDS. - Implemented as virtual attributes - They are enabled by default - numSubordinates and hasSubordinates methods added to the backend API and implemented for all existing backends - JE implementation uses the id2children index to keep count of the number of subordinates for each entry. - The behavior of exceeding the index-entry-limit (ALL-IDs) has changed to store a 8 byte entry ID set count with the most significant bit set to 1 instead of a 0 byte array to signify the index-entry-limit has been exceeded. The previous format is still compatible but all requests for numSubordinates will return undefined (-1). - The DBTest tool is also included in this fix. This can be used to list root containers, entry containers, database containers, index status, as well as dumping a database with or without decoding the data.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
index 8e2b059..9e0223b 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
@@ -586,6 +586,23 @@
}
@Test(dependsOnMethods = "testAdd")
+ public void testNumSubordinates() throws Exception
+ {
+ DN dn = DN.decode("dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 1);
+ dn = DN.decode("ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 12);
+ dn = DN.decode("dc=com");
+ assertEquals(backend.numSubordinates(dn), -1);
+ dn = DN.decode("dc=test1,dc=com");
+ assertEquals(backend.numSubordinates(dn), 2);
+ dn = DN.decode("uid=user.10,ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 0);
+ dn = DN.decode("uid=does not exist,ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), -1);
+ }
+
+ @Test(dependsOnMethods = "testAdd")
public void testSearchIndex() throws Exception {
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
@@ -719,7 +736,8 @@
@Test(dependsOnMethods = {"testAdd", "testSearchIndex",
"testSearchScope", "testSearchNotIndexed", "testModifyDNNewSuperior",
- "testMatchedDN"})
+ "testMatchedDN", "testNumSubordinates",
+ "testNumSubordinatesIndexEntryLimitExceeded"})
public void testDeleteSubtree() throws Exception {
Control control = new Control(OID_SUBTREE_DELETE_CONTROL, false);
ArrayList<Control> deleteSubTreeControl = new ArrayList<Control>();
@@ -852,7 +870,8 @@
}
@Test(dependsOnMethods = {"testSearchNotIndexed", "testAdd",
- "testSearchIndex", "testSearchScope", "testMatchedDN"})
+ "testSearchIndex", "testSearchScope", "testMatchedDN",
+ "testNumSubordinates", "testNumSubordinatesIndexEntryLimitExceeded"})
public void testReplaceEntry() throws Exception {
Entry entry;
Entry oldEntry;
@@ -971,7 +990,8 @@
}
@Test(dependsOnMethods = {"testSearchNotIndexed", "testAdd",
- "testSearchIndex", "testSearchScope", "testMatchedDN"})
+ "testSearchIndex", "testSearchScope", "testMatchedDN",
+ "testNumSubordinates", "testNumSubordinatesIndexEntryLimitExceeded"})
public void testModifyEntry() throws Exception {
Entry entry;
Entry newEntry;
@@ -1145,7 +1165,8 @@
@Test(dependsOnMethods = {"testSearchNotIndexed", "testAdd", "testSearchIndex",
"testSearchScope", "testModifyEntry", "testModifyDN", "testReplaceEntry",
- "testDeleteEntry", "testMatchedDN"})
+ "testDeleteEntry", "testMatchedDN", "testNumSubordinates",
+ "testNumSubordinatesIndexEntryLimitExceeded"})
public void testModifyDNNewSuperior() throws Exception {
//Add the new superior entry we want to move to. Test to see if the child ID
//always above parent invarient is preseved.
@@ -1502,6 +1523,25 @@
}
+ @Test(dependsOnMethods = "testSearchNotIndexed")
+ public void testNumSubordinatesIndexEntryLimitExceeded() throws Exception
+ {
+ DN dn = DN.decode("dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 1);
+
+ // 1 entry was deleted and 2 added for a total of 13
+ dn = DN.decode("ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 13);
+ dn = DN.decode("dc=com");
+ assertEquals(backend.numSubordinates(dn), -1);
+ dn = DN.decode("dc=test1,dc=com");
+ assertEquals(backend.numSubordinates(dn), 2);
+ dn = DN.decode("uid=user.10,ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), 0);
+ dn = DN.decode("uid=does not exist,ou=People,dc=test,dc=com");
+ assertEquals(backend.numSubordinates(dn), -1);
+ }
+
/**
* Provides a set of DNs for the matched DN test case.
--
Gitblit v1.10.0