Projects:Inclusion Of Apache JDBC Connection Pool In Distribution/QA
Test Plan
Defined in TestLink in Platform > Connection Pool Project suite. The following scenarios have been tested manually to check any problems in the upgrade to 3.0PR15Q4.
- Scenario 1: The purspose of this scenario is upgrade from < 3.0PR15Q4 to current pi (3.0PR15Q4).
- Scenario 2: The purspose of this scenario is upgrade from < 3.0PR15Q4 using Apache JDBC Connection Pool module to current pi (3.0PR15Q4).
- Scenario 2.1: In this case ConnectionPool.properties has default properties defined in ConnectionPool.properties.template.
- Scenario 2.2: In this case ConnectionPool.properties has default properties and new ones.
- Scenario 3: The purspose of this scenario is upgrade from < 3.0PR15Q4 using an external connection pool to current pi (3.0PR15Q4).
- Scenario 3.1.: With properties in Openbravo.properties.
- Scenario 4: The purspose of this scenario is install a new 3.0PR15Q4.
Performance test
As we saw in Performance considerations section some performance tests to obtain multiple serial connections have been made. This performance test is following:
package org.openbravo.test; import java.lang.reflect.Method; import java.sql.Connection; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Properties; import org.hibernate.Session; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.openbravo.base.session.OBPropertiesProvider; import org.openbravo.dal.core.SessionHandler; import org.openbravo.database.ConnectionProviderImpl; import org.openbravo.database.ExternalConnectionPool; import org.openbravo.test.base.HiddenObjectHelper; import org.openbravo.test.base.OBBaseTest; @RunWith(Parameterized.class) public class ConnectionPool extends OBBaseTest { private static final int NUM_OF_EXECUTIONS = 10; private String poolClass; private int numOfConns; public ConnectionPool(String poolClass, int numOfConns) { this.poolClass = poolClass; this.numOfConns = numOfConns; } @Parameters(name = "{0} - {1}") public static Collection<Object[]> params() { String pools[] = { // "org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool", // "", // }; List<Object[]> configs = new ArrayList<Object[]>(); for (String pool : pools) { configs.add(new Object[] { pool, 10 }); configs.add(new Object[] { pool, 50 }); configs.add(new Object[] { pool, 100 }); configs.add(new Object[] { pool, 1000 }); configs.add(new Object[] { pool, 10000 }); // configs.add(new Object[] { pool, 100000 }); // configs.add(new Object[] { pool, 1000000 }); } return configs; } @Test public void xsql() throws Exception { Properties properties = OBPropertiesProvider.getInstance().getOpenbravoProperties(); properties.put("db.externalPoolClassName", poolClass); ConnectionProviderImpl cp = new ConnectionProviderImpl(properties); // cp.getConnection(); Method newConnMethod = ConnectionProviderImpl.class.getDeclaredMethod("getNewConnection", String.class); newConnMethod.setAccessible(true); for (int exec = 0; exec < NUM_OF_EXECUTIONS; exec++) { long t = System.currentTimeMillis(); for (int i = 0; i < numOfConns; i++) { Connection cn = (Connection) newConnMethod.invoke(cp, "myPool"); cn.close(); } System.out.println("xsql :" + ("".equals(poolClass) ? "commons.dbcp" : poolClass) + "(" + numOfConns + "): " + (System.currentTimeMillis() - t)); } } @Test public void dal() throws Exception { SessionHandler sh = SessionHandler.getInstance(); sh.commitAndClose(); if (!"".equals(poolClass)) { HiddenObjectHelper.set(sh, "externalConnectionPool", ExternalConnectionPool.getInstance(poolClass)); } else { HiddenObjectHelper.set(sh, "externalConnectionPool", null); } Method createSession = SessionHandler.class.getDeclaredMethod("createSession"); createSession.setAccessible(true); for (int exec = 0; exec < NUM_OF_EXECUTIONS; exec++) { long t = System.currentTimeMillis(); for (int i = 0; i < numOfConns; i++) { HiddenObjectHelper.set(sh, "connection", null); Session s = (Session) createSession.invoke(sh); Connection conn = sh.getConnection(); if (conn != null) { sh.getConnection().close(); } s.close(); } System.out.println("dal :" + ("".equals(poolClass) ? "commons.dbcp" : poolClass) + "(" + numOfConns + "): " + (System.currentTimeMillis() - t)); } } }