Search in sources :

Example 1 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class RabbitMQCollectorTest method checkFalseWhenRabbitMQIsDown.

@Test
public void checkFalseWhenRabbitMQIsDown() {
    CheckResult check = collector.check();
    assertThat(check.ok()).isFalse();
    assertThat(check.error()).isInstanceOf(UncheckedIOException.class);
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 2 with CheckResult

use of zipkin2.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 3 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ITEnsureSchema method worksWithOldSchema.

/**
 * This tests we don't accidentally rely on new indexes such as autocomplete tags
 */
@Test
void worksWithOldSchema(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema.cql");
    Schema.applyCqlFile(storage.keyspace, session(), "/zipkin2-schema-indexes-original.cql");
    // Ensure the storage component is functional before proceeding
    CheckResult check = storage.check();
    if (!check.ok()) {
        throw new AssertionError("Could not connect to storage: " + check.error().getMessage(), check.error());
    }
    List<Span> trace = newTrace(testSuffix);
    accept(trace);
    assertGetTraceReturns(trace.get(0).traceId(), trace);
    assertThat(storage.autocompleteTags().getValues("environment").execute()).isEmpty();
    String serviceName = trace.get(0).localServiceName();
    assertThat(storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute()).isEmpty();
    QueryRequest request = requestBuilder().serviceName(serviceName).remoteServiceName(appendSuffix(BACKEND.serviceName(), testSuffix)).build();
    // Make sure there's an error if a query will return incorrectly vs returning invalid results
    assertThatThrownBy(() -> storage.spanStore().getTraces(request)).isInstanceOf(IllegalArgumentException.class).hasMessage("remoteService=" + trace.get(1).remoteServiceName() + " unsupported due to missing table remote_service_by_service");
}
Also used : QueryRequest(zipkin2.storage.QueryRequest) CheckResult(zipkin2.CheckResult) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 4 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ElasticsearchStorageTest method check_ensuresIndexTemplates_fail_onNoContent.

// makes sure we don't NPE
@Test
void check_ensuresIndexTemplates_fail_onNoContent() {
    // empty instead of version json
    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)

Example 5 with CheckResult

use of zipkin2.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)

Aggregations

CheckResult (zipkin2.CheckResult)22 Test (org.junit.Test)12 Test (org.junit.jupiter.api.Test)5 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)4 CompletableFuture (java.util.concurrent.CompletableFuture)2 Future (java.util.concurrent.Future)2 Component (zipkin2.Component)2 AggregatedHttpRequest (com.linecorp.armeria.common.AggregatedHttpRequest)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 SQLException (java.sql.SQLException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 DataSource (javax.sql.DataSource)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Span (zipkin2.Span)1 QueryRequest (zipkin2.storage.QueryRequest)1