You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/22 10:08:15 UTC
svn commit: r1204867 -
/tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java
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