directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1397918 - in /directory/apacheds/trunk: ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ server-integ/src/test/java/org/apache/directory/server/operations/search/ test-framework/src/main/java/org/apache/dir...
Date Sat, 13 Oct 2012 18:19:38 GMT
Author: seelmann
Date: Sat Oct 13 18:19:38 2012
New Revision: 1397918

URL: http://svn.apache.org/viewvc?rev=1397918&view=rev
Log:
Fix for DIRAPI-94 (Random failure of ClientAbandonRequestTest). Slow down sending of results.
Extracted DelayInducingInterceptor from SearchLimitsIT for reusability.

Added:
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/DelayInducingInterceptor.java
Modified:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java?rev=1397918&r1=1397917&r2=1397918&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
Sat Oct 13 18:19:38 2012
@@ -30,6 +30,7 @@ import org.apache.directory.ldap.client.
 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.DelayInducingInterceptor;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -66,12 +67,15 @@ public class ClientAbandonRequestTest ex
     @Rule
     public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE
);
     private static final int numEntries = 100;
+    private DelayInducingInterceptor delayInterceptor;
     private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
+        delayInterceptor = new DelayInducingInterceptor();
+        getLdapServer().getDirectoryService().addFirst( delayInterceptor );
         connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
 
         // injecting some values to keep the
@@ -99,6 +103,7 @@ public class ClientAbandonRequestTest ex
     public void shutdown() throws Exception
     {
         LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
+        getLdapServer().getDirectoryService().remove( delayInterceptor.getName() );
     }
 
 
@@ -152,6 +157,10 @@ public class ClientAbandonRequestTest ex
     @Test
     public void testAbandonSearch() throws Exception
     {
+        // Slow down sending of results, otherwise it is possible that the server already
sent all results 
+        // before the abandon request arrives. See DIRAPI-94.
+        delayInterceptor.setDelayMillis( 1 );
+
         // Launch the search now
         EntryCursor cursor = connection.search( new Dn( "ou=system" ), "(cn=*)", SearchScope.ONELEVEL,
"*" );
 
@@ -172,7 +181,7 @@ public class ClientAbandonRequestTest ex
 
         cursor.close();
 
-        System.out.println( "Responses received / expected : " + count + "/" + numEntries
);
+        //System.out.println( "Responses received / expected : " + count + "/" + numEntries
);
         assertTrue( numEntries > count );
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java?rev=1397918&r1=1397917&r2=1397918&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
Sat Oct 13 18:19:38 2012
@@ -39,17 +39,10 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
-import org.apache.directory.server.core.api.filtering.EntryFilter;
-import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
-import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
-import org.apache.directory.server.core.api.interceptor.Interceptor;
-import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
-import org.apache.directory.server.core.api.interceptor.context.SearchingOperationContext;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.DelayInducingInterceptor;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.ldap.LdapServer;
-import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -126,54 +119,6 @@ public class SearchLimitsIT extends Abst
     @Rule
     public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE
);
     
-    /**
-     * An {@link Interceptor} that fakes a specified amount of delay to each
-     * search iteration so we can make sure search time limits are adhered to.
-     *
-     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-     */
-    class DelayInducingInterceptor extends BaseInterceptor
-    {
-        private Long delayMillis;
-    
-    
-        public DelayInducingInterceptor()
-        {
-            super( "DelayInterceptor" );
-        }
-    
-    
-        public EntryFilteringCursor search( SearchOperationContext searchContext ) throws
LdapException
-        {
-            EntryFilteringCursor cursor = next( searchContext );
-            cursor.addEntryFilter( new EntryFilter()
-            {
-                public boolean accept( SearchingOperationContext operation, Entry result
) throws Exception
-                {
-                    if ( delayMillis != null )
-                    {
-                        Thread.sleep( delayMillis );
-                    }
-    
-                    return true;
-                }
-            } );
-    
-            return cursor;
-        }
-    
-    
-        public void setDelayMillis( long delayMillis )
-        {
-            if ( delayMillis <= 0 )
-            {
-                this.delayMillis = null;
-            }
-    
-            this.delayMillis = delayMillis;
-        }
-    }
-    
     private int oldMaxTimeLimit;
     private long oldMaxSizeLimit;
     private DelayInducingInterceptor delayInterceptor;
@@ -194,7 +139,7 @@ public class SearchLimitsIT extends Abst
     {
         getLdapServer().setMaxTimeLimit( oldMaxTimeLimit );
         getLdapServer().setMaxSizeLimit( oldMaxSizeLimit );
-        getLdapServer().getDirectoryService().remove( "DelayInterceptor" );
+        getLdapServer().getDirectoryService().remove( delayInterceptor.getName() );
     }
     
     

Added: directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/DelayInducingInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/DelayInducingInterceptor.java?rev=1397918&view=auto
==============================================================================
--- directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/DelayInducingInterceptor.java
(added)
+++ directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/DelayInducingInterceptor.java
Sat Oct 13 18:19:38 2012
@@ -0,0 +1,79 @@
+/*
+ *  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.core.integ;
+
+
+import org.apache.directory.server.core.api.filtering.EntryFilter;
+import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
+import org.apache.directory.server.core.api.interceptor.Interceptor;
+import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.SearchingOperationContext;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+
+
+/**
+ * An {@link Interceptor} that fakes a specified amount of delay to each
+ * search iteration so we can make sure search time limits are adhered to.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DelayInducingInterceptor extends BaseInterceptor
+{
+    private Long delayMillis;
+
+
+    public DelayInducingInterceptor()
+    {
+        super( "DelayInterceptor" );
+    }
+
+
+    public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
+    {
+        EntryFilteringCursor cursor = next( searchContext );
+        cursor.addEntryFilter( new EntryFilter()
+        {
+            public boolean accept( SearchingOperationContext operation, Entry result ) throws
Exception
+            {
+                if ( delayMillis != null )
+                {
+                    Thread.sleep( delayMillis );
+                }
+
+                return true;
+            }
+        } );
+
+        return cursor;
+    }
+
+
+    public void setDelayMillis( long delayMillis )
+    {
+        if ( delayMillis <= 0 )
+        {
+            this.delayMillis = null;
+        }
+
+        this.delayMillis = delayMillis;
+    }
+}



Mime
View raw message