Author: ersiner
Date: Wed Dec 2 11:21:19 2009
New Revision: 886118
URL: http://svn.apache.org/viewvc?rev=886118&view=rev
Log:
Initial import of preliminary performance test suite.
Added:
directory/sandbox/ersiner/apacheds-performance-tests/pom.xml
directory/sandbox/ersiner/apacheds-performance-tests/src/
directory/sandbox/ersiner/apacheds-performance-tests/src/main/
directory/sandbox/ersiner/apacheds-performance-tests/src/main/java/
directory/sandbox/ersiner/apacheds-performance-tests/src/main/resources/
directory/sandbox/ersiner/apacheds-performance-tests/src/main/resources/META-INF/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/PerformanceTest.java
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/log4j.properties
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/apache/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/apache/directory/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/apache/directory/server/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/apache/directory/server/core/
directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/org/apache/directory/server/core/perf/
Modified:
directory/sandbox/ersiner/apacheds-performance-tests/ (props changed)
Propchange: directory/sandbox/ersiner/apacheds-performance-tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec 2 11:21:19 2009
@@ -0,0 +1,13 @@
+*.iml
+*.ipr
+*.iws
+.wtpmodules
+.settings
+.deployables
+junit*.properties
+server-work
+target
+.classpath
+.project
+*.log
+nbproject
Added: directory/sandbox/ersiner/apacheds-performance-tests/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/apacheds-performance-tests/pom.xml?rev=886118&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-performance-tests/pom.xml (added)
+++ directory/sandbox/ersiner/apacheds-performance-tests/pom.xml Wed Dec 2 11:21:19 2009
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-parent</artifactId>
+ <version>1.5.6-SNAPSHOT</version>
+ </parent>
+ <artifactId>apacheds-performance-tests</artifactId>
+ <name>ApacheDS Performance Tests</name>
+ <packaging>jar</packaging>
+
+ <description>
+ Performance Tests for Apache Directory Server.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-core-integ</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-schema-extras</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-bootstrap-partition</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ </project>
\ No newline at end of file
Added: directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/PerformanceTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/PerformanceTest.java?rev=886118&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/PerformanceTest.java
(added)
+++ directory/sandbox/ersiner/apacheds-performance-tests/src/test/java/org/apache/directory/server/core/perf/PerformanceTest.java
Wed Dec 2 11:21:19 2009
@@ -0,0 +1,170 @@
+package org.apache.directory.server.core.perf;
+
+
+/*
+ * 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.
+ *
+ */
+
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.DirectoryServiceFactory;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifFiles;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.core.integ.annotations.Factory;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.xdbm.Index;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+@RunWith(CiRunner.class)
+@ApplyLdifFiles("test.ldif") // This LDIF file should exist on the class path!
+@Factory(PerformanceTest.MyFactory.class)
+@CleanupLevel(Level.CLASS)
+public class PerformanceTest
+{
+ public static DirectoryService service;
+
+ // number of threads to be fired
+ private int nbThreads = 4;
+
+ // number of total searches to be performed by all threads
+ private int nbSearches = 20000;
+
+ // number of entries in the database to search over
+ private int nbEntries = 10000;
+
+ @Test
+ public void testSearchPerf() throws Exception
+ {
+ LdapContext sysRoot = getSystemContext( service );
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ controls.setReturningAttributes( new String[] { "uid" } );
+ long startTime = System.currentTimeMillis();
+
+ CountDownLatch latch = new CountDownLatch( nbThreads );
+ for ( int i = 0; i < nbThreads; i++ )
+ {
+ new MyThread(sysRoot, controls, nbSearches/nbThreads, nbEntries, latch ).start();
+ }
+ latch.await();
+
+ long endTime = System.currentTimeMillis();
+ System.out.println( ">>> " + nbThreads + " thread(s) performed " + nbSearches
+ " random searches over " + nbEntries + " entries in " + (endTime - startTime) + " milliseconds."
);
+ }
+
+ private static class MyThread extends Thread
+ {
+ private LdapContext sysRoot;
+ private SearchControls controls;
+ private int nbSearches;
+ private int nbEntries;
+ private CountDownLatch latch;
+
+ public MyThread( LdapContext sysRoot, SearchControls controls, int nbSearches, int
nbEntries, CountDownLatch latch )
+ {
+ this.sysRoot = sysRoot;
+ this.controls = controls;
+ this.nbSearches = nbSearches;
+ this.nbEntries = nbEntries;
+ this.latch = latch;
+ }
+
+
+ public void search() throws NamingException
+ {
+ Random randomGenerator = new Random();
+
+ for ( int i = 0; i < nbSearches; i++ )
+ {
+ int randomId = randomGenerator.nextInt(nbEntries);
+ NamingEnumeration<SearchResult> list = sysRoot.search( "", "(uid=user."
+ randomId + ")", controls );
+
+ if ( list.hasMore() )
+ {
+ SearchResult result = list.next();
+ Assert.assertEquals( "uid=user." + randomId + ",ou=system", result.getName()
);
+ }
+ else
+ {
+ Assert.fail( "Could not find use with uid=user." + randomId );
+ }
+ }
+ }
+
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ search();
+ }
+ catch ( NamingException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ latch.countDown();
+ }
+ }
+
+ public static class MyFactory implements DirectoryServiceFactory
+ {
+ public DirectoryService newInstance()
+ {
+ DirectoryService service = new DefaultDirectoryService();
+ service.getChangeLog().setEnabled( true );
+
+ JdbmPartition partition = new JdbmPartition();
+ partition.setId( "system" );
+ partition.setSuffix( "ou=system" );
+ partition.setCacheSize( 11000 );
+
+ Set<Index<?, ServerEntry>> indices = new HashSet<Index<?, ServerEntry>>();
+ indices.addAll( partition.getIndexedAttributes() );
+ indices.add( new JdbmIndex<String, ServerEntry>( "uid" ) );
+ partition.setIndexedAttributes( indices );
+ service.setSystemPartition( partition );
+
+ return service;
+ }
+ }
+
+}
Added: directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/log4j.properties?rev=886118&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/log4j.properties
(added)
+++ directory/sandbox/ersiner/apacheds-performance-tests/src/test/resources/log4j.properties
Wed Dec 2 11:21:19 2009
@@ -0,0 +1,22 @@
+#############################################################################
+# 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.
+#############################################################################
+log4j.rootCategory=OFF, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+log4j.logger.org.apache.directory.server.core.integ=ERROR
|