use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class RedisReactiveHealthIndicatorTests method redisIsUp.
@Test
void redisIsUp() {
Properties info = new Properties();
info.put("redis_version", "2.8.9");
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
given(redisConnection.closeLater()).willReturn(Mono.empty());
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
given(commands.info("server")).willReturn(Mono.just(info));
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails().get("version")).isEqualTo("2.8.9");
}).verifyComplete();
then(redisConnection).should().closeLater();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class SolrHealthIndicatorTests method assertHealth.
private void assertHealth(SolrHealthIndicator healthIndicator, Status expectedStatus, int expectedStatusCode, String expectedPathType) {
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(expectedStatus);
assertThat(health.getDetails().get("status")).isEqualTo(expectedStatusCode);
assertThat(health.getDetails().get("detectedPathType")).isEqualTo(expectedPathType);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class SolrHealthIndicatorTests method healthWhenSolrConnectionFailsReturnsDown.
@Test
void healthWhenSolrConnectionFailsReturnsDown() throws Exception {
SolrClient solrClient = mock(SolrClient.class);
given(solrClient.request(any(CoreAdminRequest.class), isNull())).willThrow(new IOException("Connection failed"));
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
then(solrClient).shouldHaveNoMoreInteractions();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class DiskSpaceHealthIndicatorTests method diskSpaceIsUp.
@Test
void diskSpaceIsUp() {
given(this.fileMock.exists()).willReturn(true);
long freeSpace = THRESHOLD.toBytes() + 10;
given(this.fileMock.getUsableSpace()).willReturn(freeSpace);
given(this.fileMock.getTotalSpace()).willReturn(TOTAL_SPACE.toBytes());
Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD.toBytes());
assertThat(health.getDetails().get("free")).isEqualTo(freeSpace);
assertThat(health.getDetails().get("total")).isEqualTo(TOTAL_SPACE.toBytes());
assertThat(health.getDetails().get("exists")).isEqualTo(true);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class DiskSpaceHealthIndicatorTests method diskSpaceIsDown.
@Test
void diskSpaceIsDown() {
given(this.fileMock.exists()).willReturn(true);
long freeSpace = THRESHOLD.toBytes() - 10;
given(this.fileMock.getUsableSpace()).willReturn(freeSpace);
given(this.fileMock.getTotalSpace()).willReturn(TOTAL_SPACE.toBytes());
Health health = this.healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD.toBytes());
assertThat(health.getDetails().get("free")).isEqualTo(freeSpace);
assertThat(health.getDetails().get("total")).isEqualTo(TOTAL_SPACE.toBytes());
assertThat(health.getDetails().get("exists")).isEqualTo(true);
}
Aggregations