You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2019/04/30 19:10:23 UTC

[directory-server] branch master updated: Added a test for DIRAPI-340

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git


The following commit(s) were added to refs/heads/master by this push:
     new 6837f5c  Added a test for DIRAPI-340
     new 05b2c4a  Merge branch 'master' of https://gitbox.apache.org/repos/asf/directory-server
6837f5c is described below

commit 6837f5cc9790c57feb7240fb554d9c7312148f68
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Tue Apr 30 21:09:59 2019 +0200

    Added a test for DIRAPI-340
---
 .../operations/search/OperationWithIndexTest.java  | 72 ++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
index 13d338f..e0c56cc 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
@@ -93,6 +93,7 @@ import org.junit.runner.RunWith;
                         @CreateIndex(attribute = "objectClass"),
                         @CreateIndex(attribute = "sn"),
                         @CreateIndex(attribute = "cn"),
+                        @CreateIndex(attribute = "uniqueMember"),
                         @CreateIndex(attribute = "displayName")
                 })
 
@@ -814,4 +815,75 @@ public class OperationWithIndexTest extends AbstractLdapTestUnit
         assertTrue( entries.contains( "cn=test,ou=system" ) );
         cursor.close();
     }
+
+
+    /**
+     * Check that we can find entries in more than one partition 
+     */
+    @Test
+    public void testSearchWithIndex() throws Exception
+    {
+        int nbIterations = 1000;
+
+        //BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") );
+
+        long t0 = System.currentTimeMillis();
+        long t00 = 0L;
+        long tt0 = System.currentTimeMillis();
+
+        for ( int i = 0; i < nbIterations; i++ )
+        {
+            if ( i % 100 == 0 )
+            {
+                long tt1 = System.currentTimeMillis();
+
+                System.out.println( i + ", " + ( tt1 - tt0 ) );
+                tt0 = tt1;
+            }
+
+            if ( i == 500 )
+            {
+                t00 = System.currentTimeMillis();
+            }
+
+            String cnStr = "user" + i;
+            String rdnStr = "cn=" + cnStr;
+            Dn dn = new Dn( rdnStr + ",dc=test,dc=com" );
+            Entry entry = new DefaultEntry(
+                getService().getSchemaManager(),
+                dn,
+                "objectClass: top",
+                "objectClass: groupOfUniqueNames",
+                "cn", cnStr,
+                "uniqueMember", dn.toString() );
+
+            connection.add( entry );
+        }
+
+        long t1 = System.currentTimeMillis();
+
+        Long deltaWarmed = ( t1 - t00 );
+        System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 500 ) * 1000 ) / deltaWarmed )
+            + " per s ) /" + ( t1 - t0 ) );
+
+
+        // Now search the entry from the root
+        EntryCursor cursor = connection.search( "", "(uniqueMember=cn=user784,dc=test,dc=com)", SearchScope.SUBTREE );
+        List<String> entries = new ArrayList<String>();
+
+        while ( cursor.next() )
+        {
+            Entry entryFound = cursor.get();
+            assertNotNull( entryFound );
+            entries.add( entryFound.getDn().getName() );
+        }
+
+        SearchResultDone done = cursor.getSearchResultDone();
+
+        assertNotNull( done );
+        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+        assertEquals( 1, entries.size() );
+        assertTrue( entries.contains( "cn=user784,dc=test,dc=com" ) );
+        cursor.close();
+    }
 }