Search in sources :

Example 1 with EndpointDiagnostics

use of com.couchbase.client.core.diagnostics.EndpointDiagnostics 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 2 with EndpointDiagnostics

use of com.couchbase.client.core.diagnostics.EndpointDiagnostics 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 3 with EndpointDiagnostics

use of com.couchbase.client.core.diagnostics.EndpointDiagnostics 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)

Example 4 with EndpointDiagnostics

use of com.couchbase.client.core.diagnostics.EndpointDiagnostics 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)

Aggregations

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