Search in sources :

Example 71 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class TestSystemTagsManager method checkForGlobalButNoMetricTags.

@Test
void checkForGlobalButNoMetricTags() {
    Config metricsConfig = Config.just(ConfigSources.create(GLOBAL_AND_APP_TAG_SETTINGS)).get("metrics");
    MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
    SystemTagsManager mgr = SystemTagsManager.create(metricsSettings);
    MetricID metricID = new MetricID("no-tags-metric");
    Map<String, String> fullTags = new HashMap<>();
    mgr.allTags(metricID).forEach(entry -> fullTags.put(entry.getKey(), entry.getValue()));
    assertThat("Global tags derived from tagless metric ID", fullTags, allOf(hasEntry(GLOBAL_TAG_1, GLOBAL_VALUE_1), hasEntry(GLOBAL_TAG_2, GLOBAL_VALUE_2), hasKey(SystemTagsManager.APP_TAG)));
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) HashMap(java.util.HashMap) Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 72 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class TestSystemTagsManager method checkMetricsSettingsForGlobalTagsConfig.

@Test
void checkMetricsSettingsForGlobalTagsConfig() {
    Config metricsConfig = Config.just(ConfigSources.create(GLOBAL_ONLY_TAGS_SETTINGS)).get("metrics");
    MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
    Map<String, String> tags = metricsSettings.globalTags();
    assertThat("Global tags in settings", tags, allOf(hasEntry(GLOBAL_TAG_1, GLOBAL_VALUE_1), hasEntry(GLOBAL_TAG_2, GLOBAL_VALUE_2), not(hasKey(MetricsSettings.Builder.APP_TAG_CONFIG_KEY))));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 73 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class TestSystemTagsManager method checkSystemTagsManagerForGlobalTags.

@Test
void checkSystemTagsManagerForGlobalTags() {
    Config metricsConfig = Config.just(ConfigSources.create(GLOBAL_ONLY_TAGS_SETTINGS)).get("metrics");
    MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
    SystemTagsManager mgr = SystemTagsManager.create(metricsSettings);
    MetricID metricID = new MetricID("my-metric", new Tag(METRIC_TAG_NAME, METRIC_TAG_VALUE));
    Map<String, String> fullTags = new HashMap<>();
    mgr.allTags(metricID).forEach(entry -> fullTags.put(entry.getKey(), entry.getValue()));
    assertThat("Global tags derived from tagless metric ID", fullTags, allOf(hasEntry(GLOBAL_TAG_1, GLOBAL_VALUE_1), hasEntry(GLOBAL_TAG_2, GLOBAL_VALUE_2), hasEntry(METRIC_TAG_NAME, METRIC_TAG_VALUE), not(hasKey(SystemTagsManager.APP_TAG))));
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) HashMap(java.util.HashMap) Config(io.helidon.config.Config) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.jupiter.api.Test)

Example 74 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class TestSystemTagsManager method checkForGlobalAndAppTags.

@Test
void checkForGlobalAndAppTags() {
    Config metricsConfig = Config.just(ConfigSources.create(GLOBAL_AND_APP_TAG_SETTINGS)).get("metrics");
    MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
    SystemTagsManager mgr = SystemTagsManager.create(metricsSettings);
    MetricID metricID = new MetricID("my-metric", new Tag(METRIC_TAG_NAME, METRIC_TAG_VALUE));
    Map<String, String> fullTags = new HashMap<>();
    mgr.allTags(metricID).forEach(entry -> fullTags.put(entry.getKey(), entry.getValue()));
    assertThat("Global tags derived from tagless metric ID", fullTags, allOf(hasEntry(GLOBAL_TAG_1, GLOBAL_VALUE_1), hasEntry(GLOBAL_TAG_2, GLOBAL_VALUE_2), hasEntry(METRIC_TAG_NAME, METRIC_TAG_VALUE), hasKey(SystemTagsManager.APP_TAG)));
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) HashMap(java.util.HashMap) Config(io.helidon.config.Config) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.jupiter.api.Test)

Example 75 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class TestMetricsSettings method loadConfig.

@BeforeAll
static void loadConfig() throws IOException {
    Config all = Config.just(ConfigSources.classpath(CONFIG_FILE));
    topLevelDisabled = all.get("topLevelDisabled").get("metrics");
    baseDisabled = all.get("baseDisabled").get("metrics");
    baseSelectiveDisabled = all.get("baseSelectiveDisabled").get("metrics");
    withKpi = all.get("withKpi").get("metrics");
    withRESTSettings = all.get("withRESTSettings").get("metrics");
    withOneRegistrySettings = all.get("withOneRegistrySettings").get("metrics");
    withTwoRegistrySettings = all.get("withTwoRegistrySettings").get("metrics");
    registrySettingsWithBadFilterSyntax = all.get("registrySettingsWithBadFilterSyntax").get("metrics");
    withSimpleFilter = all.get("withSimpleFilter").get("metrics");
}
Also used : Config(io.helidon.config.Config) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

Config (io.helidon.config.Config)329 Test (org.junit.jupiter.api.Test)169 LogConfig (io.helidon.common.LogConfig)56 WebServer (io.helidon.webserver.WebServer)54 Routing (io.helidon.webserver.Routing)51 BeforeAll (org.junit.jupiter.api.BeforeAll)24 Security (io.helidon.security.Security)20 HealthSupport (io.helidon.health.HealthSupport)18 Single (io.helidon.common.reactive.Single)17 MetricsSupport (io.helidon.metrics.MetricsSupport)16 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)16 ConfigSources (io.helidon.config.ConfigSources)15 JsonpSupport (io.helidon.media.jsonp.JsonpSupport)15 SecurityContext (io.helidon.security.SecurityContext)15 Optional (java.util.Optional)15 TimeUnit (java.util.concurrent.TimeUnit)15 WebSecurity (io.helidon.security.integration.webserver.WebSecurity)13 HealthChecks (io.helidon.health.checks.HealthChecks)12 WebClient (io.helidon.webclient.WebClient)12 GrpcRouting (io.helidon.grpc.server.GrpcRouting)11