Fix logger level to not show up by default
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 May 2009 04:35:22 +0000 (04:35 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 May 2009 04:35:22 +0000 (04:35 +0000)
Add fairness tests to all

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@770889 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java

index 6e2aedf..7196df9 100644 (file)
@@ -76,6 +76,27 @@ public class CheckOutThreadTest extends DefaultTestCase {
         tearDown();
     }
 
+    public void testPoolThreads10Connections10Fair() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setFairQueue(true);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = this.datasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10Fair]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
     public void testC3P0Threads10Connections10() throws Exception {
         init();
         this.datasource.getPoolProperties().setMaxActive(10);
@@ -205,6 +226,7 @@ public class CheckOutThreadTest extends DefaultTestCase {
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
         this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setFairQueue(false);
         this.threadcount = 10;
         this.transferProperties();
         this.datasource.getConnection().close();
@@ -222,6 +244,29 @@ public class CheckOutThreadTest extends DefaultTestCase {
         tearDown();
     }
     
+    public void testPoolThreads10Connections10ValidateFair() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setFairQueue(true);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-validate-"+i);
+            t.d = this.datasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10ValidateFair]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
     public void testC3P0Threads10Connections10Validate() throws Exception {
         init();
         this.datasource.getPoolProperties().setMaxActive(10);
@@ -271,6 +316,7 @@ public class CheckOutThreadTest extends DefaultTestCase {
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
         this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setFairQueue(false);
         this.threadcount = 20;
         this.transferProperties();
         this.datasource.getConnection().close();
@@ -288,6 +334,29 @@ public class CheckOutThreadTest extends DefaultTestCase {
         tearDown();
     }
     
+    public void testPoolThreads10Connections20ValidateFair() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setFairQueue(true);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-validate-"+i);
+            t.d = this.datasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads20Connections10ValidateFair]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+    
     public void testC3P0Threads10Connections20Validate() throws Exception {
         init();
         this.datasource.getPoolProperties().setMaxActive(10);
index ae1b95a..10ed110 100644 (file)
@@ -106,6 +106,7 @@ public class DefaultTestCase extends TestCase {
     protected void transferPropertiesToC3P0() throws Exception {
         System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "WARNING");
         MLog.getLogger().setLevel(MLevel.WARNING);
+        MLog.getLogger("com").setLevel(MLevel.WARNING);
         //http://www.mchange.com/projects/c3p0/index.html#automaticTestTable
         ComboPooledDataSource c3p0 = new ComboPooledDataSource();  
         c3p0.setAcquireIncrement(1);