Support Mongo's Stable API in MongoHealthIndicator
Closes gh-30849
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
management.endpoints.web.exposure.include=*
|
||||
management.endpoint.health.show-details=always
|
||||
spring.security.user.name=user
|
||||
spring.security.user.password=password
|
||||
@@ -29,6 +29,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -53,6 +54,9 @@ public class SampleSessionMongoApplicationTests {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Container
|
||||
static MongoDBContainer mongo = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(3)
|
||||
.withStartupTimeout(Duration.ofMinutes(2));
|
||||
@@ -73,6 +77,15 @@ public class SampleSessionMongoApplicationTests {
|
||||
assertThat(sessions.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void health() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("http://localhost:" + this.port + "/actuator/health", String.class);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
assertThat(entity.getBody()).contains("maxWireVersion");
|
||||
}
|
||||
|
||||
private void createSession(URI uri) {
|
||||
RequestEntity<Object> request = getRequestEntity(uri);
|
||||
this.restTemplate.exchange(request, String.class);
|
||||
|
||||
Reference in New Issue
Block a user