directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1509637 - /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
Date Fri, 02 Aug 2013 11:28:30 GMT
Author: elecharny
Date: Fri Aug  2 11:28:30 2013
New Revision: 1509637

URL: http://svn.apache.org/r1509637
Log:
Added a perf test where we add 10 000 users before doing a search

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java?rev=1509637&r1=1509636&r2=1509637&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
Fri Aug  2 11:28:30 2013
@@ -22,7 +22,12 @@ package org.apache.directory.server.core
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.Random;
+
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
+import org.apache.directory.api.ldap.model.cursor.SearchCursor;
+import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.message.AliasDerefMode;
 import org.apache.directory.api.ldap.model.message.SearchRequest;
 import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
@@ -30,7 +35,10 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.ldap.client.api.EntryCursorImpl;
 import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.core.annotations.ContextEntry;
 import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
@@ -44,7 +52,29 @@ import org.junit.runner.RunWith;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateDS(name = "SearchPerfDS")
+@CreateDS(
+    name = "SearchPerfDS",
+    partitions =
+        {
+            @CreatePartition(
+                name = "example",
+                suffix = "dc=example,dc=com",
+                contextEntry = @ContextEntry(
+                    entryLdif =
+                    "dn: dc=example,dc=com\n" +
+                        "dc: example\n" +
+                        "objectClass: top\n" +
+                        "objectClass: domain\n\n"),
+                indexes =
+                    {
+                        @CreateIndex(attribute = "objectClass"),
+                        @CreateIndex(attribute = "sn"),
+                        @CreateIndex(attribute = "cn"),
+                        @CreateIndex(attribute = "displayName")
+                })
+
+    },
+    enableChangeLog = false)
 public class SearchPerfIT extends AbstractLdapTestUnit
 {
     /**
@@ -116,7 +146,8 @@ public class SearchPerfIT extends Abstra
         long t1 = System.currentTimeMillis();
 
         Long deltaWarmed = ( t1 - t00 );
-        System.out.println( "OBJECT level - Delta : " + deltaWarmed + "( " + ( ( ( nbIterations
- 500000 ) * 1000 ) / deltaWarmed )
+        System.out.println( "OBJECT level - Delta : " + deltaWarmed + "( "
+            + ( ( ( nbIterations - 500000 ) * 1000 ) / deltaWarmed )
             + " per s ) /" + ( t1 - t0 ) + ", count : " + count );
         connection.close();
     }
@@ -189,7 +220,8 @@ public class SearchPerfIT extends Abstra
         long t1 = System.currentTimeMillis();
 
         Long deltaWarmed = ( t1 - t00 );
-        System.out.println( "ONE level - Delta : " + deltaWarmed + "( " + ( ( ( nbIterations
- 50000 ) * 1000 ) / deltaWarmed ) * 5
+        System.out.println( "ONE level - Delta : " + deltaWarmed + "( "
+            + ( ( ( nbIterations - 50000 ) * 1000 ) / deltaWarmed ) * 5
             + " per s ) /" + ( t1 - t0 ) + ", count : " + count );
         connection.close();
     }
@@ -262,9 +294,114 @@ public class SearchPerfIT extends Abstra
         long t1 = System.currentTimeMillis();
 
         Long deltaWarmed = ( t1 - t00 );
-        System.out.println( "SUB level - Delta : " + deltaWarmed + "( " + ( ( ( nbIterations
- 50000 ) * 1000 ) / deltaWarmed )
+        System.out.println( "SUB level - Delta : " + deltaWarmed + "( "
+            + ( ( ( nbIterations - 50000 ) * 1000 ) / deltaWarmed )
             * 10
             + " per s ) /" + ( t1 - t0 ) + ", count : " + count );
         connection.close();
     }
+
+
+    @Test
+    public void testSearchCore100kUsers() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+        connection.bind( "uid=admin,ou=system", "secret" );
+
+        Entry rootPeople = new DefaultEntry(
+            "ou=People,dc=example,dc=com",
+            "objectClass: top",
+            "objectClass: organizationalUnit",
+            "ou: People" );
+
+        connection.add( rootPeople );
+        int nbUsers = 10000;
+
+        long tadd0 = System.currentTimeMillis();
+        for ( int i = 0; i < nbUsers; i++ )
+        {
+            Entry user = new DefaultEntry(
+                "uid=user." + i + ",ou=People,dc=example,dc=com",
+                "objectClass: top",
+                "objectClass: person",
+                "objectClass: organizationalPerson",
+                "objectClass: inetOrgPerson",
+                "givenName: Aaccf",
+                "sn: Amar",
+                "cn", "user" + i,
+                "initials: AA",
+                "uid", "user." + i,
+                "mail: user.1@cs.hacettepe.edu.tr",
+                "userPassword: password",
+                "telephoneNumber: 314-796-3178",
+                "homePhone: 514-847-0518",
+                "pager: 784-600-5445",
+                "mobile: 801-755-4931",
+                "street: 00599 First Street",
+                "l: Augusta",
+                "st: MN",
+                "postalCode: 30667",
+                "postalAddress: Aaccf Amar$00599 First Street$Augusta, MN  30667",
+                "description: This is the description for Aaccf Amar." );
+
+            connection.add( user );
+
+            if ( i % 100 == 0 )
+            {
+                System.out.println( "Injected " + i );
+            }
+        }
+        long tadd1 = System.currentTimeMillis();
+
+        System.out.println( "Time to inject " + nbUsers + " entries : " + ( ( tadd1 - tadd0
) / 1000 ) + "s" );
+
+        // Now do a random search
+        SearchRequest searchRequest = new SearchRequestImpl();
+
+        searchRequest.setBase( new Dn( "dc=example,dc=com" ) );
+        searchRequest.setScope( SearchScope.SUBTREE );
+        searchRequest.addAttributes( "*" );
+        searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
+
+        long t0 = System.currentTimeMillis();
+        long t00 = 0L;
+        long tt0 = System.currentTimeMillis();
+        int nbIterations = 200000;
+        int count = 0;
+        Random random = new Random();
+
+        for ( int j = 0; j < nbIterations; j++ )
+        {
+            if ( j % 10000 == 0 )
+            {
+                long tt1 = System.currentTimeMillis();
+
+                System.out.println( j + ", " + ( tt1 - tt0 ) );
+                tt0 = tt1;
+            }
+
+            if ( j == 5000 )
+            {
+                t00 = System.currentTimeMillis();
+            }
+
+            searchRequest.setFilter( "(cn=user" + random.nextInt( nbUsers ) + ")" );
+
+            SearchCursor cursor = connection.search( searchRequest );
+
+            while ( cursor.next() )
+            {
+                count++;
+                cursor.getEntry();
+            }
+
+            cursor.close();
+        }
+
+        long t1 = System.currentTimeMillis();
+
+        Long deltaWarmed = ( t1 - t00 );
+        System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 5000 )
* 1000 ) / deltaWarmed )
+            + " per s ) /" + ( t1 - t0 ) + ", count : " + count );
+    }
 }



Mime
View raw message