Skip to content

Commit

Permalink
(MAINT) Close datasource in max connection jdbc pool tests
Browse files Browse the repository at this point in the history
Previously, the max connections jdbc pool-construction tests did not
close the connection pool data source before falling out of scope.
Depending upon timing, this could cause the tests to fail on
attempting to drop temp databases which are still busy being used
by the connection pool.

This commit wraps usage of the data source in each of the max
connections tests with `with-open` calls, allowing the connection pool
to be closed off before any calls to drop the temporary databases occur
(and, therefore, for the tests to complete successfully).
  • Loading branch information
camlow325 committed Jan 28, 2017
1 parent 5883b46 commit 3832c43
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/puppetlabs/puppetdb/jdbc_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,21 @@
(testing "max connections setting defaults to 25"
(call-with-antonym-test-database
(fn []
(let [pool (-> *db*
defaulted-read-db-config
subject/pooled-datasource)]
(is (= 25 (.getMaximumPoolSize (:datasource pool))))))))
(with-open [data-source (-> *db*
defaulted-read-db-config
subject/pooled-datasource
:datasource)]
(is (= 25 (.getMaximumPoolSize data-source)))))))

(testing "max connections setting takes effect"
(call-with-antonym-test-database
(fn []
(let [pool (-> *db*
defaulted-read-db-config
(assoc :maximum-pool-size 5)
subject/pooled-datasource)]
(is (= 5 (.getMaximumPoolSize (:datasource pool)))))))))
(with-open [data-source (-> *db*
defaulted-read-db-config
(assoc :maximum-pool-size 5)
subject/pooled-datasource
:datasource)]
(is (= 5 (.getMaximumPoolSize data-source))))))))

(deftest-antonyms query-to-vec
(testing "query string only"
Expand Down

0 comments on commit 3832c43

Please sign in to comment.