Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 35847 invoked from network); 12 May 2010 22:14:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 May 2010 22:14:12 -0000 Received: (qmail 58588 invoked by uid 500); 12 May 2010 22:14:12 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 58558 invoked by uid 500); 12 May 2010 22:14:12 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 58551 invoked by uid 99); 12 May 2010 22:14:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 May 2010 22:14:12 +0000 X-ASF-Spam-Status: No, hits=-1405.4 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 May 2010 22:14:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 69FDC23889B2; Wed, 12 May 2010 22:13:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Wed, 12 May 2010 22:13:50 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100512221350.69FDC23889B2@eris.apache.org> 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 @@ **/*PasswordPolicyServiceIT.java **/*StoredProcedureIT.java + + **/*PerfIT.java + 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 Apache Directory Project + * @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 env = new Hashtable(); + 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 Apache Directory Project + * @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 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(); + } + } +}