Move /application to /actuator

Change the endpoint default path from `/application` to `/actuator`.

Fixes gh-10970
This commit is contained in:
Phillip Webb
2017-11-22 22:32:11 -08:00
parent 3e2ede51d6
commit 07f71e889e
82 changed files with 203 additions and 211 deletions

View File

@@ -43,14 +43,14 @@ public class AuditEventsEndpointWebIntegrationTests {
@Test
public void eventsWithoutParams() throws Exception {
client.get().uri((builder) -> builder.path("/application/auditevents").build())
client.get().uri((builder) -> builder.path("/actuator/auditevents").build())
.exchange().expectStatus().isBadRequest();
}
@Test
public void eventsWithDateAfter() throws Exception {
client.get()
.uri((builder) -> builder.path("/application/auditevents")
.uri((builder) -> builder.path("/actuator/auditevents")
.queryParam("after", "2016-11-01T13:00:00%2B00:00").build())
.exchange().expectStatus().isOk().expectBody().jsonPath("events")
.isEmpty();
@@ -59,7 +59,7 @@ public class AuditEventsEndpointWebIntegrationTests {
@Test
public void eventsWithPrincipalAndDateAfter() throws Exception {
client.get()
.uri((builder) -> builder.path("/application/auditevents")
.uri((builder) -> builder.path("/actuator/auditevents")
.queryParam("after", "2016-11-01T10:00:00%2B00:00")
.queryParam("principal", "user").build())
.exchange().expectStatus().isOk().expectBody()
@@ -70,7 +70,7 @@ public class AuditEventsEndpointWebIntegrationTests {
@Test
public void eventsWithPrincipalDateAfterAndType() throws Exception {
client.get()
.uri((builder) -> builder.path("/application/auditevents")
.uri((builder) -> builder.path("/actuator/auditevents")
.queryParam("after", "2016-11-01T10:00:00%2B00:00")
.queryParam("principal", "admin").queryParam("type", "logout")
.build())

View File

@@ -40,19 +40,19 @@ public class EndpointLinksResolverTests {
@Test
public void linkResolutionWithTrailingSlashStripsSlashOnSelfLink() {
Map<String, Link> links = this.linksResolver.resolveLinks(Collections.emptyList(),
"https://api.example.com/application/");
"https://api.example.com/actuator/");
assertThat(links).hasSize(1);
assertThat(links).hasEntrySatisfying("self",
linkWithHref("https://api.example.com/application"));
linkWithHref("https://api.example.com/actuator"));
}
@Test
public void linkResolutionWithoutTrailingSlash() {
Map<String, Link> links = this.linksResolver.resolveLinks(Collections.emptyList(),
"https://api.example.com/application");
"https://api.example.com/actuator");
assertThat(links).hasSize(1);
assertThat(links).hasEntrySatisfying("self",
linkWithHref("https://api.example.com/application"));
linkWithHref("https://api.example.com/actuator"));
}
@Test
@@ -63,14 +63,14 @@ public class EndpointLinksResolverTests {
Arrays.asList(operationWithPath("/alpha", "alpha"),
operationWithPath("/alpha/{name}",
"alpha-name")))),
"https://api.example.com/application");
"https://api.example.com/actuator");
assertThat(links).hasSize(3);
assertThat(links).hasEntrySatisfying("self",
linkWithHref("https://api.example.com/application"));
linkWithHref("https://api.example.com/actuator"));
assertThat(links).hasEntrySatisfying("alpha",
linkWithHref("https://api.example.com/application/alpha"));
linkWithHref("https://api.example.com/actuator/alpha"));
assertThat(links).hasEntrySatisfying("alpha-name",
linkWithHref("https://api.example.com/application/alpha/{name}"));
linkWithHref("https://api.example.com/actuator/alpha/{name}"));
}
private WebOperation operationWithPath(String path, String id) {

View File

@@ -101,7 +101,7 @@ class JerseyEndpointsRunner extends AbstractWebEndpointRunner {
this.applicationContext, new ConversionServiceParameterMapper(),
endpointMediaTypes, EndpointPathResolver.useEndpointId(), null, null);
Collection<Resource> resources = new JerseyEndpointResourceFactory()
.createEndpointResources(new EndpointMapping("/application"),
.createEndpointResources(new EndpointMapping("/actuator"),
discoverer.discoverEndpoints(), endpointMediaTypes);
config.registerResources(new HashSet<>(resources));
}

View File

@@ -106,7 +106,7 @@ class WebFluxEndpointsRunner extends AbstractWebEndpointRunner {
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext, new ConversionServiceParameterMapper(),
endpointMediaTypes, EndpointPathResolver.useEndpointId(), null, null);
return new WebFluxEndpointHandlerMapping(new EndpointMapping("/application"),
return new WebFluxEndpointHandlerMapping(new EndpointMapping("/actuator"),
discoverer.discoverEndpoints(), endpointMediaTypes,
new CorsConfiguration());
}

View File

@@ -89,7 +89,7 @@ class WebMvcEndpointRunner extends AbstractWebEndpointRunner {
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext, new ConversionServiceParameterMapper(),
endpointMediaTypes, EndpointPathResolver.useEndpointId(), null, null);
return new WebMvcEndpointHandlerMapping(new EndpointMapping("/application"),
return new WebMvcEndpointHandlerMapping(new EndpointMapping("/actuator"),
discoverer.discoverEndpoints(), endpointMediaTypes,
new CorsConfiguration());
}

View File

@@ -46,13 +46,13 @@ public class EnvironmentEndpointWebIntegrationTests {
@Test
public void home() throws Exception {
client.get().uri("/application/env").exchange().expectStatus().isOk().expectBody()
client.get().uri("/actuator/env").exchange().expectStatus().isOk().expectBody()
.jsonPath("propertySources[?(@.name=='systemProperties')]").exists();
}
@Test
public void sub() throws Exception {
client.get().uri("/application/env/foo").exchange().expectStatus().isOk()
client.get().uri("/actuator/env/foo").exchange().expectStatus().isOk()
.expectBody().jsonPath("property.source").isEqualTo("test")
.jsonPath("property.value").isEqualTo("bar");
}
@@ -63,8 +63,8 @@ public class EnvironmentEndpointWebIntegrationTests {
map.put("food", null);
EnvironmentEndpointWebIntegrationTests.context.getEnvironment()
.getPropertySources().addFirst(new MapPropertySource("null-value", map));
client.get().uri("/application/env?pattern=foo.*").exchange().expectStatus()
.isOk().expectBody().jsonPath(forProperty("test", "foo")).isEqualTo("bar")
client.get().uri("/actuator/env?pattern=foo.*").exchange().expectStatus().isOk()
.expectBody().jsonPath(forProperty("test", "foo")).isEqualTo("bar")
.jsonPath(forProperty("test", "fool")).isEqualTo("baz");
}
@@ -75,7 +75,7 @@ public class EnvironmentEndpointWebIntegrationTests {
map.put("my.foo", "${my.bar}");
context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map));
client.get().uri("/application/env/my.foo").exchange().expectStatus().isOk()
client.get().uri("/actuator/env/my.foo").exchange().expectStatus().isOk()
.expectBody().jsonPath("property.value").isEqualTo("${my.bar}")
.jsonPath(forPropertyEntry("unresolved-placeholder"))
.isEqualTo("${my.bar}");
@@ -88,14 +88,14 @@ public class EnvironmentEndpointWebIntegrationTests {
map.put("my.password", "hello");
context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("placeholder", map));
client.get().uri("/application/env/my.foo").exchange().expectStatus().isOk()
client.get().uri("/actuator/env/my.foo").exchange().expectStatus().isOk()
.expectBody().jsonPath("property.value").isEqualTo("******")
.jsonPath(forPropertyEntry("placeholder")).isEqualTo("******");
}
@Test
public void nestedPathForUnknownKeyShouldReturn404AndBody() throws Exception {
client.get().uri("/application/env/this.does.not.exist").exchange().expectStatus()
client.get().uri("/actuator/env/this.does.not.exist").exchange().expectStatus()
.isNotFound().expectBody().jsonPath("property").doesNotExist()
.jsonPath("propertySources[?(@.name=='test')]").exists()
.jsonPath("propertySources[?(@.name=='systemProperties')]").exists()
@@ -109,7 +109,7 @@ public class EnvironmentEndpointWebIntegrationTests {
map.put("my.foo", "${my.bar}");
context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map));
client.get().uri("/application/env?pattern=my.*").exchange().expectStatus().isOk()
client.get().uri("/actuator/env?pattern=my.*").exchange().expectStatus().isOk()
.expectBody()
.jsonPath(
"propertySources[?(@.name=='unresolved-placeholder')].properties.['my.foo'].value")
@@ -124,7 +124,7 @@ public class EnvironmentEndpointWebIntegrationTests {
map.put("my.password", "hello");
context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("placeholder", map));
client.get().uri("/application/env?pattern=my.*").exchange().expectStatus().isOk()
client.get().uri("/actuator/env?pattern=my.*").exchange().expectStatus().isOk()
.expectBody().jsonPath(forProperty("placeholder", "my.foo"))
.isEqualTo("******");
}

View File

@@ -43,17 +43,16 @@ public class HealthEndpointWebIntegrationTests {
@Test
public void whenHealthIsUp200ResponseIsReturned() throws Exception {
client.get().uri("/application/health").exchange().expectStatus().isOk()
.expectBody().jsonPath("status").isEqualTo("UP")
.jsonPath("details.alpha.status").isEqualTo("UP")
.jsonPath("details.bravo.status").isEqualTo("UP");
client.get().uri("/actuator/health").exchange().expectStatus().isOk().expectBody()
.jsonPath("status").isEqualTo("UP").jsonPath("details.alpha.status")
.isEqualTo("UP").jsonPath("details.bravo.status").isEqualTo("UP");
}
@Test
public void whenHealthIsDown503ResponseIsReturned() throws Exception {
context.getBean("alphaHealthIndicator", TestHealthIndicator.class)
.setHealth(Health.down().build());
client.get().uri("/application/health").exchange().expectStatus()
client.get().uri("/actuator/health").exchange().expectStatus()
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE).expectBody().jsonPath("status")
.isEqualTo("DOWN").jsonPath("details.alpha.status").isEqualTo("DOWN")
.jsonPath("details.bravo.status").isEqualTo("UP");

View File

@@ -45,8 +45,8 @@ public class InfoEndpointWebIntegrationTests {
@Test
public void info() throws Exception {
client.get().uri("/application/info").accept(MediaType.APPLICATION_JSON)
.exchange().expectStatus().isOk().expectBody().jsonPath("beanName1.key11")
client.get().uri("/actuator/info").accept(MediaType.APPLICATION_JSON).exchange()
.expectStatus().isOk().expectBody().jsonPath("beanName1.key11")
.isEqualTo("value11").jsonPath("beanName1.key12").isEqualTo("value12")
.jsonPath("beanName2.key21").isEqualTo("value21")
.jsonPath("beanName2.key22").isEqualTo("value22");

View File

@@ -60,14 +60,14 @@ public class LogFileWebEndpointWebIntegrationTests {
@Test
public void getRequestProduces404ResponseWhenLogFileNotFound() throws Exception {
client.get().uri("/application/logfile").exchange().expectStatus().isNotFound();
client.get().uri("/actuator/logfile").exchange().expectStatus().isNotFound();
}
@Test
public void getRequestProducesResponseWithLogFile() throws Exception {
TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath())
.applyTo(context);
client.get().uri("/application/logfile").exchange().expectStatus().isOk()
client.get().uri("/actuator/logfile").exchange().expectStatus().isOk()
.expectBody(String.class).isEqualTo("--TEST--");
}

View File

@@ -75,7 +75,7 @@ public class LoggersEndpointWebIntegrationTests {
public void getLoggerShouldReturnAllLoggerConfigurations() throws Exception {
given(this.loggingSystem.getLoggerConfigurations()).willReturn(Collections
.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
client.get().uri("/application/loggers").exchange().expectStatus().isOk()
client.get().uri("/actuator/loggers").exchange().expectStatus().isOk()
.expectBody().jsonPath("$.length()").isEqualTo(2).jsonPath("levels")
.isEqualTo(jsonArrayOf("OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG",
"TRACE"))
@@ -89,7 +89,7 @@ public class LoggersEndpointWebIntegrationTests {
public void getLoggerShouldReturnLogLevels() throws Exception {
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
client.get().uri("/application/loggers/ROOT").exchange().expectStatus().isOk()
client.get().uri("/actuator/loggers/ROOT").exchange().expectStatus().isOk()
.expectBody().jsonPath("$.length()").isEqualTo(2)
.jsonPath("configuredLevel").isEqualTo(null).jsonPath("effectiveLevel")
.isEqualTo("DEBUG");
@@ -97,13 +97,13 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() throws Exception {
client.get().uri("/application/loggers/com.does.not.exist").exchange()
.expectStatus().isNotFound();
client.get().uri("/actuator/loggers/com.does.not.exist").exchange().expectStatus()
.isNotFound();
}
@Test
public void setLoggerUsingApplicationJsonShouldSetLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
.expectStatus().isNoContent();
@@ -112,7 +112,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
.expectStatus().isNoContent();
@@ -121,7 +121,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerWithWrongLogLevelResultInBadRequestResponse() throws Exception {
client.post().uri("/application/loggers/ROOT")
client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("configuredLevel", "other")).exchange()
.expectStatus().isBadRequest();
@@ -130,7 +130,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerWithNullLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", null)).exchange()
.expectStatus().isNoContent();
@@ -139,7 +139,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerWithNoLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.emptyMap()).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null);
@@ -150,7 +150,7 @@ public class LoggersEndpointWebIntegrationTests {
throws Exception {
given(this.loggingSystem.getLoggerConfiguration("com.png"))
.willReturn(new LoggerConfiguration("com.png", null, LogLevel.DEBUG));
client.get().uri("/application/loggers/com.png").exchange().expectStatus().isOk()
client.get().uri("/actuator/loggers/com.png").exchange().expectStatus().isOk()
.expectBody().jsonPath("$.length()").isEqualTo(2)
.jsonPath("configuredLevel").isEqualTo(null).jsonPath("effectiveLevel")
.isEqualTo("DEBUG");

View File

@@ -61,13 +61,13 @@ public class HeapDumpWebEndpointWebIntegrationTests {
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus()
throws Exception {
this.endpoint.setAvailable(false);
client.get().uri("/application/heapdump").exchange().expectStatus()
client.get().uri("/actuator/heapdump").exchange().expectStatus()
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
}
@Test
public void getRequestShouldReturnHeapDumpInResponseBody() throws Exception {
client.get().uri("/application/heapdump").exchange().expectStatus().isOk()
client.get().uri("/actuator/heapdump").exchange().expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_OCTET_STREAM)
.expectBody(String.class).isEqualTo("HEAPDUMP");
assertHeapDumpFileIsDeleted();

View File

@@ -55,7 +55,7 @@ public class MetricsEndpointWebIntegrationTests {
@Test
@SuppressWarnings("unchecked")
public void listNames() throws IOException {
String responseBody = client.get().uri("/application/metrics").exchange()
String responseBody = client.get().uri("/actuator/metrics").exchange()
.expectStatus().isOk().expectBody(String.class).returnResult()
.getResponseBody();
Map<String, List<String>> names = this.mapper.readValue(responseBody, Map.class);
@@ -65,7 +65,7 @@ public class MetricsEndpointWebIntegrationTests {
@Test
public void selectByName() throws IOException {
MockClock.clock(registry).add(SimpleConfig.DEFAULT_STEP);
client.get().uri("/application/metrics/jvm.memory.used").exchange().expectStatus()
client.get().uri("/actuator/metrics/jvm.memory.used").exchange().expectStatus()
.isOk().expectBody().jsonPath("$.name").isEqualTo("jvm.memory.used");
}
@@ -73,7 +73,7 @@ public class MetricsEndpointWebIntegrationTests {
public void selectByTag() {
MockClock.clock(registry).add(SimpleConfig.DEFAULT_STEP);
client.get()
.uri("/application/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
.uri("/actuator/metrics/jvm.memory.used?tag=id:Compressed%20Class%20Space")
.exchange().expectStatus().isOk().expectBody().jsonPath("$.name")
.isEqualTo("jvm.memory.used");
}

View File

@@ -42,7 +42,7 @@ public class PrometheusScrapeEndpointIntegrationTests {
@Test
public void scrapeHasContentTypeText004() {
client.get().uri("/application/prometheus").exchange().expectStatus().isOk()
client.get().uri("/actuator/prometheus").exchange().expectStatus().isOk()
.expectHeader()
.contentType(MediaType.parseMediaType(TextFormat.CONTENT_TYPE_004));
}

View File

@@ -52,7 +52,7 @@ public class SessionsEndpointWebIntegrationTests {
@Test
public void sessionsForUsernameWithoutUsernameParam() throws Exception {
client.get().uri((builder) -> builder.path("/application/sessions").build())
client.get().uri((builder) -> builder.path("/actuator/sessions").build())
.exchange().expectStatus().isBadRequest();
}
@@ -62,7 +62,7 @@ public class SessionsEndpointWebIntegrationTests {
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
.willReturn(Collections.emptyMap());
client.get()
.uri((builder) -> builder.path("/application/sessions")
.uri((builder) -> builder.path("/actuator/sessions")
.queryParam("username", "user").build())
.exchange().expectStatus().isOk().expectBody().jsonPath("sessions")
.isEmpty();
@@ -74,7 +74,7 @@ public class SessionsEndpointWebIntegrationTests {
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
.willReturn(Collections.singletonMap(session.getId(), session));
client.get()
.uri((builder) -> builder.path("/application/sessions")
.uri((builder) -> builder.path("/actuator/sessions")
.queryParam("username", "user").build())
.exchange().expectStatus().isOk().expectBody().jsonPath("sessions.[*].id")
.isEqualTo(new JSONArray().appendElement(session.getId()));