Search in sources :

Example 1 with DiagnosticsResult

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

the class CouchbaseHealthIndicator method doHealthCheck.

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    DiagnosticsResult diagnostics = this.cluster.diagnostics();
    new CouchbaseHealth(diagnostics).applyTo(builder);
}
Also used : DiagnosticsResult(com.couchbase.client.core.diagnostics.DiagnosticsResult)

Example 2 with DiagnosticsResult

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

the class CouchbaseAutoConfigurationIntegrationTests method defaultConfiguration.

@Test
void defaultConfiguration() {
    this.contextRunner.run((context) -> {
        assertThat(context).hasSingleBean(Cluster.class).hasSingleBean(ClusterEnvironment.class);
        Cluster cluster = context.getBean(Cluster.class);
        Bucket bucket = cluster.bucket(BUCKET_NAME);
        bucket.waitUntilReady(Duration.ofMinutes(5));
        DiagnosticsResult diagnostics = cluster.diagnostics();
        assertThat(diagnostics.state()).isEqualTo(ClusterState.ONLINE);
    });
}
Also used : Bucket(com.couchbase.client.java.Bucket) DiagnosticsResult(com.couchbase.client.core.diagnostics.DiagnosticsResult) Cluster(com.couchbase.client.java.Cluster) Test(org.junit.jupiter.api.Test)

Example 3 with DiagnosticsResult

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

the class CouchbaseHealthIndicatorTests method couchbaseClusterIsDown.

@Test
@SuppressWarnings("unchecked")
void couchbaseClusterIsDown() {
    Cluster cluster = mock(Cluster.class);
    CouchbaseHealthIndicator healthIndicator = new CouchbaseHealthIndicator(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();
    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 4 with DiagnosticsResult

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

the class CouchbaseHealthIndicatorTests method couchbaseClusterIsUp.

@Test
@SuppressWarnings("unchecked")
void couchbaseClusterIsUp() {
    Cluster cluster = mock(Cluster.class);
    CouchbaseHealthIndicator healthIndicator = new CouchbaseHealthIndicator(cluster);
    Map<ServiceType, List<EndpointDiagnostics>> endpoints = Collections.singletonMap(ServiceType.KV, Collections.singletonList(new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTED, "127.0.0.1", "127.0.0.1", Optional.empty(), Optional.of(1234L), Optional.of("endpoint-1"))));
    DiagnosticsResult diagnostics = new DiagnosticsResult(endpoints, "test-sdk", "test-id");
    given(cluster.diagnostics()).willReturn(diagnostics);
    Health health = healthIndicator.health();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
    assertThat(health.getDetails()).containsKey("endpoints");
    assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(1);
    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 5 with DiagnosticsResult

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

the class CouchbaseReactiveHealthIndicatorTests method couchbaseClusterIsUp.

@Test
@SuppressWarnings("unchecked")
void couchbaseClusterIsUp() {
    Cluster cluster = mock(Cluster.class);
    CouchbaseReactiveHealthIndicator healthIndicator = new CouchbaseReactiveHealthIndicator(cluster);
    Map<ServiceType, List<EndpointDiagnostics>> endpoints = Collections.singletonMap(ServiceType.KV, Collections.singletonList(new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTED, "127.0.0.1", "127.0.0.1", Optional.empty(), Optional.of(1234L), Optional.of("endpoint-1"))));
    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.UP);
    assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
    assertThat(health.getDetails()).containsKey("endpoints");
    assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(1);
    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)

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