directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1434859 - /directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
Date Thu, 17 Jan 2013 18:44:57 GMT
Author: elecharny
Date: Thu Jan 17 18:44:57 2013
New Revision: 1434859

URL: http://svn.apache.org/viewvc?rev=1434859&view=rev
Log:
Fixed the connection closing in the perf test

Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java?rev=1434859&r1=1434858&r2=1434859&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/OperationWithIndexTest.java
Thu Jan 17 18:44:57 2013
@@ -19,6 +19,10 @@
  */
 package org.apache.directory.shared.client.api.operations.search;
 
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.DefaultModification;
@@ -41,12 +45,11 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+
 
 @RunWith(FrameworkRunner.class)
 @CreateDS(
-    name="AddPerfDS",
+    name = "AddPerfDS",
     partitions =
     {
         @CreatePartition(
@@ -67,12 +70,12 @@ import static org.junit.Assert.assertFal
             } )
             
     },
-    enableChangeLog = false )
+    enableChangeLog = false)
 @CreateLdapServer(transports =
     {
         @CreateTransport(protocol = "LDAP"),
         @CreateTransport(protocol = "LDAPS")
-    })
+})
 /**
  * Test some Add operations using an index
  * 
@@ -81,25 +84,27 @@ import static org.junit.Assert.assertFal
 public class OperationWithIndexTest extends AbstractLdapTestUnit
 {
     private LdapNetworkConnection connection;
-    
-    
+
+
     @Before
     public void setup() throws Exception
     {
-        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
+        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
+        connection.setTimeOut( 0 );
 
         // Restart the service so that the index is created
         getService().shutdown();
         getService().startup();
     }
-    
-    
+
+
     @After
     public void shutdown() throws Exception
     {
         LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
     }
 
+
     /**
      * Test an add operation performance
      */
@@ -115,6 +120,7 @@ public class OperationWithIndexTest exte
             "cn: test" );
     
         connection.add( entry );
+
         int nbIterations = 8000;
 
         //BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") );
@@ -122,17 +128,17 @@ public class OperationWithIndexTest exte
         long t0 = System.currentTimeMillis();
         long t00 = 0L;
         long tt0 = System.currentTimeMillis();
-        
+
         for ( int i = 0; i < nbIterations; i++ )
         {
             if ( i % 1000 == 0 )
             {
                 long tt1 = System.currentTimeMillis();
-    
+
                 System.out.println( i + ", " + ( tt1 - tt0 ) );
                 tt0 = tt1;
             }
-    
+
             if ( i == 5000 )
             {
                 t00 = System.currentTimeMillis();
@@ -157,49 +163,54 @@ public class OperationWithIndexTest exte
                 "displayName", i + "Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D",
                 "employeeNumber: A-A-R.Awg-Rosli",
                 "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config"
);
-    
+
             //out.write( LdifUtils.convertToLdif( entry ) );
             connection.add( entry );
         }
-        
+
         //out.flush();
         //out.close();
-    
+
         long t1 = System.currentTimeMillis();
-    
+
         Long deltaWarmed = ( t1 - t00 );
         System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 5000 )
* 1000 ) / deltaWarmed ) + " per s ) /" + ( t1 - t0 ) );
 
         Entry entry1 = null;
         Entry entry2 = null;
         Entry entry3 = null;
-        
+
         long ns0 = System.currentTimeMillis();
         EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1234Awg-Rosli,
Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );
         
         while ( results.next() )
         {
-            entry1 = results.get();
-            break;
+            if ( entry1 == null )
+            {
+                entry1 = results.get();
+            }
         }
-        
+
         results.close();
-        
+
         long ns1 = System.currentTimeMillis();
-        
+
         System.out.println( "Delta search : " + ( ns1 - ns0 ) );
 
         long ns2 = System.currentTimeMillis();
-        results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE,
"*" );
+        results = connection.search( "dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE,
"*" );
                 
         while ( results.next() )
         {
-            entry2 = results.get();
-            break;
+            if ( entry2 == null )
+            {
+                entry2 = results.get();
+            }
         }
+
         results.close();
         long ns3 = System.currentTimeMillis();
-        
+
         System.out.println( "Delta search substring : " + ( ns3 - ns2 ) );
 
         long ns4 = System.currentTimeMillis();
@@ -207,51 +218,56 @@ public class OperationWithIndexTest exte
                 
         while ( results.next() )
         {
-            entry3 = results.get();
-            break;
+            if ( entry3 == null )
+            {
+                entry3 = results.get();
+            }
         }
-        
+
         results.close();
         long ns5 = System.currentTimeMillis();
-        
+
         System.out.println( "Delta search no index : " + ( ns5 - ns4 ) );
 
-        System.out.println( "Entry 1 : " + entry1 );
-        System.out.println( "Entry 2 : " + entry2 );
-        System.out.println( "Entry 3 : " + entry3 );
+        //System.out.println( "Entry 1 : " + entry1 );
+        //System.out.println( "Entry 2 : " + entry2 );
+        //System.out.println( "Entry 3 : " + entry3 );
         connection.close();
-        
+
         // Now, shutdown and restart the server once more
+        System.out.println( "--------------> Shuting Down" );
         getService().shutdown();
         getService().startup();
-        
+
         // and do a search again
-        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
+        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
 
         long ns6 = System.currentTimeMillis();
-        results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE,
"*" );
-                
+        results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE,
"*" );
+
         while ( results.next() )
         {
             entry3 = results.get();
             break;
         }
-        
+
         results.close();
         long ns7 = System.currentTimeMillis();
         System.out.println( "New Delta search substring : " + ( ns7 - ns6 ) );
 
         connection.close();
     }
-    
-    
+
+
     @Test
     public void testModify() throws Exception
     {
-        
+
         // Add the entry
         Dn dn = new Dn( "uid=1,dc=example,dc=com" );
-        Entry entry = new DefaultEntry( getService().getSchemaManager(), dn,
+        Entry entry = new DefaultEntry(
+            getService().getSchemaManager(),
+            dn,
             "objectClass: top",
             "objectClass: person",
             "objectClass: organizationalPerson",
@@ -271,34 +287,35 @@ public class OperationWithIndexTest exte
             "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config"
);
 
         connection.add( entry );
-        
-        EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1*)",
SearchScope.SUBTREE, "*" );
-        
+
+        EntryCursor results = connection.search( "dc=example,dc=com", "(displayName=1*)",
SearchScope.SUBTREE, "*" );
+
         while ( results.next() )
         {
             Entry result = results.get();
             assertTrue( result.contains( "displayName", "1Awg-Rosli" ) );
         }
-        
+
         results.close();
-        
+
         // Now, modify it
-        connection.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
"displayName", "test" ) );
-        
-        results = connection.search("dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE,
"*" );
-        
+        connection
+            .modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
"displayName", "test" ) );
+
+        results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE,
"*" );
+
         while ( results.next() )
         {
             Entry result = results.get();
             assertTrue( result.contains( "displayName", "test" ) );
         }
-        
+
         results.close();
 
-        results = connection.search("dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE,
"*" );
-        
+        results = connection.search( "dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE,
"*" );
+
         assertFalse( results.next() );
-        
+
         results.close();
     }
 }



Mime
View raw message