Search in sources :

Example 1 with ElasticsearchStorage

use of zipkin2.elasticsearch.ElasticsearchStorage in project zipkin by openzipkin.

the class InternalForTests method writeDependencyLinks.

public static void writeDependencyLinks(ElasticsearchStorage es, List<DependencyLink> links, long midnightUTC) {
    String index = ((ElasticsearchSpanConsumer) es.spanConsumer()).formatTypeAndTimestampForInsert("dependency", midnightUTC);
    BulkCallBuilder indexer = new BulkCallBuilder(es, es.version(), "indexlinks");
    for (DependencyLink link : links) indexer.index(index, "dependency", link, DEPENDENCY_LINK_WRITER);
    try {
        indexer.build().execute();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : BulkCallBuilder(zipkin2.elasticsearch.internal.BulkCallBuilder) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) DependencyLink(zipkin2.DependencyLink)

Example 2 with ElasticsearchStorage

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

use of zipkin2.elasticsearch.ElasticsearchStorage 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 4 with ElasticsearchStorage

use of zipkin2.elasticsearch.ElasticsearchStorage 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 5 with ElasticsearchStorage

use of zipkin2.elasticsearch.ElasticsearchStorage in project zipkin by openzipkin.

the class ITElasticsearchHealthCheck method healthCheckDisabled.

@Test
public void healthCheckDisabled() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    TestPropertyValues.of("spring.config.name=zipkin-server", "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.ensure-templates=false", "zipkin.storage.elasticsearch.timeout=200", "zipkin.storage.elasticsearch.health-check.enabled=false", "zipkin.storage.elasticsearch.health-check.interval=100ms", "zipkin.storage.elasticsearch.hosts=127.0.0.1:" + server1.httpPort() + ",127.0.0.1:" + server2.httpPort()).applyTo(context);
    Access.registerElasticsearch(context);
    context.refresh();
    server1Health.setHealthy(false);
    server2Health.setHealthy(false);
    try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
        // Even though cluster health is false, we ignore that and continue to check index health,
        // which is correctly returned by our mock server.
        assertOk(storage.check());
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)6 CheckResult (zipkin2.CheckResult)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 DependencyLink (zipkin2.DependencyLink)1 BulkCallBuilder (zipkin2.elasticsearch.internal.BulkCallBuilder)1