You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zipkin.apache.org by ad...@apache.org on 2019/05/06 14:51:19 UTC

[incubator-zipkin] branch verify-es5-unittests created (now b41931a)

This is an automated email from the ASF dual-hosted git repository.

adriancole pushed a change to branch verify-es5-unittests
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git.


      at b41931a  Verified ES 5.x with unit tests as opposed to integration tests

This branch includes the following new commits:

     new b41931a  Verified ES 5.x with unit tests as opposed to integration tests

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-zipkin] 01/01: Verified ES 5.x with unit tests as opposed to integration tests

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adriancole pushed a commit to branch verify-es5-unittests
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git

commit b41931a927b800dc76726219389ffcf2dc692217
Author: Adrian Cole <ac...@pivotal.io>
AuthorDate: Mon May 6 22:48:04 2019 +0800

    Verified ES 5.x with unit tests as opposed to integration tests
    
    Our builds currently take too long due in part to checking 3 different
    versions of Elasticsearch. Elastic no longer supports version 5, so our
    support of it is "best efforts". Accordingly, integration testing v5.x
    knowing we break the build on timeouts is not the best call.
    
    This increases the unit test coverage of version specific code to 100%
    and removes the Elasticsearch 5.x integration tests.
---
 .../elasticsearch/VersionSpecificTemplates.java    |  71 ++----
 .../VersionSpecificTemplatesTest.java              | 255 +++++++++++----------
 .../integration/ITElasticsearchStorageV5.java      | 164 -------------
 3 files changed, 148 insertions(+), 342 deletions(-)

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 6f82980..1db7eeb 100644
--- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java
+++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java
@@ -18,7 +18,6 @@ package zipkin2.elasticsearch;
 
 import com.squareup.moshi.JsonReader;
 import java.io.IOException;
-import java.util.logging.Logger;
 import okhttp3.Request;
 import okio.BufferedSource;
 import zipkin2.elasticsearch.internal.client.HttpCall;
@@ -30,7 +29,6 @@ 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;
@@ -60,7 +58,7 @@ final class VersionSpecificTemplates {
   String spanIndexTemplate() {
     String result =
       "{\n"
-        + "  \"TEMPLATE\": \"${__INDEX__}:span-*\",\n"
+        + "  \"index_patterns\": \"${__INDEX__}:span-*\",\n"
         + "  \"settings\": {\n"
         + "    \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n"
         + "    \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n"
@@ -142,7 +140,7 @@ final class VersionSpecificTemplates {
   /** Templatized due to version differences. Only fields used in search are declared */
   static final String DEPENDENCY_INDEX_TEMPLATE =
     "{\n"
-      + "  \"TEMPLATE\": \"${__INDEX__}:dependency-*\",\n"
+      + "  \"index_patterns\": \"${__INDEX__}:dependency-*\",\n"
       + "  \"settings\": {\n"
       + "    \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n"
       + "    \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n"
@@ -156,7 +154,7 @@ final class VersionSpecificTemplates {
   // BodyConverters KEY
   static final String AUTOCOMPLETE_INDEX_TEMPLATE =
     "{\n"
-      + "  \"TEMPLATE\": \"${__INDEX__}:autocomplete-*\",\n"
+      + "  \"index_patterns\": \"${__INDEX__}:autocomplete-*\",\n"
       + "  \"settings\": {\n"
       + "    \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n"
       + "    \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n"
@@ -174,11 +172,15 @@ final class VersionSpecificTemplates {
 
   IndexTemplates get(HttpCall.Factory callFactory) throws IOException {
     float version = getVersion(callFactory);
+    if (version < 5.0f || version >= 8.0f) {
+      throw new IllegalArgumentException(
+        "Elasticsearch versions 5-7.x are supported, was: " + version);
+    }
     return IndexTemplates.newBuilder()
       .version(version)
-      .span(versionSpecificSpanIndexTemplate(version))
-      .dependency(versionSpecificDependencyLinkIndexTemplate(version))
-      .autocomplete(versionSpecificAutocompleteIndexTemplate(version))
+      .span(versionSpecificIndexTemplate(SPAN, spanIndexTemplate, version))
+      .dependency(versionSpecificIndexTemplate(DEPENDENCY, dependencyIndexTemplate, version))
+      .autocomplete(versionSpecificIndexTemplate(AUTOCOMPLETE, autocompleteIndexTemplate, version))
       .build();
   }
 
@@ -194,54 +196,19 @@ final class VersionSpecificTemplates {
       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 < 5) {
-        LOG.warning("Please upgrade to Elasticsearch 5 or later. version=" + versionString);
-      }
-      return result;
-    }
-
-    @Override public String toString() {
-      return "GetVersion";
+      return Float.valueOf(versionString.substring(0, 3));
     }
-  }
-
-  private String versionSpecificSpanIndexTemplate(float version) {
-    String result;
-    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 5-7.x are supported, was: " + version);
-    }
-    return maybeReviseFor7x(SPAN, version, result);
-  }
-
-  private String versionSpecificDependencyLinkIndexTemplate(float version) {
-    String result = dependencyIndexTemplate.replace(
-      "TEMPLATE", version >= 6 ? "index_patterns" : "template");
-    return maybeReviseFor7x(DEPENDENCY, version, result);
-  }
-
-  private String versionSpecificAutocompleteIndexTemplate(float version) {
-    String result;
-    if (version >= 5) {
-      result = autocompleteIndexTemplate
-        .replace("TEMPLATE", version >= 6 ? "index_patterns" : "template");
-    } else {
-      throw new IllegalStateException("Elasticsearch 5-7.x are supported, was: " + version);
-    }
-    return maybeReviseFor7x(AUTOCOMPLETE, version, result);
-  }
+}
 
-  private String maybeReviseFor7x(String type, float version, String result) {
-    if (version < 7) return result;
+  static String versionSpecificIndexTemplate(String type, String template, float version) {
+    if (version < 6.0f) return template.replace("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
+    if (version < 7.0f) return template;
     // Colons are no longer allowed in index names. Make sure the pattern in our index template
     // doesn't use them either.
-    result = result.replaceAll(":" + type, "-" + type);
-    result = result.replaceAll(",\n +\"index\\.mapper\\.dynamic\": false", "");
-    return result;
+    template = template.replaceAll(":" + type, "-" + type);
+    return template.replaceAll(",\n +\"index\\.mapper\\.dynamic\": false", "");
   }
 }
 
diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/VersionSpecificTemplatesTest.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/VersionSpecificTemplatesTest.java
index d747ffa..c09be6f 100644
--- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/VersionSpecificTemplatesTest.java
+++ b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/VersionSpecificTemplatesTest.java
@@ -10,7 +10,7 @@
  *
  * 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.
+ * WITHOUT WARRANTIvOR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
@@ -27,148 +27,151 @@ import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class VersionSpecificTemplatesTest {
+  static final MockResponse VERSION_RESPONSE_7 = new MockResponse().setBody(""
+    + "{\n"
+    + "  \"name\" : \"zipkin-elasticsearch\",\n"
+    + "  \"cluster_name\" : \"docker-cluster\",\n"
+    + "  \"cluster_uuid\" : \"wByRPgSgTryYl0TZXW4MsA\",\n"
+    + "  \"version\" : {\n"
+    + "    \"number\" : \"7.0.1\",\n"
+    + "    \"build_flavor\" : \"default\",\n"
+    + "    \"build_type\" : \"tar\",\n"
+    + "    \"build_hash\" : \"e4efcb5\",\n"
+    + "    \"build_date\" : \"2019-04-29T12:56:03.145736Z\",\n"
+    + "    \"build_snapshot\" : false,\n"
+    + "    \"lucene_version\" : \"8.0.0\",\n"
+    + "    \"minimum_wire_compatibility_version\" : \"6.7.0\",\n"
+    + "    \"minimum_index_compatibility_version\" : \"6.0.0-beta1\"\n"
+    + "  },\n"
+    + "  \"tagline\" : \"You Know, for Search\"\n"
+    + "}");
+  static final MockResponse VERSION_RESPONSE_6 = new MockResponse().setBody(""
+    + "{\n"
+    + "  \"name\" : \"PV-NhJd\",\n"
+    + "  \"cluster_name\" : \"CollectorDBCluster\",\n"
+    + "  \"cluster_uuid\" : \"UjZaM0fQRC6tkHINCg9y8w\",\n"
+    + "  \"version\" : {\n"
+    + "    \"number\" : \"6.7.0\",\n"
+    + "    \"build_flavor\" : \"oss\",\n"
+    + "    \"build_type\" : \"tar\",\n"
+    + "    \"build_hash\" : \"8453f77\",\n"
+    + "    \"build_date\" : \"2019-03-21T15:32:29.844721Z\",\n"
+    + "    \"build_snapshot\" : false,\n"
+    + "    \"lucene_version\" : \"7.7.0\",\n"
+    + "    \"minimum_wire_compatibility_version\" : \"5.6.0\",\n"
+    + "    \"minimum_index_compatibility_version\" : \"5.0.0\"\n"
+    + "  },\n"
+    + "  \"tagline\" : \"You Know, for Search\"\n"
+    + "}");
+  static final MockResponse VERSION_RESPONSE_5 = new MockResponse().setBody(""
+    + "{\n"
+    + "  \"name\" : \"vU0g1--\",\n"
+    + "  \"cluster_name\" : \"elasticsearch\",\n"
+    + "  \"cluster_uuid\" : \"Fnm277ITSNyzsy0UCVFN7g\",\n"
+    + "  \"version\" : {\n"
+    + "    \"number\" : \"5.0.0\",\n"
+    + "    \"build_hash\" : \"253032b\",\n"
+    + "    \"build_date\" : \"2016-10-26T04:37:51.531Z\",\n"
+    + "    \"build_snapshot\" : false,\n"
+    + "    \"lucene_version\" : \"6.2.0\"\n"
+    + "  },\n"
+    + "  \"tagline\" : \"You Know, for Search\"\n"
+    + "}");
+  static final MockResponse VERSION_RESPONSE_2 = new MockResponse().setBody(""
+    + "{\n"
+    + "  \"name\" : \"Kamal\",\n"
+    + "  \"cluster_name\" : \"elasticsearch\",\n"
+    + "  \"version\" : {\n"
+    + "    \"number\" : \"2.4.0\",\n"
+    + "    \"build_hash\" : \"ce9f0c7394dee074091dd1bc4e9469251181fc55\",\n"
+    + "    \"build_timestamp\" : \"2016-08-29T09:14:17Z\",\n"
+    + "    \"build_snapshot\" : false,\n"
+    + "    \"lucene_version\" : \"5.5.2\"\n"
+    + "  },\n"
+    + "  \"tagline\" : \"You Know, for Search\"\n"
+    + "}");
+
   @Rule public ExpectedException thrown = ExpectedException.none();
   @Rule public MockWebServer es = new MockWebServer();
 
   ElasticsearchStorage storage =
-      ElasticsearchStorage.newBuilder().hosts(asList(es.url("").toString())).build();
+    ElasticsearchStorage.newBuilder().hosts(asList(es.url("").toString())).build();
 
-  @After
-  public void close() {
+  @After public void close() {
     storage.close();
   }
 
   /** Unsupported, but we should test that parsing works */
-  @Test
-  public void getVersion_1() throws Exception {
-    es.enqueue(
-        new MockResponse()
-            .setBody(
-                "{\n"
-                    + "  \"status\" : 200,\n"
-                    + "  \"name\" : \"Shen Kuei\",\n"
-                    + "  \"cluster_name\" : \"elasticsearch\",\n"
-                    + "  \"version\" : {\n"
-                    + "    \"number\" : \"1.7.3\",\n"
-                    + "    \"build_hash\" : \"05d4530971ef0ea46d0f4fa6ee64dbc8df659682\",\n"
-                    + "    \"build_timestamp\" : \"2015-10-15T09:14:17Z\",\n"
-                    + "    \"build_snapshot\" : false,\n"
-                    + "    \"lucene_version\" : \"4.10.4\"\n"
-                    + "  },\n"
-                    + "  \"tagline\" : \"You Know, for Search\"\n"
-                    + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(1.7f);
-  }
+  @Test public void version2_unsupported() throws Exception {
+    es.enqueue(VERSION_RESPONSE_2);
+
+    thrown.expectMessage("Elasticsearch versions 5-7.x are supported, was: 2.4");
 
-  @Test
-  public void getVersion_2() throws Exception {
-    es.enqueue(
-        new MockResponse()
-            .setBody(
-                "{\n"
-                    + "  \"name\" : \"Kamal\",\n"
-                    + "  \"cluster_name\" : \"elasticsearch\",\n"
-                    + "  \"version\" : {\n"
-                    + "    \"number\" : \"2.4.0\",\n"
-                    + "    \"build_hash\" : \"ce9f0c7394dee074091dd1bc4e9469251181fc55\",\n"
-                    + "    \"build_timestamp\" : \"2016-08-29T09:14:17Z\",\n"
-                    + "    \"build_snapshot\" : false,\n"
-                    + "    \"lucene_version\" : \"5.5.2\"\n"
-                    + "  },\n"
-                    + "  \"tagline\" : \"You Know, for Search\"\n"
-                    + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(2.4f);
+    new VersionSpecificTemplates(storage).get(storage.http());
   }
 
-  @Test
-  public void getVersion_5() throws Exception {
-    es.enqueue(
-        new MockResponse()
-            .setBody(
-                "{\n"
-                    + "  \"name\" : \"vU0g1--\",\n"
-                    + "  \"cluster_name\" : \"elasticsearch\",\n"
-                    + "  \"cluster_uuid\" : \"Fnm277ITSNyzsy0UCVFN7g\",\n"
-                    + "  \"version\" : {\n"
-                    + "    \"number\" : \"5.0.0\",\n"
-                    + "    \"build_hash\" : \"253032b\",\n"
-                    + "    \"build_date\" : \"2016-10-26T04:37:51.531Z\",\n"
-                    + "    \"build_snapshot\" : false,\n"
-                    + "    \"lucene_version\" : \"6.2.0\"\n"
-                    + "  },\n"
-                    + "  \"tagline\" : \"You Know, for Search\"\n"
-                    + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(5.0f);
+  @Test public void version5() throws Exception {
+    es.enqueue(VERSION_RESPONSE_5);
+
+    IndexTemplates template = new VersionSpecificTemplates(storage).get(storage.http());
+
+    assertThat(template.version()).isEqualTo(5.0f);
+    assertThat(template.autocomplete())
+      .withFailMessage("In v5.x, the index_patterns field was named template")
+      .contains("\"template\":");
+    assertThat(template.autocomplete())
+      .withFailMessage("Until v7.x, we delimited index and type with a colon")
+      .contains("\"template\": \"zipkin:autocomplete-*\"");
+    assertThat(template.autocomplete())
+      .contains("\"index.mapper.dynamic\": false");
   }
 
-  @Test
-  public void getVersion_6() throws Exception {
-    es.enqueue(
-        new MockResponse()
-            .setBody(
-                "{\n"
-                    + "  \"name\" : \"gZlGcWF\",\n"
-                    + "  \"cluster_name\" : \"elasticsearch\",\n"
-                    + "  \"cluster_uuid\" : \"QAiO5laPRquRvL8BzjDgYQ\",\n"
-                    + "  \"version\" : {\n"
-                    + "    \"number\" : \"6.0.0-alpha2\",\n"
-                    + "    \"build_hash\" : \"0424099\",\n"
-                    + "    \"build_date\" : \"2017-05-31T23:38:55.271Z\",\n"
-                    + "    \"build_snapshot\" : false,\n"
-                    + "    \"lucene_version\" : \"7.0.0\"\n"
-                    + "  },\n"
-                    + "  \"tagline\" : \"You Know, for Search\"\n"
-                    + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(6.0f);
+  @Test public void version6() throws Exception {
+    es.enqueue(VERSION_RESPONSE_6);
+
+    IndexTemplates template = new VersionSpecificTemplates(storage).get(storage.http());
+
+    assertThat(template.version()).isEqualTo(6.7f);
+    assertThat(template.autocomplete())
+      .withFailMessage("Until v7.x, we delimited index and type with a colon")
+      .contains("\"index_patterns\": \"zipkin:autocomplete-*\"");
+    assertThat(template.autocomplete())
+      .contains("\"index.mapper.dynamic\": false");
   }
 
-  @Test public void getVersion_6_7() throws Exception {
-    es.enqueue(new MockResponse().setBody(
-      "{\n"
-        + "  \"name\" : \"PV-NhJd\",\n"
-        + "  \"cluster_name\" : \"CollectorDBCluster\",\n"
-        + "  \"cluster_uuid\" : \"UjZaM0fQRC6tkHINCg9y8w\",\n"
-        + "  \"version\" : {\n"
-        + "    \"number\" : \"6.7.0\",\n"
-        + "    \"build_flavor\" : \"oss\",\n"
-        + "    \"build_type\" : \"tar\",\n"
-        + "    \"build_hash\" : \"8453f77\",\n"
-        + "    \"build_date\" : \"2019-03-21T15:32:29.844721Z\",\n"
-        + "    \"build_snapshot\" : false,\n"
-        + "    \"lucene_version\" : \"7.7.0\",\n"
-        + "    \"minimum_wire_compatibility_version\" : \"5.6.0\",\n"
-        + "    \"minimum_index_compatibility_version\" : \"5.0.0\"\n"
-        + "  },\n"
-        + "  \"tagline\" : \"You Know, for Search\"\n"
-        + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(6.7f);
+  @Test public void version7() throws Exception {
+    es.enqueue(VERSION_RESPONSE_7);
+
+    IndexTemplates template = new VersionSpecificTemplates(storage).get(storage.http());
+
+    assertThat(template.version()).isEqualTo(7.0f);
+    assertThat(template.autocomplete())
+      .withFailMessage("Starting at v7.x, we delimit index and type with hyphen")
+      .contains("\"index_patterns\": \"zipkin-autocomplete-*\"");
+    assertThat(template.autocomplete())
+      .withFailMessage("7.x does not support the key index.mapper.dynamic")
+      .doesNotContain("\"index.mapper.dynamic\": false");
   }
 
-  @Test public void getVersion_7() throws Exception {
-    es.enqueue(new MockResponse().setBody(
-      "{\n"
-        + "  \"name\" : \"zipkin-elasticsearch\",\n"
-        + "  \"cluster_name\" : \"docker-cluster\",\n"
-        + "  \"cluster_uuid\" : \"wByRPgSgTryYl0TZXW4MsA\",\n"
-        + "  \"version\" : {\n"
-        + "    \"number\" : \"7.0.1\",\n"
-        + "    \"build_flavor\" : \"default\",\n"
-        + "    \"build_type\" : \"tar\",\n"
-        + "    \"build_hash\" : \"e4efcb5\",\n"
-        + "    \"build_date\" : \"2019-04-29T12:56:03.145736Z\",\n"
-        + "    \"build_snapshot\" : false,\n"
-        + "    \"lucene_version\" : \"8.0.0\",\n"
-        + "    \"minimum_wire_compatibility_version\" : \"6.7.0\",\n"
-        + "    \"minimum_index_compatibility_version\" : \"6.0.0-beta1\"\n"
-        + "  },\n"
-        + "  \"tagline\" : \"You Know, for Search\"\n"
-        + "}"));
-
-    assertThat(VersionSpecificTemplates.getVersion(storage.http())).isEqualTo(7.0f);
+  @Test public void searchEnabled_minimalSpanIndexing() throws Exception {
+    storage = ElasticsearchStorage.newBuilder().hosts(storage.hostsSupplier().get())
+      .searchEnabled(false)
+      .build();
+
+    es.enqueue(VERSION_RESPONSE_6);
+
+    IndexTemplates template = new VersionSpecificTemplates(storage).get(storage.http());
+
+    assertThat(template.span())
+      .contains(""
+        + "  \"mappings\": {\n"
+        + "    \"span\": {\n"
+        + "      \"properties\": {\n"
+        + "        \"traceId\": { \"type\": \"keyword\", \"norms\": false },\n"
+        + "        \"annotations\": { \"enabled\": false },\n"
+        + "        \"tags\": { \"enabled\": false }\n"
+        + "      }\n"
+        + "    }\n"
+        + "  }");
   }
 }
diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV5.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV5.java
deleted file mode 100644
index b0fc548..0000000
--- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/integration/ITElasticsearchStorageV5.java
+++ /dev/null
@@ -1,164 +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 ITElasticsearchStorageV5 {
-
-  static ElasticsearchStorageRule classRule() {
-    return new ElasticsearchStorageRule("openzipkin/zipkin-elasticsearch5: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<Span> spans) throws Exception {
-      aggregateLinks(spans).forEach(
-        (midnight, links) -> InternalForTests.writeDependencyLinks(storage, links, midnight));
-    }
-
-    @Before @Override public void clear() throws IOException {
-      storage.clear();
-    }
-  }
-}