ElasticsearchStorage extends zipkin2.storage.StorageComponent { @Override public CheckResult check() { return ensureIndexTemplatesAndClusterReady(indexNameFormatter().formatType(TYPE_SPAN)); } ElasticsearchStorage(); static Builder newBuilder(LazyHttpClient lazyHttpClient); @Nullable abstract String pipeline(); abstract boolean flushOnWrites(); abstract boolean strictTraceId(); abstract IndexNameFormatter indexNameFormatter(); abstract int namesLookback(); @Override SpanStore spanStore(); @Override Traces traces(); @Override ServiceAndSpanNames serviceAndSpanNames(); @Override AutocompleteTags autocompleteTags(); @Override SpanConsumer spanConsumer(); @Memoized float version(); void clear(); @Override boolean isOverCapacity(Throwable e); @Override CheckResult check(); @Override final String toString(); @Override void close();  }
@Test void check_ensuresIndexTemplates_memozied() { server.enqueue(RESPONSE_VERSION_6); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(HEALTH_RESPONSE); assertThat(storage.check()).isEqualTo(CheckResult.OK); server.enqueue(HEALTH_RESPONSE); assertThat(storage.check()).isEqualTo(CheckResult.OK); }
@Test void check_ensuresIndexTemplates_fail_onNoContent() { server.enqueue(SUCCESS_RESPONSE); CheckResult result = storage.check(); assertThat(result.ok()).isFalse(); assertThat(result.error().getMessage()) .isEqualTo("No content reading Elasticsearch version"); }
@Test void check_fail_onNoContent() { storage.ensuredTemplates = true; server.enqueue(SUCCESS_RESPONSE); CheckResult result = storage.check(); assertThat(result.ok()).isFalse(); assertThat(result.error().getMessage()) .isEqualTo("No content reading Elasticsearch version"); }
@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"); }
@Test void check_create_legacy_indexTemplate_resourcePath_version78() throws Exception { server.enqueue(AggregatedHttpResponse.of( HttpStatus.OK, MediaType.JSON_UTF_8, "{\"version\":{\"number\":\"7.8.0\"}}")); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); storage.check(); server.takeRequest(); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-span_template"); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-dependency_template"); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-autocomplete_template"); }
@Test void check_create_legacy_indexTemplate_resourcePath_version79() throws Exception { server.enqueue(AggregatedHttpResponse.of( HttpStatus.OK, MediaType.JSON_UTF_8, "{\"version\":{\"number\":\"7.9.0\"}}")); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); server.enqueue(SUCCESS_RESPONSE); storage.check(); server.takeRequest(); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-span_template"); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-dependency_template"); assertThat(server.takeRequest().request().path()) .startsWith("/_template/zipkin-autocomplete_template"); }