Search in sources :

Example 1 with CheckResult

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

the class MySQLExtension method beforeAll.

@Override
public void beforeAll(ExtensionContext context) throws Exception {
    if (context.getRequiredTestClass().getEnclosingClass() != null) {
        // Only run once in outermost scope.
        return;
    }
    container.start();
    LOGGER.info("Using hostPort " + host() + ":" + port());
    try (MySQLStorage result = computeStorageBuilder().build()) {
        CheckResult check = result.check();
        assumeTrue(check.ok(), () -> "Could not connect to storage, skipping test: " + check.error().getMessage());
        dropAndRecreateSchema(result.datasource);
    }
}
Also used : CheckResult(zipkin2.CheckResult)

Example 2 with CheckResult

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

the class ForwardingStorageComponentTest method delegatesCheck.

@Test
public void delegatesCheck() {
    CheckResult down = CheckResult.failed(new RuntimeException("failed"));
    when(delegate.check()).thenReturn(down);
    assertThat(forwarder.check()).isEqualTo(down);
    verify(delegate).check();
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 3 with CheckResult

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

the class ComponentHealth method ofComponent.

static ComponentHealth ofComponent(Component component) {
    Throwable t = null;
    try {
        CheckResult check = component.check();
        if (!check.ok())
            t = check.error();
    } catch (Throwable unexpected) {
        Call.propagateIfFatal(unexpected);
        t = unexpected;
    }
    if (t == null)
        return new ComponentHealth(component.toString(), STATUS_UP, null);
    String message = t.getMessage();
    String error = t.getClass().getName() + (message != null ? ": " + message : "");
    return new ComponentHealth(component.toString(), STATUS_DOWN, error);
}
Also used : CheckResult(zipkin2.CheckResult)

Example 4 with CheckResult

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

the class ITElasticsearchClientInitialization method doesntHangWhenAllDown.

/**
 * blocking a little is ok, but blocking forever is not.
 */
@Test(timeout = 3000L)
public void doesntHangWhenAllDown() throws IOException {
    TestPropertyValues.of("spring.config.name=zipkin-server", "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.timeout:1000", "zipkin.storage.elasticsearch.hosts:127.0.0.1:1234,127.0.0.1:5678").applyTo(context);
    Access.registerElasticsearch(context);
    context.refresh();
    try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
        CheckResult result = storage.check();
        assertThat(result.ok()).isFalse();
    }
}
Also used : ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 5 with CheckResult

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

the class ITElasticsearchHealthCheck method wrongScheme.

@Test
public void wrongScheme() {
    context.close();
    context = new AnnotationConfigApplicationContext();
    initWithHosts("https://localhost:" + server1.httpPort());
    try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
        CheckResult result = storage.check();
        assertThat(result.ok()).isFalse();
        // Test this is not wrapped in a rejection exception, as health check is not throttled
        // Depending on JDK this is SSLHandshakeException or NotSslRecordException
        assertThat(result.error()).isInstanceOf(SSLException.class);
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) CheckResult(zipkin2.CheckResult) Test(org.junit.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