tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1204867 - /tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java
Date Tue, 22 Nov 2011 09:08:15 GMT
Author: kkolinko
Date: Tue Nov 22 09:08:14 2011
New Revision: 1204867

URL: http://svn.apache.org/viewvc?rev=1204867&view=rev
Log:
Run Mapper performance test twice if it takes too long,
to reject occasional failures observed by Gump/buildbot

Modified:
    tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java

Modified: tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java?rev=1204867&r1=1204866&r2=1204867&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java Tue Nov 22 09:08:14
2011
@@ -22,14 +22,17 @@ import static org.junit.Assert.assertTru
 import org.junit.Before;
 import org.junit.Test;
 
+import org.apache.catalina.startup.LoggingBaseTest;
 import org.apache.tomcat.util.buf.MessageBytes;
 
-public class TestMapper {
+public class TestMapper extends LoggingBaseTest {
 
     private Mapper mapper;
 
     @Before
+    @Override
     public void setUp() throws Exception {
+        super.setUp();
         mapper = new Mapper();
 
         mapper.addHost("sjbjdvwsbvhrb", new String[0], "blah1");
@@ -162,6 +165,21 @@ public class TestMapper {
 
     @Test
     public void testPerformance() throws Exception {
+        // Takes ~1s on markt's laptop. If this takes more than 4s something
+        // probably needs looking at. If this fails repeatedly then we may need
+        // to increase this limit.
+        final long maxTime = 4000;
+        long time = testPerformanceImpl();
+        if (time >= maxTime) {
+            // Rerun to reject occasional failures, e.g. because of gc
+            log.warn("testPerformance() test completed in " + time + " ms");
+            time = testPerformanceImpl();
+            log.warn("testPerformance() test rerun completed in " + time + " ms");
+        }
+        assertTrue(String.valueOf(time), time < maxTime);
+    }
+
+    private long testPerformanceImpl() throws Exception {
         MappingData mappingData = new MappingData();
         MessageBytes host = MessageBytes.newInstance();
         host.setString("iowejoiejfoiew");
@@ -176,10 +194,6 @@ public class TestMapper {
             mapper.map(host, uri, null, mappingData);
         }
         long time = System.currentTimeMillis() - start;
-
-        // Takes ~1s on markt's laptop. If this takes more than 4s something
-        // probably needs looking at. If this fails repeatedly then we may need
-        // to increase this limit.
-        assertTrue(String.valueOf(time), time < 4000);
+        return time;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message