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 2010/05/13 00:13:50 UTC
svn commit: r943718 - in /directory/apacheds/trunk/server-integ: ./
src/test/java/org/apache/directory/server/operations/lookup/
src/test/java/org/apache/directory/server/operations/search/
Author: elecharny
Date: Wed May 12 22:13:49 2010
New Revision: 943718
URL: http://svn.apache.org/viewvc?rev=943718&view=rev
Log:
o Added some performance tests
o Made the build not launching those performance tests
Added:
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/LookupPerfIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java
Modified:
directory/apacheds/trunk/server-integ/pom.xml
Modified: directory/apacheds/trunk/server-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/pom.xml?rev=943718&r1=943717&r2=943718&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/pom.xml (original)
+++ directory/apacheds/trunk/server-integ/pom.xml Wed May 12 22:13:49 2010
@@ -115,6 +115,9 @@
<include>**/*PasswordPolicyServiceIT.java</include>
<include>**/*StoredProcedureIT.java</include>
</includes>
+ <excludes>
+ <exclude>**/*PerfIT.java</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/LookupPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/LookupPerfIT.java?rev=943718&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/LookupPerfIT.java (added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/lookup/LookupPerfIT.java Wed May 12 22:13:49 2010
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.operations.lookup;
+
+
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getClientApiConnection;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.message.SearchResponse;
+import org.apache.directory.ldap.client.api.message.SearchResultEntry;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
+import org.apache.directory.shared.ldap.message.control.Control;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Testcase for the lookup operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 682556 $
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+ transports =
+ {
+ @CreateTransport(protocol = "LDAP")
+ })
+public class LookupPerfIT extends AbstractLdapTestUnit
+{
+ public static LdapServer ldapServer;
+
+ /**
+ * Evaluate the lookup operation performances
+ */
+ @Test
+ @Ignore
+ public void testLookupPerfAPI() throws Exception
+ {
+ LdapConnection connection = getClientApiConnection( ldapServer );
+
+ SearchResponse response = connection.lookup( "uid=admin,ou=system" );;
+ assertNotNull( response );
+ assertTrue( response instanceof SearchResultEntry );
+
+ SearchResultEntry result = (SearchResultEntry)response;
+
+ assertNotNull( result );
+
+ Entry entry = result.getEntry();
+
+ assertNotNull( entry );
+
+ long t0 = System.currentTimeMillis();
+
+ for ( int i = 0; i < 50; i++ )
+ {
+ for ( int j = 0; j < 10000; j++)
+ {
+ response = connection.lookup( "uid=admin,ou=system", "+" );
+ }
+
+ System.out.print( "." );
+ }
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "Delta : " + ( t1 - t0 ) );
+ connection.close();
+ }
+
+
+ public static LdapContext getWiredContext( LdapServer ldapServer, Control[] controls ) throws Exception
+ {
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapServer.getPort() );
+ env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
+ env.put( Context.SECURITY_CREDENTIALS, "secret" );
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+
+ return new InitialLdapContext( env, JndiUtils.toJndiControls( controls ) );
+ }
+
+
+ /**
+ * Evaluate the lookup operation performances
+ */
+ @Test
+ @Ignore
+ public void testLookupPerfJNDI() throws Exception
+ {
+ LdapContext ctx = getWiredContext( ldapServer, null );
+
+ Attributes result = ctx.getAttributes( "uid=admin,ou=system" );
+
+ assertNotNull( result );
+
+ long t0 = System.currentTimeMillis();
+
+ for ( int i = 0; i < 50; i++ )
+ {
+ for ( int j = 0; j < 10000; j++)
+ {
+ ctx.getAttributes( "uid=admin,ou=system" );
+ }
+
+ System.out.print( "." );
+ }
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "Delta : " + ( t1 - t0 ) );
+
+ ctx.close();
+ }
+}
Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java?rev=943718&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java (added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java Wed May 12 22:13:49 2010
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.operations.search;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.exception.LdapException;
+import org.apache.directory.ldap.client.api.message.SearchResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Testcase with different modify operations on a person entry. Each includes a
+ * single add op only. Created to demonstrate DIREVE-241 ("Adding an already
+ * existing attribute value with a modify operation does not cause an error.").
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 682556 $
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+ transports =
+ {
+ @CreateTransport(protocol = "LDAP")
+ })
+public class SearchPerfIT extends AbstractLdapTestUnit
+{
+ public static LdapServer ldapServer;
+
+ /**
+ * test a search request perf.
+ */
+ @Test
+ @Ignore
+ public void testSearchRequestPerf() throws Exception
+ {
+ //ldapServer.getDirectoryService().getInterceptorChain().addFirst( new TimerInterceptor( "Start" ) );
+ //ldapServer.getDirectoryService().getInterceptorChain().addLast( new TimerInterceptor( "End" ) );
+ LdapConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+ connection.setTimeOut( 0 );
+
+ try
+ {
+ // Use the client API as JNDI cannot be used to do a search without
+ // first binding. (hmmm, even client API won't allow searching without binding)
+ connection.bind( "uid=admin,ou=system", "secret" );
+
+ // Searches for all the entries in ou=system
+ Cursor<SearchResponse> cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );
+
+ int i = 0;
+
+ while ( cursor.next() )
+ {
+ cursor.get();
+ ++i;
+ }
+
+ cursor.close();
+ assertEquals( 1, i );
+
+ for ( int j = 0; j < 10000; j++ )
+ {
+ cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );
+ while ( cursor.next() ){}
+ cursor.close();
+ }
+
+ long t0 = System.currentTimeMillis();
+
+ for ( int j = 0; j < 200000; j++ )
+ {
+ if ( j % 10000 == 0 )
+ {
+ System.out.println(j);
+ }
+
+ cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );
+ while ( cursor.next() ){}
+ cursor.close();
+ }
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "Delta = " + ( t1 - t0 ) );
+ }
+ catch ( LdapException e )
+ {
+ e.printStackTrace();
+ fail( "Should not have caught exception." );
+ }
+ finally
+ {
+ connection.unBind();
+ }
+ }
+}