use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class HazelcastHealthContributorAutoConfigurationIntegrationTests method hazelcastDown.
@Test
void hazelcastDown() {
this.contextRunner.run((context) -> {
context.getBean(HazelcastInstance.class).shutdown();
assertThat(context).hasSingleBean(HazelcastHealthIndicator.class);
Health health = context.getBean(HazelcastHealthIndicator.class).health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
});
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class HealthEndpointAutoConfigurationTests method runCreatesReactiveHealthEndpointWebExtension.
@Test
void runCreatesReactiveHealthEndpointWebExtension() {
this.reactiveContextRunner.run((context) -> {
ReactiveHealthEndpointWebExtension webExtension = context.getBean(ReactiveHealthEndpointWebExtension.class);
Mono<WebEndpointResponse<? extends HealthComponent>> response = webExtension.health(ApiVersion.V3, WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
Health health = (Health) (response.block().getBody());
assertThat(health.getDetails()).containsEntry("counter", 42);
});
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithNodeVersionShouldAddVersionDetail.
@Test
void healthWithNodeVersionShouldAddVersionDetail() {
CqlSession session = mock(CqlSession.class);
Metadata metadata = mock(Metadata.class);
given(session.getMetadata()).willReturn(metadata);
Node node = mock(Node.class);
given(node.getState()).willReturn(NodeState.UP);
given(node.getCassandraVersion()).willReturn(Version.V4_0_0);
given(metadata.getNodes()).willReturn(createNodesWithRandomUUID(Collections.singletonList(node)));
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
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(Version.V4_0_0);
}).verifyComplete();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithoutNodeVersionShouldNotAddVersionDetail.
@Test
void healthWithoutNodeVersionShouldNotAddVersionDetail() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails().get("version")).isNull();
}).verifyComplete();
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverReactiveHealthIndicatorTests method healthWithOneHealthyNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverReactiveHealthIndicator healthIndicator = new CassandraDriverReactiveHealthIndicator(session);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP)).verifyComplete();
}
Aggregations