This commit is contained in:
Phillip Webb
2018-02-19 19:53:59 -08:00
parent 482ecc606c
commit adf22d6e4a
14 changed files with 60 additions and 43 deletions

View File

@@ -70,7 +70,6 @@ public class WebEndpointProperties {
return this.pathMapping;
}
public static class Exposure {
/**

View File

@@ -174,9 +174,9 @@ public class MetricsProperties {
/**
* Specific SLA boundaries for meter IDs starting-with the specified name. The
* longest match wins, the key `all` can also be used to configure all meters.
* Counters will be published for each specified boundary. Values can be
* specified as a long or as a Duration value (for timer meters, defaulting to ms
* if no unit specified).
* Counters will be published for each specified boundary. Values can be specified
* as a long or as a Duration value (for timer meters, defaulting to ms if no unit
* specified).
*/
private Map<String, ServiceLevelAgreementBoundary[]> sla = new LinkedHashMap<>();

View File

@@ -61,8 +61,8 @@ public class ControllerEndpointWebFluxIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigReactiveWebApplicationContext();
this.context.register(DefaultConfiguration.class, ExampleController.class);
TestPropertyValues.of("management.endpoints.web.exposure.include=*").applyTo(
this.context);
TestPropertyValues.of("management.endpoints.web.exposure.include=*")
.applyTo(this.context);
this.context.refresh();
WebTestClient webClient = WebTestClient.bindToApplicationContext(this.context)
.build();

View File

@@ -83,8 +83,10 @@ public class ControllerEndpointWebMvcIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class, ExampleController.class);
TestPropertyValues.of("management.endpoints.web.base-path:/management",
"management.endpoints.web.exposure.include=*").applyTo(this.context);
TestPropertyValues
.of("management.endpoints.web.base-path:/management",
"management.endpoints.web.exposure.include=*")
.applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/example")).andExpect(status().isOk());
}

View File

@@ -54,8 +54,8 @@ public class WebFluxEndpointCorsIntegrationTests {
ManagementContextAutoConfiguration.class,
ReactiveManagementContextAutoConfiguration.class,
BeansEndpointAutoConfiguration.class);
TestPropertyValues.of("management.endpoints.web.exposure.include:*").applyTo(
this.context);
TestPropertyValues.of("management.endpoints.web.exposure.include:*")
.applyTo(this.context);
}
@Test

View File

@@ -62,8 +62,8 @@ public class WebMvcEndpointCorsIntegrationTests {
ManagementContextAutoConfiguration.class,
ServletManagementContextAutoConfiguration.class,
BeansEndpointAutoConfiguration.class);
TestPropertyValues.of("management.endpoints.web.exposure.include:*").applyTo(
this.context);
TestPropertyValues.of("management.endpoints.web.exposure.include:*")
.applyTo(this.context);
}
@Test

View File

@@ -104,8 +104,10 @@ public class WebMvcEndpointIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class);
TestPropertyValues.of("management.endpoints.web.base-path:/management",
"management.endpoints.web.exposure.include=*").applyTo(this.context);
TestPropertyValues
.of("management.endpoints.web.base-path:/management",
"management.endpoints.web.exposure.include=*")
.applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
}
@@ -114,8 +116,8 @@ public class WebMvcEndpointIntegrationTests {
public void linksAreProvidedToAllEndpointTypes() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(DefaultConfiguration.class, EndpointsConfiguration.class);
TestPropertyValues.of("management.endpoints.web.exposure.include=*").applyTo(
this.context);
TestPropertyValues.of("management.endpoints.web.exposure.include=*")
.applyTo(this.context);
MockMvc mockMvc = doCreateMockMvc();
mockMvc.perform(get("/actuator").accept("*/*")).andExpect(status().isOk())
.andExpect(jsonPath("_links", both(hasKey("beans")).and(hasKey("servlet"))

View File

@@ -56,7 +56,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresAClock() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Clock.class));
this.contextRunner
.run((context) -> assertThat(context).hasSingleBean(Clock.class));
}
@Test
@@ -84,15 +85,16 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresJvmMetrics() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(JvmGcMetrics.class).hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
.hasSingleBean(ClassLoaderMetrics.class));
}
@Test
public void allowsJvmMetricsToBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.binders.jvm.enabled=false")
this.contextRunner
.withPropertyValues("management.metrics.binders.jvm.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean(JvmGcMetrics.class)
.doesNotHaveBean(JvmMemoryMetrics.class)
.doesNotHaveBean(JvmThreadMetrics.class)
@@ -111,7 +113,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomJvmMemoryMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasBean("customJvmMemoryMetrics")
@@ -121,7 +124,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomJvmThreadMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
@@ -131,7 +135,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomClassLoaderMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
@@ -147,7 +152,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsLogbackMetricsToBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.binders.logback.enabled=false")
this.contextRunner
.withPropertyValues("management.metrics.binders.logback.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(LogbackMetrics.class));
}
@@ -167,7 +173,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsUptimeMetricsToBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.binders.uptime.enabled=false")
this.contextRunner
.withPropertyValues("management.metrics.binders.uptime.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(UptimeMetrics.class));
}
@@ -195,7 +202,8 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomProcessorMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomProcessorMetricsConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomProcessorMetricsConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(ProcessorMetrics.class)
.hasBean("customProcessorMetrics"));
@@ -209,14 +217,16 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsFileDescriptorMetricsToBeDisabled() {
this.contextRunner.withPropertyValues("management.metrics.binders.files.enabled=false")
this.contextRunner
.withPropertyValues("management.metrics.binders.files.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(FileDescriptorMetrics.class));
}
@Test
public void allowsCustomFileDescriptorMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class)
.hasBean("customFileDescriptorMetrics"));

View File

@@ -38,4 +38,5 @@ public class DatadogPropertiesTests extends StepRegistryPropertiesTests {
assertThat(properties.getHostTag()).isEqualTo(config.hostTag());
assertThat(properties.getUri()).isEqualTo(config.uri());
}
}

View File

@@ -87,12 +87,13 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
GraphiteMeterRegistry registry = spyOnDisposableBean(
GraphiteMeterRegistry.class, context);
context.close();
verify(registry).stop();
});
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
GraphiteMeterRegistry registry = spyOnDisposableBean(
GraphiteMeterRegistry.class, context);
context.close();
verify(registry).stop();
});
}
@SuppressWarnings("unchecked")

View File

@@ -103,12 +103,13 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
JmxMeterRegistry registry = spyOnDisposableBean(JmxMeterRegistry.class,
context);
context.close();
verify(registry).stop();
});
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
JmxMeterRegistry registry = spyOnDisposableBean(
JmxMeterRegistry.class, context);
context.close();
verify(registry).stop();
});
}
@SuppressWarnings("unchecked")

View File

@@ -88,7 +88,8 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomCollectorRegistryToBeUsed() {
this.contextRunner.withUserConfiguration(CustomCollectorRegistryConfiguration.class)
this.contextRunner
.withUserConfiguration(CustomCollectorRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(PrometheusMeterRegistry.class)
.hasBean("customCollectorRegistry")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.