Search in sources :

Example 6 with CheckResult

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

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

Example 8 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ITElasticsearchHealthCheck method notHealthyThenHealthyThenNotHealthy.

@Test
public void notHealthyThenHealthyThenNotHealthy() {
    server1Health.setHealthy(false);
    server2Health.setHealthy(false);
    try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
        CheckResult result = storage.check();
        assertThat(result.ok()).isFalse();
        server2Health.setHealthy(true);
        awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isTrue());
        server2Health.setHealthy(false);
        awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isFalse());
    }
}
Also used : ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 9 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ComponentHealthTest method addsMessageToDetails.

@Test
public void addsMessageToDetails() {
    ComponentHealth health = ComponentHealth.ofComponent(new Component() {

        @Override
        public CheckResult check() {
            return CheckResult.failed(new IOException("socket disconnect"));
        }
    });
    assertThat(health.error).isEqualTo("java.io.IOException: socket disconnect");
}
Also used : CheckResult(zipkin2.CheckResult) IOException(java.io.IOException) Component(zipkin2.Component) Test(org.junit.Test)

Example 10 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ComponentHealthTest method doesntAddNullMessageToDetails.

@Test
public void doesntAddNullMessageToDetails() {
    ComponentHealth health = ComponentHealth.ofComponent(new Component() {

        @Override
        public CheckResult check() {
            return CheckResult.failed(ClosedSessionException.get());
        }
    });
    assertThat(health.error).isEqualTo("com.linecorp.armeria.common.ClosedSessionException");
}
Also used : CheckResult(zipkin2.CheckResult) Component(zipkin2.Component) 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