ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [1/2] ambari git commit: AMBARI-9736 - Ambari Exhausts Connection Pool When Using MySQL Due To Invalid Connections (jonathanhurley)
Date Sat, 21 Feb 2015 13:39:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 00ee76d31 -> 3271d1d1f


http://git-wip-us.apache.org/repos/asf/ambari/blob/3271d1d1/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 207f1eb..06af5c7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -35,6 +35,8 @@ import java.util.Properties;
 import junit.framework.Assert;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.configuration.Configuration.ConnectionPoolType;
+import org.apache.ambari.server.configuration.Configuration.DatabaseType;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.security.authorization.LdapServerProperties;
 import org.apache.commons.io.FileUtils;
@@ -350,4 +352,55 @@ public class ConfigurationTest {
     Assert.assertEquals("15", ldapProperties.getAdminGroupMappingRules());
     Assert.assertEquals("16", ldapProperties.getGroupSearchFilter());
   }
+
+  @Test
+  public void testConnectionPoolingProperties() throws Exception {
+    // test defaults
+    final Properties ambariProperties = new Properties();
+    final Configuration configuration = new Configuration(ambariProperties);
+    Assert.assertEquals(ConnectionPoolType.INTERNAL, configuration.getConnectionPoolType());
+    Assert.assertEquals(5, configuration.getConnectionPoolAcquisitionSize());
+    Assert.assertEquals(7200, configuration.getConnectionPoolIdleTestInternval());
+    Assert.assertEquals(0, configuration.getConnectionPoolMaximumAge());
+    Assert.assertEquals(0, configuration.getConnectionPoolMaximumExcessIdle());
+    Assert.assertEquals(14400, configuration.getConnectionPoolMaximumIdle());
+    Assert.assertEquals(32, configuration.getConnectionPoolMaximumSize());
+    Assert.assertEquals(5, configuration.getConnectionPoolMinimumSize());
+
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL, ConnectionPoolType.C3P0.getName());
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_MIN_SIZE, "1");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_MAX_SIZE, "2");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_AQUISITION_SIZE,
"3");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_MAX_AGE, "4");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_MAX_IDLE_TIME,
"5");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_MAX_IDLE_TIME_EXCESS,
"6");
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_CONNECTION_POOL_IDLE_TEST_INTERVAL,
"7");
+
+    Assert.assertEquals(ConnectionPoolType.C3P0, configuration.getConnectionPoolType());
+    Assert.assertEquals(3, configuration.getConnectionPoolAcquisitionSize());
+    Assert.assertEquals(7, configuration.getConnectionPoolIdleTestInternval());
+    Assert.assertEquals(4, configuration.getConnectionPoolMaximumAge());
+    Assert.assertEquals(6, configuration.getConnectionPoolMaximumExcessIdle());
+    Assert.assertEquals(5, configuration.getConnectionPoolMaximumIdle());
+    Assert.assertEquals(2, configuration.getConnectionPoolMaximumSize());
+    Assert.assertEquals(1, configuration.getConnectionPoolMinimumSize());
+  }
+
+  @Test
+  public void testDatabaseType() throws Exception {
+    final Properties ambariProperties = new Properties();
+    final Configuration configuration = new Configuration(ambariProperties);
+
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "jdbc:oracle://server");
+    Assert.assertEquals( DatabaseType.ORACLE, configuration.getDatabaseType() );
+
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "jdbc:postgres://server");
+    Assert.assertEquals( DatabaseType.POSTGRES, configuration.getDatabaseType() );
+
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "jdbc:mysql://server");
+    Assert.assertEquals( DatabaseType.MYSQL, configuration.getDatabaseType() );
+
+    ambariProperties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "jdbc:derby://server");
+    Assert.assertEquals( DatabaseType.DERBY, configuration.getDatabaseType() );
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/3271d1d1/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionSchedulerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionSchedulerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionSchedulerTest.java
index 366171b..faf44e3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionSchedulerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/scheduler/ExecutionSchedulerTest.java
@@ -17,7 +17,16 @@
  */
 package org.apache.ambari.server.scheduler;
 
+import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.spy;
+import static org.powermock.api.easymock.PowerMock.createNiceMock;
+import static org.powermock.api.easymock.PowerMock.expectNew;
+import static org.powermock.api.easymock.PowerMock.expectPrivate;
+
+import java.util.Properties;
+
 import junit.framework.Assert;
+
 import org.apache.ambari.server.configuration.Configuration;
 import org.junit.After;
 import org.junit.Before;
@@ -30,14 +39,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
 import org.quartz.Scheduler;
 import org.quartz.impl.StdSchedulerFactory;
 
-import java.io.File;
-import java.util.Properties;
-import static org.easymock.EasyMock.expect;
-import static org.mockito.Mockito.spy;
-import static org.powermock.api.easymock.PowerMock.createNiceMock;
-import static org.powermock.api.easymock.PowerMock.expectNew;
-import static org.powermock.api.easymock.PowerMock.expectPrivate;
-
 @RunWith(PowerMockRunner.class)
 @PowerMockIgnore("javax.management.*")
 public class ExecutionSchedulerTest {
@@ -51,11 +52,11 @@ public class ExecutionSchedulerTest {
     properties.setProperty(Configuration.EXECUTION_SCHEDULER_CLUSTERED, "false");
     properties.setProperty(Configuration.EXECUTION_SCHEDULER_CONNECTIONS, "2");
     properties.setProperty(Configuration.SERVER_JDBC_DRIVER_KEY, "db.driver");
-    properties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "db.url");
+    properties.setProperty(Configuration.SERVER_JDBC_URL_KEY, "jdbc:postgresql://localhost/");
     properties.setProperty(Configuration.SERVER_JDBC_USER_NAME_KEY, "user");
     properties.setProperty(Configuration.SERVER_DB_NAME_KEY, "derby");
 
-    this.configuration = new Configuration(properties);
+    configuration = new Configuration(properties);
 
   }
 
@@ -76,7 +77,7 @@ public class ExecutionSchedulerTest {
     Assert.assertEquals("2", actualProperties.getProperty("org.quartz.threadPool.threadCount"));
     Assert.assertEquals("2", actualProperties.getProperty("org.quartz.dataSource.myDS.maxConnections"));
     Assert.assertEquals("false", actualProperties.getProperty("org.quartz.jobStore.isClustered"));
-    Assert.assertEquals("org.quartz.impl.jdbcjobstore.StdJDBCDelegate",
+    Assert.assertEquals("org.quartz.impl.jdbcjobstore.PostgreSQLDelegate",
       actualProperties.getProperty("org.quartz.jobStore.driverDelegateClass"));
     Assert.assertEquals("select 0",
       actualProperties.getProperty("org.quartz.dataSource.myDS.validationQuery"));


Mime
View raw message