Search in sources :

Example 6 with DiagnosticsResult

use of com.couchbase.client.core.diagnostics.DiagnosticsResult in project spring-boot by spring-projects.

the class CouchbaseReactiveHealthIndicatorTests method couchbaseClusterIsDown.

@Test
@SuppressWarnings("unchecked")
void couchbaseClusterIsDown() {
    Cluster cluster = mock(Cluster.class);
    CouchbaseReactiveHealthIndicator healthIndicator = new CouchbaseReactiveHealthIndicator(cluster);
    Map<ServiceType, List<EndpointDiagnostics>> endpoints = Collections.singletonMap(ServiceType.KV, Arrays.asList(new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTED, "127.0.0.1", "127.0.0.1", Optional.empty(), Optional.of(1234L), Optional.of("endpoint-1")), new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTING, "127.0.0.1", "127.0.0.1", Optional.empty(), Optional.of(1234L), Optional.of("endpoint-2"))));
    DiagnosticsResult diagnostics = new DiagnosticsResult(endpoints, "test-sdk", "test-id");
    given(cluster.diagnostics()).willReturn(diagnostics);
    Health health = healthIndicator.health().block(Duration.ofSeconds(30));
    assertThat(health.getStatus()).isEqualTo(Status.DOWN);
    assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
    assertThat(health.getDetails()).containsKey("endpoints");
    assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(2);
    then(cluster).should().diagnostics();
}
Also used : EndpointDiagnostics(com.couchbase.client.core.diagnostics.EndpointDiagnostics) Health(org.springframework.boot.actuate.health.Health) ServiceType(com.couchbase.client.core.service.ServiceType) DiagnosticsResult(com.couchbase.client.core.diagnostics.DiagnosticsResult) Cluster(com.couchbase.client.java.Cluster) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 7 with DiagnosticsResult

use of com.couchbase.client.core.diagnostics.DiagnosticsResult in project spring-boot by spring-projects.

the class CouchbaseReactiveHealthIndicator method doHealthCheck.

@Override
protected Mono<Health> doHealthCheck(Health.Builder builder) {
    DiagnosticsResult diagnostics = this.cluster.diagnostics();
    new CouchbaseHealth(diagnostics).applyTo(builder);
    return Mono.just(builder.build());
}
Also used : DiagnosticsResult(com.couchbase.client.core.diagnostics.DiagnosticsResult)

Aggregations

DiagnosticsResult (com.couchbase.client.core.diagnostics.DiagnosticsResult)7 Cluster (com.couchbase.client.java.Cluster)5 Test (org.junit.jupiter.api.Test)5 EndpointDiagnostics (com.couchbase.client.core.diagnostics.EndpointDiagnostics)4 ServiceType (com.couchbase.client.core.service.ServiceType)4 List (java.util.List)4 Health (org.springframework.boot.actuate.health.Health)4 Bucket (com.couchbase.client.java.Bucket)1