You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2007/09/08 05:50:43 UTC
svn commit: r573782 - in /commons/sandbox/performance/trunk/src:
java/org/apache/commons/performance/
java/org/apache/commons/performance/pool/
test/org/apache/commons/performance/pool/
Author: psteitz
Date: Fri Sep 7 20:50:42 2007
New Revision: 573782
URL: http://svn.apache.org/viewvc?rev=573782&view=rev
Log:
Added some configuration tests.
Added:
commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/
commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java (with props)
commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml (with props)
commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-pool.xml
- copied unchanged from r566024, commons/sandbox/performance/trunk/config-pool.xml
Modified:
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java?rev=573782&r1=573781&r2=573782&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java (original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/LoadGenerator.java Fri Sep 7 20:50:42 2007
@@ -210,4 +210,25 @@
"configuration/run/cycle-type", 10);
}
+
+ /**
+ * @return the configFile
+ */
+ public String getConfigFile() {
+ return configFile;
+ }
+
+ /**
+ * @param configFile the configFile to set
+ */
+ public void setConfigFile(String configFile) {
+ this.configFile = configFile;
+ }
+
+ /**
+ * @return the digester
+ */
+ public Digester getDigester() {
+ return digester;
+ }
}
Modified: commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java?rev=573782&r1=573781&r2=573782&view=diff
==============================================================================
--- commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java (original)
+++ commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/pool/PoolSoak.java Fri Sep 7 20:50:42 2007
@@ -229,4 +229,8 @@
Integer.parseInt(abandonedTimeout));
}
+ public GenericObjectPool getPool() {
+ return pool;
+ }
+
}
Added: commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java?rev=573782&view=auto
==============================================================================
--- commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java (added)
+++ commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java Fri Sep 7 20:50:42 2007
@@ -0,0 +1,141 @@
+/*
+ * 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.commons.performance.pool;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+import org.apache.commons.dbcp.AbandonedConfig;
+import org.apache.commons.dbcp.AbandonedObjectPool;
+import org.apache.commons.math.stat.descriptive.SummaryStatistics;
+import org.apache.commons.pool.impl.GenericObjectPool;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class PoolSoakTest extends TestCase {
+
+
+ public PoolSoakTest(String name) {
+ super(name);
+ }
+
+
+ public static Test suite() {
+ return new TestSuite(PoolSoakTest.class);
+ }
+
+ protected PoolSoak poolSoak = null;
+
+ public void setUp() throws Exception {
+ poolSoak = new PoolSoak();
+ poolSoak.configure();
+ }
+
+ public void testGenericObjectPoolConfig() throws Exception {
+ /** Contents of config file
+ <max-active>15</max-active>
+ <max-idle>15</max-idle>
+ <min-idle>0</min-idle>
+ <max-wait>-1</max-wait>
+ <!-- block, fail, or grow -->
+ <exhausted-action>block</exhausted-action>
+ <test-on-borrow>false</test-on-borrow>
+ <test-on-return>false</test-on-return>
+ <time-between-evictions>-1</time-between-evictions>
+ <tests-per-eviction>3</tests-per-eviction>
+ <idle-timeout>-1</idle-timeout>
+ <test-while-idle>false</test-while-idle>
+ **/
+ poolSoak.getDigester().parse(getInputStream("config-pool.xml"));
+ poolSoak.init();
+ GenericObjectPool pool = poolSoak.getPool();
+ assertEquals(15, pool.getMaxActive());
+ assertEquals(15, pool.getMaxIdle());
+ assertEquals(0, pool.getMinIdle());
+ assertEquals(-1, pool.getMaxWait());
+ assertEquals(GenericObjectPool.WHEN_EXHAUSTED_BLOCK,
+ pool.getWhenExhaustedAction());
+ assertEquals(false, pool.getTestOnBorrow());
+ assertEquals(false, pool.getTestOnReturn());
+ assertEquals(-1, pool.getTimeBetweenEvictionRunsMillis());
+ assertEquals(3, pool.getNumTestsPerEvictionRun());
+ assertEquals(-1, pool.getMinEvictableIdleTimeMillis());
+ assertEquals(false, pool.getTestWhileIdle());
+ }
+
+ public void testAbandonedObjectPoolConfig() throws Exception {
+ /*
+ <pool>
+ <!-- GenericObjectPool or AbandonedObjectPool -->
+ <type>AbandonedObjectPool</type>
+ <max-active>15</max-active>
+ <max-idle>-1</max-idle>
+ <min-idle>0</min-idle>
+ <max-wait>-1</max-wait>
+ <!-- block, fail, or grow -->
+ <exhausted-action>grow</exhausted-action>
+ <test-on-borrow>true</test-on-borrow>
+ <test-on-return>false</test-on-return>
+ <time-between-evictions>-1</time-between-evictions>
+ <tests-per-eviction>3</tests-per-eviction>
+ <idle-timeout>-1</idle-timeout>
+ <test-while-idle>true</test-while-idle>
+ </pool>
+
+ <!-- Ignored unless pool type is AbandonedObjectPool -->
+ <abandoned-config>
+ <log-abandoned>true</log-abandoned>
+ <remove-abandoned>false</remove-abandoned>
+ <abandoned-timeout>50000</abandoned-timeout>
+ </abandoned-config>
+ */
+ poolSoak.getDigester().parse(getInputStream("config-abandoned.xml"));
+ poolSoak.init();
+ AbandonedObjectPool pool = (AbandonedObjectPool) poolSoak.getPool();
+ assertEquals(15, pool.getMaxActive());
+ assertEquals(-1, pool.getMaxIdle());
+ assertEquals(0, pool.getMinIdle());
+ assertEquals(-1, pool.getMaxWait());
+ assertEquals(GenericObjectPool.WHEN_EXHAUSTED_GROW,
+ pool.getWhenExhaustedAction());
+ assertEquals(true, pool.getTestOnBorrow());
+ assertEquals(false, pool.getTestOnReturn());
+ assertEquals(-1, pool.getTimeBetweenEvictionRunsMillis());
+ assertEquals(3, pool.getNumTestsPerEvictionRun());
+ assertEquals(-1, pool.getMinEvictableIdleTimeMillis());
+ assertEquals(true, pool.getTestWhileIdle());
+ }
+
+ /**
+ * Return an appropriate InputStream for the specified test file (which
+ * must be inside our current package).
+ *
+ * Borrowed from Commons Digester RuleTestCase.
+ *
+ * @param name Name of the test file we want
+ * @exception IOException if an input/output error occurs
+ */
+ protected InputStream getInputStream(String name) throws IOException {
+
+ return (this.getClass().getResourceAsStream
+ ("/org/apache/commons/performance/pool/" + name));
+ }
+
+}
Propchange: commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/PoolSoakTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml?rev=573782&view=auto
==============================================================================
--- commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml (added)
+++ commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml Fri Sep 7 20:50:42 2007
@@ -0,0 +1,75 @@
+<!--
+/*
+ * 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.
+ */
+ -->
+
+<configuration>
+
+ <factory>
+ <activate-latency>0</activate-latency>
+ <destroy-latency>0</destroy-latency>
+ <make-latency>100</make-latency>
+ <passivate-latency>0</passivate-latency>
+ <validate-latency>100</validate-latency>
+ <waiter-latency>0</waiter-latency>
+ </factory>
+
+ <pool>
+ <!-- GenericObjectPool or AbandonedObjectPool -->
+ <type>AbandonedObjectPool</type>
+ <max-active>15</max-active>
+ <max-idle>-1</max-idle>
+ <min-idle>0</min-idle>
+ <max-wait>-1</max-wait>
+ <!-- block, fail, or grow -->
+ <exhausted-action>grow</exhausted-action>
+ <test-on-borrow>true</test-on-borrow>
+ <test-on-return>false</test-on-return>
+ <time-between-evictions>-1</time-between-evictions>
+ <tests-per-eviction>3</tests-per-eviction>
+ <idle-timeout>-1</idle-timeout>
+ <test-while-idle>true</test-while-idle>
+ </pool>
+
+ <!-- Ignored unless pool type is AbandonedObjectPool -->
+ <abandoned-config>
+ <log-abandoned>true</log-abandoned>
+ <remove-abandoned>false</remove-abandoned>
+ <abandoned-timeout>50000</abandoned-timeout>
+ </abandoned-config>
+
+ <run>
+ <!-- integerIndexed, integerScan, or textScan -->
+ <iterations>100</iterations>
+ <clients>50</clients>
+ <delay-min>250</delay-min>
+ <delay-max>500</delay-max>
+ <delay-sigma>50</delay-sigma>
+ <!-- constant, gaussian, or poisson -->
+ <delay-type>gaussian</delay-type>
+ <!-- none, linear, random -->
+ <ramp-type>random</ramp-type>
+ <ramp-period>5000</ramp-period>
+ <peak-period>2000</peak-period>
+ <trough-period>5000</trough-period>
+ <!-- none, oscillating (others?)-->
+ <cycle-type>oscillating</cycle-type>
+ </run>
+
+</configuration>
Propchange: commons/sandbox/performance/trunk/src/test/org/apache/commons/performance/pool/config-abandoned.xml
------------------------------------------------------------------------------
svn:eol-style = native