From commits-return-813-archive-asf-public=cust-asf.ponee.io@zipkin.apache.org Mon May 6 13:18:34 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1CD52180763 for ; Mon, 6 May 2019 15:18:34 +0200 (CEST) Received: (qmail 37413 invoked by uid 500); 6 May 2019 13:18:33 -0000 Mailing-List: contact commits-help@zipkin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zipkin.apache.org Delivered-To: mailing list commits@zipkin.apache.org Received: (qmail 37387 invoked by uid 99); 6 May 2019 13:18:33 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 May 2019 13:18:33 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 054E18725B; Mon, 6 May 2019 13:18:33 +0000 (UTC) Date: Mon, 06 May 2019 13:18:33 +0000 To: "commits@zipkin.apache.org" Subject: [incubator-zipkin] 01/04: Removes support for Elasticsearch 2.x MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: adriancole@apache.org In-Reply-To: <155714871271.13701.10933197559988421335@gitbox.apache.org> References: <155714871271.13701.10933197559988421335@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-zipkin X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 097fc9d392e470bd2288ced071280ba83bb0d885 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190506131833.054E18725B@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. adriancole pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git commit 097fc9d392e470bd2288ced071280ba83bb0d885 Author: Adrian Cole AuthorDate: Mon May 6 13:22:58 2019 +0800 Removes support for Elasticsearch 2.x As discussed, this removes support for Elasticsearch 2.x See https://lists.apache.org/thread.html/ac01ebd12b6ecaac6496e146570652a3e804d45d9b9d2100001f5c75@%3Cdev.zipkin.apache.org%3E --- zipkin-server/README.md | 5 +- zipkin-storage/elasticsearch/README.md | 7 +- .../elasticsearch/ElasticsearchStorage.java | 1 - .../elasticsearch/VersionSpecificTemplates.java | 276 +++++++++------------ .../elasticsearch/ElasticsearchStorageTest.java | 2 +- .../integration/ITElasticsearchStorageV2.java | 163 ------------ .../integration/ITElasticsearchStorageV7.java | 19 ++ 7 files changed, 144 insertions(+), 329 deletions(-) diff --git a/zipkin-server/README.md b/zipkin-server/README.md index 0a79549..7832c84 100644 --- a/zipkin-server/README.md +++ b/zipkin-server/README.md @@ -183,14 +183,13 @@ $ STORAGE_TYPE=cassandra3 java -jar zipkin.jar --logging.level.zipkin=trace --lo ### Elasticsearch Storage Zipkin's [Elasticsearch storage component](../zipkin-storage/elasticsearch) -supports versions 2-6.x and applies when `STORAGE_TYPE` is set to `elasticsearch` +supports versions 5-7.x and applies when `STORAGE_TYPE` is set to `elasticsearch` The following apply when `STORAGE_TYPE` is set to `elasticsearch`: * `ES_HOSTS`: A comma separated list of elasticsearch base urls to connect to ex. http://host:9200. Defaults to "http://localhost:9200". - * `ES_PIPELINE`: Only valid when the destination is Elasticsearch 5+. Indicates the ingest - pipeline used before spans are indexed. No default. + * `ES_PIPELINE`: Indicates the ingest pipeline used before spans are indexed. No default. * `ES_TIMEOUT`: Controls the connect, read and write socket timeouts (in milliseconds) for Elasticsearch Api. Defaults to 10000 (10 seconds) * `ES_MAX_REQUESTS`: Only valid when the transport is http. Sets maximum in-flight requests from diff --git a/zipkin-storage/elasticsearch/README.md b/zipkin-storage/elasticsearch/README.md index a3ee202..f5b5e7b 100644 --- a/zipkin-storage/elasticsearch/README.md +++ b/zipkin-storage/elasticsearch/README.md @@ -2,8 +2,8 @@ This is is a plugin to the Elasticsearch storage component, which uses HTTP by way of [OkHttp 3](https://github.com/square/okttp) and -[Moshi](https://github.com/square/moshi). This currently supports 2.x, -5.x, 6.x and 7.x version families. +[Moshi](https://github.com/square/moshi). This currently supports 5.x, +6.x and 7.x version families. ## Multiple hosts Most users will supply a DNS name that's mapped to multiple A or AAAA @@ -123,8 +123,7 @@ be written, nor analyzed. ## Customizing the ingest pipeline -When using Elasticsearch 5.x, you can setup an [ingest pipeline](https://www.elastic.co/guide/en/elasticsearch/reference/master/pipeline.html) -to perform custom processing. +You can setup an [ingest pipeline](https://www.elastic.co/guide/en/elasticsearch/reference/master/pipeline.html) to perform custom processing. Here's an example, which you'd setup prior to configuring Zipkin to use it via `ElasticsearchStorage.Builder.pipeline` diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java index a19541f..1d12681 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java @@ -293,7 +293,6 @@ public abstract class ElasticsearchStorage extends zipkin2.storage.StorageCompon void clear(String index) throws IOException { HttpUrl.Builder url = http().baseUrl.newBuilder().addPathSegment(index); - //if (version() >= 6.0 ) url.addQueryParameter("refresh", "wait_for"); Request delete = new Request.Builder().url(url.build()).delete().tag("delete-index").build(); http().newCall(delete, BodyConverters.NULL).execute(); } diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java index b48a9a1..6f82980 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java @@ -31,6 +31,7 @@ import static zipkin2.elasticsearch.internal.JsonReaders.enterPath; /** Returns a version-specific span and dependency index template */ final class VersionSpecificTemplates { static final Logger LOG = Logger.getLogger(VersionSpecificTemplates.class.getName()); + static final String KEYWORD = "{ \"type\": \"keyword\", \"norms\": false }"; final boolean searchEnabled; final String spanIndexTemplate; @@ -39,21 +40,16 @@ final class VersionSpecificTemplates { VersionSpecificTemplates(ElasticsearchStorage es) { this.searchEnabled = es.searchEnabled(); - this.spanIndexTemplate = - spanIndexTemplate() - .replace("${__INDEX__}", es.indexNameFormatter().index()) - .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) - .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())) - .replace( - "${__TRACE_ID_MAPPING__}", - es.strictTraceId() - ? "{ KEYWORD }" - : "{ \"type\": \"STRING\", \"analyzer\": \"traceId_analyzer\" }"); - this.dependencyIndexTemplate = - DEPENDENCY_INDEX_TEMPLATE - .replace("${__INDEX__}", es.indexNameFormatter().index()) - .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) - .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())); + this.spanIndexTemplate = spanIndexTemplate() + .replace("${__INDEX__}", es.indexNameFormatter().index()) + .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) + .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())) + .replace("${__TRACE_ID_MAPPING__}", es.strictTraceId() ? KEYWORD + : "{ \"type\": \"text\", \"fielddata\": \"true\", \"analyzer\": \"traceId_analyzer\" }"); + this.dependencyIndexTemplate = DEPENDENCY_INDEX_TEMPLATE + .replace("${__INDEX__}", es.indexNameFormatter().index()) + .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) + .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())); this.autocompleteIndexTemplate = AUTOCOMPLETE_INDEX_TEMPLATE .replace("${__INDEX__}", es.indexNameFormatter().index()) .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) @@ -63,138 +59,127 @@ final class VersionSpecificTemplates { /** Templatized due to version differences. Only fields used in search are declared */ String spanIndexTemplate() { String result = - "{\n" - + " \"TEMPLATE\": \"${__INDEX__}:" - + SPAN - + "-*\",\n" - + " \"settings\": {\n" - + " \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n" - + " \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n" - + " \"index.requests.cache.enable\": true,\n" - + " \"index.mapper.dynamic\": false,\n" - + " \"analysis\": {\n" - + " \"analyzer\": {\n" - + " \"traceId_analyzer\": {\n" - + " \"type\": \"custom\",\n" - + " \"tokenizer\": \"keyword\",\n" - + " \"filter\": \"traceId_filter\"\n" - + " }\n" - + " },\n" - + " \"filter\": {\n" - + " \"traceId_filter\": {\n" - + " \"type\": \"pattern_capture\",\n" - + " \"patterns\": [\"([0-9a-f]{1,16})$\"],\n" - + " \"preserve_original\": true\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n"; + "{\n" + + " \"TEMPLATE\": \"${__INDEX__}:span-*\",\n" + + " \"settings\": {\n" + + " \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n" + + " \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n" + + " \"index.requests.cache.enable\": true,\n" + + " \"index.mapper.dynamic\": false,\n" + + " \"analysis\": {\n" + + " \"analyzer\": {\n" + + " \"traceId_analyzer\": {\n" + + " \"type\": \"custom\",\n" + + " \"tokenizer\": \"keyword\",\n" + + " \"filter\": \"traceId_filter\"\n" + + " }\n" + + " },\n" + + " \"filter\": {\n" + + " \"traceId_filter\": {\n" + + " \"type\": \"pattern_capture\",\n" + + " \"patterns\": [\"([0-9a-f]{1,16})$\"],\n" + + " \"preserve_original\": true\n" + + " }\n" + + " }\n" + + " }\n" + + " },\n"; if (searchEnabled) { return result - + (" \"mappings\": {\nDISABLE_ALL" - + " \"" - + SPAN - + "\": {\n" - + " \"_source\": {\"excludes\": [\"_q\"] },\n" - + " \"dynamic_templates\": [\n" - + " {\n" - + " \"strings\": {\n" - + " \"mapping\": {\n" - + " KEYWORD,\n" - + " \"ignore_above\": 256\n" - + " },\n" - + " \"match_mapping_type\": \"string\",\n" - + " \"match\": \"*\"\n" - + " }\n" - + " }\n" - + " ],\n" - + " \"properties\": {\n" - + " \"traceId\": ${__TRACE_ID_MAPPING__},\n" - + " \"name\": { KEYWORD },\n" - + " \"localEndpoint\": {\n" - + " \"type\": \"object\",\n" - + " \"dynamic\": false,\n" - + " \"properties\": { \"serviceName\": { KEYWORD } }\n" - + " },\n" - + " \"remoteEndpoint\": {\n" - + " \"type\": \"object\",\n" - + " \"dynamic\": false,\n" - + " \"properties\": { \"serviceName\": { KEYWORD } }\n" - + " },\n" - + " \"timestamp_millis\": {\n" - + " \"type\": \"date\",\n" - + " \"format\": \"epoch_millis\"\n" - + " },\n" - + " \"duration\": { \"type\": \"long\" },\n" - + " \"annotations\": { \"enabled\": false },\n" - + " \"tags\": { \"enabled\": false },\n" - + " \"_q\": { KEYWORD }\n" - + " }\n" - + " }\n" - + " }\n" - + "}"); + + (" \"mappings\": {\n" + + " \"span\": {\n" + + " \"_source\": {\"excludes\": [\"_q\"] },\n" + + " \"dynamic_templates\": [\n" + + " {\n" + + " \"strings\": {\n" + + " \"mapping\": {\n" + + " \"type\": \"keyword\",\"norms\": false\n,\n" + + " \"ignore_above\": 256\n" + + " },\n" + + " \"match_mapping_type\": \"string\",\n" + + " \"match\": \"*\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"properties\": {\n" + + " \"traceId\": ${__TRACE_ID_MAPPING__},\n" + + " \"name\": " + KEYWORD + ",\n" + + " \"localEndpoint\": {\n" + + " \"type\": \"object\",\n" + + " \"dynamic\": false,\n" + + " \"properties\": { \"serviceName\": " + KEYWORD + " }\n" + + " },\n" + + " \"remoteEndpoint\": {\n" + + " \"type\": \"object\",\n" + + " \"dynamic\": false,\n" + + " \"properties\": { \"serviceName\": " + KEYWORD + " }\n" + + " },\n" + + " \"timestamp_millis\": {\n" + + " \"type\": \"date\",\n" + + " \"format\": \"epoch_millis\"\n" + + " },\n" + + " \"duration\": { \"type\": \"long\" },\n" + + " \"annotations\": { \"enabled\": false },\n" + + " \"tags\": { \"enabled\": false },\n" + + " \"_q\": " + KEYWORD + "\n" + + " }\n" + + " }\n" + + " }\n" + + "}"); } return result - + (" \"mappings\": {\nDISABLE_ALL" - + " \"" - + SPAN - + "\": {\n" - + " \"properties\": {\n" - + " \"traceId\": ${__TRACE_ID_MAPPING__},\n" - + " \"annotations\": { \"enabled\": false },\n" - + " \"tags\": { \"enabled\": false }\n" - + " }\n" - + " }\n" - + " }\n" - + "}"); + + (" \"mappings\": {\n" + + " \"span\": {\n" + + " \"properties\": {\n" + + " \"traceId\": ${__TRACE_ID_MAPPING__},\n" + + " \"annotations\": { \"enabled\": false },\n" + + " \"tags\": { \"enabled\": false }\n" + + " }\n" + + " }\n" + + " }\n" + + "}"); } /** Templatized due to version differences. Only fields used in search are declared */ static final String DEPENDENCY_INDEX_TEMPLATE = - "{\n" - + " \"TEMPLATE\": \"${__INDEX__}:" - + DEPENDENCY - + "-*\",\n" - + " \"settings\": {\n" - + " \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n" - + " \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n" - + " \"index.requests.cache.enable\": true,\n" - + " \"index.mapper.dynamic\": false\n" - + " },\n" - + " \"mappings\": {\"" - + DEPENDENCY - + "\": { \"enabled\": false }}\n" - + "}"; + "{\n" + + " \"TEMPLATE\": \"${__INDEX__}:dependency-*\",\n" + + " \"settings\": {\n" + + " \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n" + + " \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n" + + " \"index.requests.cache.enable\": true,\n" + + " \"index.mapper.dynamic\": false\n" + + " },\n" + + " \"mappings\": {\"dependency\": { \"enabled\": false }}\n" + + "}"; // The key filed of a autocompleteKeys is intentionally names as tagKey since it clashes with the // BodyConverters KEY static final String AUTOCOMPLETE_INDEX_TEMPLATE = "{\n" - + " \"TEMPLATE\": \"${__INDEX__}:" - + AUTOCOMPLETE - + "-*\",\n" + + " \"TEMPLATE\": \"${__INDEX__}:autocomplete-*\",\n" + " \"settings\": {\n" + " \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n" + " \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n" + " \"index.requests.cache.enable\": true,\n" + " \"index.mapper.dynamic\": false\n" + " },\n" - + " \"mappings\": {\"" - + AUTOCOMPLETE - + "\": { \"enabled\": true,\n" + + " \"mappings\": {\n" + + " \"autocomplete\": {\n" + + " \"enabled\": true,\n" + " \"properties\": {\n" - + " \"tagKey\": { KEYWORD },\n" - + " \"tagValue\": { KEYWORD }\n" + + " \"tagKey\": " + KEYWORD + ",\n" + + " \"tagValue\": " + KEYWORD + "\n" + " }}}\n" + "}"; + IndexTemplates get(HttpCall.Factory callFactory) throws IOException { float version = getVersion(callFactory); return IndexTemplates.newBuilder() - .version(version) - .span(versionSpecificSpanIndexTemplate(version)) - .dependency(versionSpecificDependencyLinkIndexTemplate(version)) - .autocomplete(versionSpecificAutocompleteIndexTemplate(version)) - .build(); + .version(version) + .span(versionSpecificSpanIndexTemplate(version)) + .dependency(versionSpecificDependencyLinkIndexTemplate(version)) + .autocomplete(versionSpecificAutocompleteIndexTemplate(version)) + .build(); } static float getVersion(HttpCall.Factory callFactory) throws IOException { @@ -205,47 +190,30 @@ final class VersionSpecificTemplates { enum ReadVersionNumber implements HttpCall.BodyConverter { INSTANCE; - @Override - public Float convert(BufferedSource content) throws IOException { + @Override public Float convert(BufferedSource content) throws IOException { JsonReader version = enterPath(JsonReader.of(content), "version", "number"); if (version == null) throw new IllegalStateException(".version.number not in response"); String versionString = version.nextString(); float result = Float.valueOf(versionString.substring(0, 3)); - if (result < 2) { - LOG.warning("Please upgrade to Elasticsearch 2 or later. version=" + versionString); + if (result < 5) { + LOG.warning("Please upgrade to Elasticsearch 5 or later. version=" + versionString); } return result; } - @Override - public String toString() { + @Override public String toString() { return "GetVersion"; } } private String versionSpecificSpanIndexTemplate(float version) { String result; - if (version >= 2 && version < 3) { - result = spanIndexTemplate - .replace("TEMPLATE", "template") - .replace("STRING", "string") - .replace("DISABLE_ALL", "\"_default_\": { \"_all\": {\"enabled\": false} },\n") - .replace( - "KEYWORD", - "\"type\": \"string\", \"norms\": {\"enabled\": false }, \"index\": \"not_analyzed\""); - } else if (version >= 5) { - result = spanIndexTemplate - .replace("TEMPLATE", version >= 6 ? "index_patterns" : "template") - .replace("STRING", "text") - // 6.x _all disabled https://www.elastic.co/guide/en/elasticsearch/reference/6.7/breaking-changes-6.0.html#_the_literal__all_literal_meta_field_is_now_disabled_by_default - // 7.x _default disallowed https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#_the_literal__default__literal_mapping_is_no_longer_allowed - .replace("DISABLE_ALL", "") - .replace("KEYWORD", "\"type\": \"keyword\", \"norms\": false") - .replace( - "\"analyzer\": \"traceId_analyzer\" }", - "\"fielddata\": \"true\", \"analyzer\": \"traceId_analyzer\" }"); + if (version >= 5) { + result = spanIndexTemplate.replace("TEMPLATE", version >= 6 ? "index_patterns" : "template"); + // 6.x _all disabled https://www.elastic.co/guide/en/elasticsearch/reference/6.7/breaking-changes-6.0.html#_the_literal__all_literal_meta_field_is_now_disabled_by_default + // 7.x _default disallowed https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#_the_literal__default__literal_mapping_is_no_longer_allowed } else { - throw new IllegalStateException("Elasticsearch 2-7.x are supported, was: " + version); + throw new IllegalStateException("Elasticsearch 5-7.x are supported, was: " + version); } return maybeReviseFor7x(SPAN, version, result); } @@ -258,17 +226,11 @@ final class VersionSpecificTemplates { private String versionSpecificAutocompleteIndexTemplate(float version) { String result; - if (version >= 2 && version < 3) { - result = autocompleteIndexTemplate - .replace("TEMPLATE", "template") - .replace("KEYWORD", "\"type\": \"string\", \"norms\": {\"enabled\": false }, \"index\": " - + "\"not_analyzed\""); - } else if (version >= 5) { + if (version >= 5) { result = autocompleteIndexTemplate - .replace("TEMPLATE", version >= 6 ? "index_patterns" : "template") - .replace("KEYWORD", "\"type\": \"keyword\",\"norms\": false\n"); + .replace("TEMPLATE", version >= 6 ? "index_patterns" : "template"); } else { - throw new IllegalStateException("Elasticsearch 2-7.x are supported, was: " + version); + throw new IllegalStateException("Elasticsearch 5-7.x are supported, was: " + version); } return maybeReviseFor7x(AUTOCOMPLETE, version, result); } diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchStorageTest.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchStorageTest.java index 0609fe3..ff543e5 100644 --- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchStorageTest.java +++ b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchStorageTest.java @@ -43,7 +43,7 @@ public class ElasticsearchStorageTest { @Test public void memoizesIndexTemplate() throws Exception { - es.enqueue(new MockResponse().setBody("{\"version\":{\"number\":\"2.4.0\"}}")); + es.enqueue(new MockResponse().setBody("{\"version\":{\"number\":\"6.7.0\"}}")); es.enqueue(new MockResponse()); // get span template es.enqueue(new MockResponse()); // get dependency template es.enqueue(new MockResponse()); // get tags template diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV2.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV2.java deleted file mode 100644 index adc380e..0000000 --- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV2.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package zipkin2.elasticsearch.integration; - -import java.io.IOException; -import java.util.List; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import zipkin2.Span; -import zipkin2.elasticsearch.ElasticsearchStorage; -import zipkin2.elasticsearch.InternalForTests; -import zipkin2.storage.StorageComponent; - -import static zipkin2.elasticsearch.integration.ElasticsearchStorageRule.index; - -@RunWith(Enclosed.class) -public class ITElasticsearchStorageV2 { - - static ElasticsearchStorageRule classRule() { - return new ElasticsearchStorageRule("openzipkin/zipkin-elasticsearch:2.12.8", - "test_elasticsearch3"); - } - - public static class ITSpanStore extends zipkin2.storage.ITSpanStore { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - ElasticsearchStorage storage; - - @Before public void connect() { - storage = backend.computeStorageBuilder().index(index(testName)).build(); - } - - @Override protected StorageComponent storage() { - return storage; - } - - @Override @Test @Ignore("No consumer-side span deduplication") public void deduplicates() { - } - - @Before @Override public void clear() throws IOException { - storage.clear(); - } - } - - public static class ITSearchEnabledFalse extends zipkin2.storage.ITSearchEnabledFalse { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - ElasticsearchStorage storage; - - @Before public void connect() { - storage = backend.computeStorageBuilder().index(index(testName)).searchEnabled(false).build(); - } - - @Override protected StorageComponent storage() { - return storage; - } - - @Before @Override public void clear() throws IOException { - storage.clear(); - } - } - - public static class ITStrictTraceIdFalse extends zipkin2.storage.ITStrictTraceIdFalse { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - ElasticsearchStorage storage; - - @Before public void connect() { - storage = backend.computeStorageBuilder().index(index(testName)).strictTraceId(false).build(); - } - - @Override protected StorageComponent storage() { - return storage; - } - - @Before @Override public void clear() throws IOException { - storage.clear(); - } - } - - public static class ITServiceAndSpanNames extends zipkin2.storage.ITServiceAndSpanNames { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - ElasticsearchStorage storage; - - @Before public void connect() { - storage = backend.computeStorageBuilder().index(index(testName)).build(); - } - - @Override protected StorageComponent storage() { - return storage; - } - - @Before @Override public void clear() throws IOException { - storage.clear(); - } - } - - public static class ITAutocompleteTags extends zipkin2.storage.ITAutocompleteTags { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - @Override protected StorageComponent.Builder storageBuilder() { - return backend.computeStorageBuilder().index(index(testName)); - } - - @Before @Override public void clear() throws IOException { - ((ElasticsearchStorage) storage).clear(); - } - } - - public static class ITDependencies extends zipkin2.storage.ITDependencies { - @ClassRule public static ElasticsearchStorageRule backend = classRule(); - @Rule public TestName testName = new TestName(); - - ElasticsearchStorage storage; - - @Before public void connect() { - storage = backend.computeStorageBuilder().index(index(testName)).build(); - } - - @Override protected StorageComponent storage() { - return storage; - } - - /** - * The current implementation does not include dependency aggregation. It includes retrieval of - * pre-aggregated links, usually made via zipkin-dependencies - */ - @Override protected void processDependencies(List spans) throws Exception { - aggregateLinks(spans).forEach( - (midnight, links) -> InternalForTests.writeDependencyLinks(storage, links, midnight)); - } - - @Before @Override public void clear() throws IOException { - storage.clear(); - } - } -} diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV7.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV7.java index e2c37f3..c6a4367 100644 --- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV7.java +++ b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV7.java @@ -83,6 +83,25 @@ public class ITElasticsearchStorageV7 { } } + public static class ITServiceAndSpanNames extends zipkin2.storage.ITServiceAndSpanNames { + @ClassRule public static ElasticsearchStorageRule backend = classRule(); + @Rule public TestName testName = new TestName(); + + ElasticsearchStorage storage; + + @Before public void connect() { + storage = backend.computeStorageBuilder().index(index(testName)).build(); + } + + @Override protected StorageComponent storage() { + return storage; + } + + @Before @Override public void clear() throws IOException { + storage.clear(); + } + } + public static class ITAutocompleteTags extends zipkin2.storage.ITAutocompleteTags { @ClassRule public static ElasticsearchStorageRule backend = classRule(); @Rule public TestName testName = new TestName();