From ebd9c353524d187524be23053014d42a5e755a7d Mon Sep 17 00:00:00 2001 From: Matt Hottinger Date: Thu, 21 May 2020 02:50:04 -0500 Subject: [PATCH] ###Description: (#567) Updated some dependencies * Spring Boot: 1.5.21 to 1.5.22 * Commons DBCP -> Commons DBCP2 ###Motivation: Prepare scheduler code base for upgrade to Spring Boot 2. --- scheduler/pom.xml | 7 +++--- .../scheduler/health/DBStatusCollector.java | 6 ++--- .../src/main/resources/applicationContext.xml | 24 +++++++++---------- .../scheduler/SchedulerApplicationTest.java | 12 ++++++++++ 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/scheduler/pom.xml b/scheduler/pom.xml index 8ca010f9b..ec383eca3 100644 --- a/scheduler/pom.xml +++ b/scheduler/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.21.RELEASE + 1.5.22.RELEASE @@ -80,8 +80,9 @@ 8.0.18 - commons-dbcp - commons-dbcp + org.apache.commons + commons-dbcp2 + 2.7.0 io.springfox diff --git a/scheduler/src/main/java/org/cloudfoundry/autoscaler/scheduler/health/DBStatusCollector.java b/scheduler/src/main/java/org/cloudfoundry/autoscaler/scheduler/health/DBStatusCollector.java index 6a6eef757..e891d223e 100644 --- a/scheduler/src/main/java/org/cloudfoundry/autoscaler/scheduler/health/DBStatusCollector.java +++ b/scheduler/src/main/java/org/cloudfoundry/autoscaler/scheduler/health/DBStatusCollector.java @@ -5,7 +5,7 @@ import javax.sql.DataSource; -import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.dbcp2.BasicDataSource; import io.prometheus.client.Collector; import io.prometheus.client.GaugeMetricFamily; @@ -39,7 +39,7 @@ public List collect() { basicDataSource.getInitialSize())); mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_data_source" + "_max_active", "The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit", - basicDataSource.getMaxActive())); + basicDataSource.getMaxTotal())); mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_data_source" + "_max_idle", "The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.", basicDataSource.getMaxIdle())); @@ -64,7 +64,7 @@ public List collect() { policyBasicDataSource.getInitialSize())); mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_policy_db_data_source" + "_max_active", "The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit", - policyBasicDataSource.getMaxActive())); + policyBasicDataSource.getMaxTotal())); mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_policy_db_data_source" + "_max_idle", "The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.", policyBasicDataSource.getMaxIdle())); diff --git a/scheduler/src/main/resources/applicationContext.xml b/scheduler/src/main/resources/applicationContext.xml index 4b421f248..cab3e92f7 100644 --- a/scheduler/src/main/resources/applicationContext.xml +++ b/scheduler/src/main/resources/applicationContext.xml @@ -40,31 +40,31 @@ - - - - - - + + + + + - - - - - - + + + + + diff --git a/scheduler/src/test/java/org/cloudfoundry/autoscaler/scheduler/SchedulerApplicationTest.java b/scheduler/src/test/java/org/cloudfoundry/autoscaler/scheduler/SchedulerApplicationTest.java index 8f92f47bf..d7ee933c0 100644 --- a/scheduler/src/test/java/org/cloudfoundry/autoscaler/scheduler/SchedulerApplicationTest.java +++ b/scheduler/src/test/java/org/cloudfoundry/autoscaler/scheduler/SchedulerApplicationTest.java @@ -1,22 +1,34 @@ package org.cloudfoundry.autoscaler.scheduler; +import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.Matchers.isA; +import static org.junit.Assert.assertThat; +import org.apache.commons.dbcp2.BasicDataSource; import org.cloudfoundry.autoscaler.scheduler.util.error.DataSourceConfigurationException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class SchedulerApplicationTest { + @Autowired + private BasicDataSource dataSource; + @Rule public ExpectedException expectedEx = ExpectedException.none(); + @Test + public void testTomcatConnectionPoolNameCorrect() { + assertThat(dataSource.getClass().getName(), equalToIgnoringCase("org.apache.commons.dbcp2.BasicDataSource")); + } + @Test public void testApplicationExitsWhenSchedulerDBUnreachable() { expectedEx.expect(BeanCreationException.class);