Skip to content

Commit

Permalink
Make test resilient to fluctuating pool names, caused by
Browse files Browse the repository at this point in the history
reuse or non-reuse of forks during testing.
  • Loading branch information
brettwooldridge committed Apr 19, 2017
1 parent bd45c52 commit 04f6d4a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public void noConnectionWithoutPoolName() throws Exception {

StubConnection.slowCreate = true;
try (HikariDataSource ds = new HikariDataSource(config)) {
assertThat(getValue("hikaricp_active_connections", "HikariPool-1"), is(0.0));
assertThat(getValue("hikaricp_idle_connections", "HikariPool-1"), is(0.0));
assertThat(getValue("hikaricp_pending_threads", "HikariPool-1"), is(0.0));
assertThat(getValue("hikaricp_connections", "HikariPool-1"), is(0.0));
String poolName = ds.getHikariConfigMXBean().getPoolName();
assertThat(getValue("hikaricp_active_connections", poolName), is(0.0));
assertThat(getValue("hikaricp_idle_connections", poolName), is(0.0));
assertThat(getValue("hikaricp_pending_threads", poolName), is(0.0));
assertThat(getValue("hikaricp_connections", poolName), is(0.0));
}
finally {
StubConnection.slowCreate = false;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void connectionClosed() throws Exception {
try (Connection connection1 = ds.getConnection()) {
// close immediately
}

assertThat(getValue("hikaricp_active_connections", "connectionClosed"), is(0.0));
assertThat(getValue("hikaricp_idle_connections", "connectionClosed"), is(1.0));
assertThat(getValue("hikaricp_pending_threads", "connectionClosed"), is(0.0));
Expand Down

0 comments on commit 04f6d4a

Please sign in to comment.