forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#38108 from yrodiere/datasource-active
Add runtime configuration property `quarkus.datasource.active`
- Loading branch information
Showing
78 changed files
with
3,075 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...l/deployment/src/test/java/io/quarkus/agroal/test/AgroalMetricsConfigActiveFalseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.quarkus.agroal.test; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.metrics.Counter; | ||
import org.eclipse.microprofile.metrics.Gauge; | ||
import org.eclipse.microprofile.metrics.MetricID; | ||
import org.eclipse.microprofile.metrics.MetricRegistry; | ||
import org.eclipse.microprofile.metrics.Tag; | ||
import org.eclipse.microprofile.metrics.annotation.RegistryType; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class AgroalMetricsConfigActiveFalseTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("application-metrics-enabled.properties") | ||
.overrideConfigKey("quarkus.datasource.active", "false") | ||
.overrideConfigKey("quarkus.datasource.ds1.active", "false"); | ||
|
||
@Inject | ||
@RegistryType(type = MetricRegistry.Type.VENDOR) | ||
MetricRegistry registry; | ||
|
||
@Test | ||
public void testMetricsOfDefaultDS() { | ||
Counter acquireCount = registry.getCounters() | ||
.get(new MetricID("agroal.acquire.count", new Tag("datasource", "default"))); | ||
Gauge<?> maxUsed = registry.getGauges() | ||
.get(new MetricID("agroal.max.used.count", new Tag("datasource", "default"))); | ||
|
||
Assertions.assertNull(acquireCount, "Agroal metrics should not be registered for deactivated datasources eagerly"); | ||
Assertions.assertNull(maxUsed, "Agroal metrics should not be registered for deactivated datasources eagerly"); | ||
} | ||
|
||
@Test | ||
public void testMetricsOfDs1() { | ||
Counter acquireCount = registry.getCounters().get(new MetricID("agroal.acquire.count", | ||
new Tag("datasource", "ds1"))); | ||
Gauge<?> maxUsed = registry.getGauges().get(new MetricID("agroal.max.used.count", | ||
new Tag("datasource", "ds1"))); | ||
|
||
Assertions.assertNull(acquireCount, "Agroal metrics should not be registered for deactivated datasources eagerly"); | ||
Assertions.assertNull(maxUsed, "Agroal metrics should not be registered for deactivated datasources eagerly"); | ||
} | ||
|
||
} |
Oops, something went wrong.