Search in sources :

Example 36 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.

the class CassandraStorageTest method check_failsInsteadOfThrowing.

@Test
public void check_failsInsteadOfThrowing() {
    CheckResult result = CassandraStorage.newBuilder().contactPoints("1.1.1.1").build().check();
    assertThat(result.ok()).isFalse();
    assertThat(result.error()).isInstanceOf(AllNodesFailedException.class);
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 37 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.

the class ElasticsearchStorage method ensureIndexTemplatesAndClusterReady.

/**
 * This allows the health check to display problems, such as access, installing the index
 * template. It also helps reduce traffic sent to nodes still initializing (when guarded on the
 * check result). Finally, this reads the cluster health of the index as it can go down after the
 * one-time initialization passes.
 */
CheckResult ensureIndexTemplatesAndClusterReady(String index) {
    try {
        // ensure the version is available (even if we already cached it)
        version();
        // called only once, so we have to double-check health
        ensureIndexTemplates();
        AggregatedHttpRequest request = AggregatedHttpRequest.of(GET, "/_cluster/health/" + index);
        CheckResult result = http().newCall(request, READ_STATUS, "get-cluster-health").execute();
        if (result == null)
            throw new IllegalArgumentException("No content reading cluster health");
        return result;
    } catch (Throwable e) {
        Call.propagateIfFatal(e);
        // Unwrap any IOException from the first call to ensureIndexTemplates()
        if (e instanceof RejectedExecutionException || e instanceof UncheckedIOException) {
            e = e.getCause();
        }
        return CheckResult.failed(e);
    }
}
Also used : CheckResult(zipkin2.CheckResult) UncheckedIOException(java.io.UncheckedIOException) AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 38 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.

the class MySQLStorageTest method check_failsInsteadOfThrowing.

@Test
public void check_failsInsteadOfThrowing() throws SQLException {
    DataSource dataSource = mock(DataSource.class);
    when(dataSource.getConnection()).thenThrow(new SQLException("foo"));
    CheckResult result = storage(dataSource).check();
    assertThat(result.ok()).isFalse();
    assertThat(result.error()).isInstanceOf(SQLException.class);
}
Also used : SQLException(java.sql.SQLException) CheckResult(zipkin2.CheckResult) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 39 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.

the class ElasticsearchStorageTest method check_unauthorized.

// TODO: when Armeria's mock server supports it, add a test for IOException
@Test
void check_unauthorized() {
    server.enqueue(RESPONSE_UNAUTHORIZED);
    CheckResult result = storage.check();
    assertThat(result.ok()).isFalse();
    assertThat(result.error().getMessage()).isEqualTo("User: anonymous is not authorized to perform: es:ESHttpGet");
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.jupiter.api.Test)

Example 40 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.

the class ElasticsearchStorageTest method check_fail_onNoContent.

// makes sure we don't NPE
@Test
void check_fail_onNoContent() {
    // assume index templates called before
    storage.ensuredTemplates = true;
    // empty instead of success response
    server.enqueue(SUCCESS_RESPONSE);
    CheckResult result = storage.check();
    assertThat(result.ok()).isFalse();
    assertThat(result.error().getMessage()).isEqualTo("No content reading Elasticsearch version");
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.jupiter.api.Test)

Aggregations

CheckResult (zipkin2.CheckResult)30 Test (org.junit.Test)24 CheckResult (com.sequenceiq.cloudbreak.core.flow2.CheckResult)12 Test (org.junit.jupiter.api.Test)7 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)5 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Package (com.sequenceiq.cloudbreak.service.cluster.Package)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)4 Bean (org.springframework.context.annotation.Bean)3 Span (zipkin2.Span)3 ArmeriaStatusException (com.linecorp.armeria.common.grpc.protocol.ArmeriaStatusException)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Future (java.util.concurrent.Future)2