소스 검색

test: Port the remaining old indices search tests to full cluster restart qa module

Also tweaked the qa module's gradle file to actually run bwc tests against all index compat versions.

Relates to #24939
Martijn van Groningen 8 년 전
부모
커밋
bcaa413b0b

+ 0 - 184
core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java

@@ -19,45 +19,23 @@
 
 package org.elasticsearch.bwcompat;
 
-import org.apache.lucene.search.Explanation;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 import org.elasticsearch.Version;
 import org.elasticsearch.VersionTests;
-import org.elasticsearch.action.get.GetResponse;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
-import org.elasticsearch.client.Requests;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.metadata.MetaData;
-import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.io.FileSystemUtils;
 import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.common.xcontent.XContentHelper;
 import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.env.Environment;
-import org.elasticsearch.env.NodeEnvironment;
 import org.elasticsearch.gateway.MetaDataStateFormat;
-import org.elasticsearch.index.IndexSettings;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.node.Node;
 import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.SearchHitField;
-import org.elasticsearch.search.SearchHits;
-import org.elasticsearch.search.aggregations.AggregationBuilders;
-import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
-import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.InternalSettingsPlugin;
 import org.elasticsearch.test.OldIndexUtils;
 import org.elasticsearch.test.VersionUtils;
-import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.Before;
 
@@ -70,16 +48,10 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery;
-import static org.elasticsearch.test.OldIndexUtils.assertUpgradeWorks;
 import static org.elasticsearch.test.OldIndexUtils.getIndexDir;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 
 // needs at least 2 nodes since it bumps replicas to 1
 @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
@@ -120,59 +92,6 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase {
         return OldIndexUtils.getSettings();
     }
 
-    void setupCluster() throws Exception {
-        List<String> replicas = internalCluster().startNodes(1); // for replicas
-
-        Path baseTempDir = createTempDir();
-        // start single data path node
-        Settings.Builder nodeSettings = Settings.builder()
-                .put(Environment.PATH_DATA_SETTING.getKey(), baseTempDir.resolve("single-path").toAbsolutePath())
-                .put(Node.NODE_MASTER_SETTING.getKey(), false); // workaround for dangling index loading issue when node is master
-        singleDataPathNodeName = internalCluster().startNode(nodeSettings);
-
-        // start multi data path node
-        nodeSettings = Settings.builder()
-                .put(Environment.PATH_DATA_SETTING.getKey(), baseTempDir.resolve("multi-path1").toAbsolutePath() + "," + baseTempDir
-                        .resolve("multi-path2").toAbsolutePath())
-                .put(Node.NODE_MASTER_SETTING.getKey(), false); // workaround for dangling index loading issue when node is master
-        multiDataPathNodeName = internalCluster().startNode(nodeSettings);
-
-        // find single data path dir
-        Path[] nodePaths = internalCluster().getInstance(NodeEnvironment.class, singleDataPathNodeName).nodeDataPaths();
-        assertEquals(1, nodePaths.length);
-        singleDataPath = nodePaths[0].resolve(NodeEnvironment.INDICES_FOLDER);
-        assertFalse(Files.exists(singleDataPath));
-        Files.createDirectories(singleDataPath);
-        logger.info("--> Single data path: {}", singleDataPath);
-
-        // find multi data path dirs
-        nodePaths = internalCluster().getInstance(NodeEnvironment.class, multiDataPathNodeName).nodeDataPaths();
-        assertEquals(2, nodePaths.length);
-        multiDataPath = new Path[]{nodePaths[0].resolve(NodeEnvironment.INDICES_FOLDER),
-                nodePaths[1].resolve(NodeEnvironment.INDICES_FOLDER)};
-        assertFalse(Files.exists(multiDataPath[0]));
-        assertFalse(Files.exists(multiDataPath[1]));
-        Files.createDirectories(multiDataPath[0]);
-        Files.createDirectories(multiDataPath[1]);
-        logger.info("--> Multi data paths: {}, {}", multiDataPath[0], multiDataPath[1]);
-        ensureGreen();
-    }
-
-    void upgradeIndexFolder() throws Exception {
-        OldIndexUtils.upgradeIndexFolder(internalCluster(), singleDataPathNodeName);
-        OldIndexUtils.upgradeIndexFolder(internalCluster(), multiDataPathNodeName);
-    }
-
-    void importIndex(String indexName) throws IOException {
-        // force reloading dangling indices with a cluster state republish
-        client().admin().cluster().prepareReroute().get();
-        ensureGreen(indexName);
-    }
-
-    void unloadIndex(String indexName) throws Exception {
-        assertAcked(client().admin().indices().prepareDelete(indexName).get());
-    }
-
     public void testAllVersionsTested() throws Exception {
         SortedSet<String> expectedVersions = new TreeSet<>();
         for (Version v : VersionUtils.allReleasedVersions()) {
@@ -198,115 +117,12 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase {
         }
     }
 
-    public void testOldIndexes() throws Exception {
-        setupCluster();
-
-        Collections.shuffle(indexes, random());
-        for (String index : indexes) {
-            long startTime = System.currentTimeMillis();
-            logger.info("--> Testing old index {}", index);
-            assertOldIndexWorks(index);
-            logger.info("--> Done testing {}, took {} seconds", index, (System.currentTimeMillis() - startTime) / 1000.0);
-        }
-    }
-
-    void assertOldIndexWorks(String index) throws Exception {
-        Version version = OldIndexUtils.extractVersion(index);
-        Path[] paths;
-        if (randomBoolean()) {
-            logger.info("--> injecting index [{}] into single data path", index);
-            paths = new Path[]{singleDataPath};
-        } else {
-            logger.info("--> injecting index [{}] into multi data path", index);
-            paths = multiDataPath;
-        }
-
-        String indexName = index.replace(".zip", "").toLowerCase(Locale.ROOT).replace("unsupported-", "index-");
-        OldIndexUtils.loadIndex(indexName, index, createTempDir(), getBwcIndicesPath(), logger, paths);
-        // we explicitly upgrade the index folders as these indices
-        // are imported as dangling indices and not available on
-        // node startup
-        upgradeIndexFolder();
-        importIndex(indexName);
-        assertUpgradeWorks(client(), indexName, version);
-        assertPositionIncrementGapDefaults(indexName, version);
-        assertAliasWithBadName(indexName, version);
-        assertStoredBinaryFields(indexName, version);
-        unloadIndex(indexName);
-    }
-
-    void assertPositionIncrementGapDefaults(String indexName, Version version) throws Exception {
-        client().prepareIndex(indexName, "doc", "position_gap_test").setSource("string", Arrays.asList("one", "two three"))
-            .setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
-
-        // Baseline - phrase query finds matches in the same field value
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "two three")).get(), 1);
-
-        // No match across gaps when slop < position gap
-        assertHitCount(
-                client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(99)).get(),
-                0);
-
-        // Match across gaps when slop >= position gap
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(100)).get(), 1);
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(101)).get(),
-                1);
-
-        // No match across gap using default slop with default positionIncrementGap
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two")).get(), 0);
-
-        // Nor with small-ish values
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(5)).get(), 0);
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(50)).get(), 0);
-
-        // But huge-ish values still match
-        assertHitCount(client().prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(500)).get(), 1);
-    }
-
     private static final Version VERSION_5_1_0_UNRELEASED = Version.fromString("5.1.0");
 
     public void testUnreleasedVersion() {
         VersionTests.assertUnknownVersion(VERSION_5_1_0_UNRELEASED);
     }
 
-    /**
-     * Search on an alias that contains illegal characters that would prevent it from being created after 5.1.0. It should still be
-     * search-able though.
-     */
-    void assertAliasWithBadName(String indexName, Version version) throws Exception {
-        if (version.onOrAfter(VERSION_5_1_0_UNRELEASED)) {
-            return;
-        }
-        // We can read from the alias just like we can read from the index.
-        String aliasName = "#" + indexName;
-        long totalDocs = client().prepareSearch(indexName).setSize(0).get().getHits().getTotalHits();
-        assertHitCount(client().prepareSearch(aliasName).setSize(0).get(), totalDocs);
-        assertThat(totalDocs, greaterThanOrEqualTo(2000L));
-
-        // We can remove the alias.
-        assertAcked(client().admin().indices().prepareAliases().removeAlias(indexName, aliasName).get());
-        assertFalse(client().admin().indices().prepareAliasesExist(aliasName).get().exists());
-    }
-
-    /**
-     * Make sure we can load stored binary fields.
-     */
-    void assertStoredBinaryFields(String indexName, Version version) throws Exception {
-        SearchRequestBuilder builder = client().prepareSearch(indexName);
-        builder.setQuery(QueryBuilders.matchAllQuery());
-        builder.setSize(100);
-        builder.addStoredField("binary");
-        SearchHits hits = builder.get().getHits();
-        assertEquals(100, hits.getHits().length);
-        for(SearchHit hit : hits) {
-            SearchHitField field = hit.field("binary");
-            assertNotNull(field);
-            Object value = field.getValue();
-            assertTrue(value instanceof BytesArray);
-            assertEquals(16, ((BytesArray) value).length());
-        }
-    }
-
     private Path getNodeDir(String indexFile) throws IOException {
         Path unzipDir = createTempDir();
         Path unzipDataDir = unzipDir.resolve("data");

+ 1 - 1
qa/full-cluster-restart/build.gradle

@@ -79,7 +79,7 @@ for (Version version : indexCompatVersions) {
     dependsOn = [upgradedClusterTest]
   }
 
-  if (project.bwc_tests_enabled == false) {
+  if (project.bwc_tests_enabled) {
     bwcTest.dependsOn(versionBwcTest)
   }
 }

+ 162 - 7
qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

@@ -34,6 +34,7 @@ import org.elasticsearch.test.rest.ESRestTestCase;
 import org.junit.Before;
 
 import java.io.IOException;
+import java.util.Base64;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -47,7 +48,7 @@ import static java.util.Collections.singletonList;
 import static java.util.Collections.singletonMap;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.greaterThan;
 
 /**
  * Tests to run before and after a full cluster restart. This is run twice,
@@ -60,6 +61,7 @@ public class FullClusterRestartIT extends ESRestTestCase {
     private final boolean runningAgainstOldCluster = Booleans.parseBoolean(System.getProperty("tests.is_old_cluster"));
     private final Version oldClusterVersion = Version.fromString(System.getProperty("tests.old_cluster_version"));
     private final boolean supportsLenientBooleans = oldClusterVersion.onOrAfter(Version.V_6_0_0_alpha1);
+    private static final Version VERSION_5_1_0_UNRELEASED = Version.fromString("5.1.0");
 
     private String index;
 
@@ -108,6 +110,12 @@ public class FullClusterRestartIT extends ESRestTestCase {
                     mappingsAndSettings.field("type", "text");
                     mappingsAndSettings.endObject();
                 }
+                {
+                    mappingsAndSettings.startObject("binary");
+                    mappingsAndSettings.field("type", "binary");
+                    mappingsAndSettings.field("store", "true");
+                    mappingsAndSettings.endObject();
+                }
                 mappingsAndSettings.endObject();
                 mappingsAndSettings.endObject();
                 mappingsAndSettings.endObject();
@@ -117,6 +125,8 @@ public class FullClusterRestartIT extends ESRestTestCase {
                 new StringEntity(mappingsAndSettings.string(), ContentType.APPLICATION_JSON));
 
             count = randomIntBetween(2000, 3000);
+            byte[] randomByteArray = new byte[16];
+            random().nextBytes(randomByteArray);
             indexRandomDocuments(count, true, true, i -> {
                 return JsonXContent.contentBuilder().startObject()
                 .field("string", randomAlphaOfLength(10))
@@ -125,7 +135,7 @@ public class FullClusterRestartIT extends ESRestTestCase {
                 // be sure to create a "proper" boolean (True, False) for the first document so that automapping is correct
                 .field("bool", i > 0 && supportsLenientBooleans ? randomLenientBoolean() : randomBoolean())
                 .field("field.with.dots", randomAlphaOfLength(10))
-                // TODO a binary field
+                .field("binary", Base64.getEncoder().encodeToString(randomByteArray))
                 .endObject();
             });
             refresh();
@@ -134,8 +144,10 @@ public class FullClusterRestartIT extends ESRestTestCase {
         }
         assertBasicSearchWorks(count);
         assertAllSearchWorks(count);
-        assertBasicAggregationWorks(count);
-        assertRealtimeGetWorks(count);
+        assertBasicAggregationWorks();
+        assertRealtimeGetWorks();
+        assertUpgradeWorks();
+        assertStoredBinaryFields(count);
     }
 
     public void testNewReplicasWork() throws Exception {
@@ -209,6 +221,75 @@ public class FullClusterRestartIT extends ESRestTestCase {
         }
     }
 
+    /**
+     * Search on an alias that contains illegal characters that would prevent it from being created after 5.1.0. It should still be
+     * search-able though.
+     */
+    public void testAliasWithBadName() throws Exception {
+        assumeTrue("Can only test bad alias name if old cluster is on 5.1.0 or before",
+            oldClusterVersion.before(VERSION_5_1_0_UNRELEASED));
+
+        int count;
+        if (runningAgainstOldCluster) {
+            XContentBuilder mappingsAndSettings = jsonBuilder();
+            mappingsAndSettings.startObject();
+            {
+                mappingsAndSettings.startObject("settings");
+                mappingsAndSettings.field("number_of_shards", 1);
+                mappingsAndSettings.field("number_of_replicas", 0);
+                mappingsAndSettings.endObject();
+            }
+            {
+                mappingsAndSettings.startObject("mappings");
+                mappingsAndSettings.startObject("doc");
+                mappingsAndSettings.startObject("properties");
+                {
+                    mappingsAndSettings.startObject("key");
+                    mappingsAndSettings.field("type", "keyword");
+                    mappingsAndSettings.endObject();
+                }
+                mappingsAndSettings.endObject();
+                mappingsAndSettings.endObject();
+                mappingsAndSettings.endObject();
+            }
+            mappingsAndSettings.endObject();
+            client().performRequest("PUT", "/" + index, Collections.emptyMap(),
+                new StringEntity(mappingsAndSettings.string(), ContentType.APPLICATION_JSON));
+
+            String aliasName = "%23" + index; // %23 == #
+            client().performRequest("PUT", "/" + index + "/_alias/" + aliasName);
+            Response response = client().performRequest("HEAD", "/" + index + "/_alias/" + aliasName);
+            assertEquals(200, response.getStatusLine().getStatusCode());
+
+            count = randomIntBetween(32, 128);
+            indexRandomDocuments(count, true, true, i -> {
+                return JsonXContent.contentBuilder().startObject()
+                    .field("key", "value")
+                    .endObject();
+            });
+            refresh();
+        } else {
+            count = countOfIndexedRandomDocuments();
+        }
+
+        logger.error("clusterState=" + toMap(client().performRequest("GET", "/_cluster/state",
+            Collections.singletonMap("metric", "metadata"))));
+        // We can read from the alias just like we can read from the index.
+        String aliasName = "%23" + index; // %23 == #
+        Map<String, Object> searchRsp = toMap(client().performRequest("GET", "/" + aliasName + "/_search"));
+        int totalHits = (int) XContentMapValues.extractValue("hits.total", searchRsp);
+        assertEquals(count, totalHits);
+        if (runningAgainstOldCluster == false) {
+            // We can remove the alias.
+            Response response = client().performRequest("DELETE", "/" + index + "/_alias/" + aliasName);
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            // and check that it is gone:
+            response = client().performRequest("HEAD", "/" + index + "/_alias/" + aliasName);
+            assertEquals(404, response.getStatusLine().getStatusCode());
+        }
+    }
+
+
     void assertBasicSearchWorks(int count) throws IOException {
         logger.info("--> testing basic search");
         Map<String, Object> response = toMap(client().performRequest("GET", "/" + index + "/_search"));
@@ -268,7 +349,7 @@ public class FullClusterRestartIT extends ESRestTestCase {
         assertEquals(count, totalHits);
     }
 
-    void assertBasicAggregationWorks(int count) throws IOException {
+    void assertBasicAggregationWorks() throws IOException {
         // histogram on a long
         String requestBody = "{ \"aggs\": { \"histo\" : {\"histogram\" : {\"field\": \"int\", \"interval\": 10}} }}";
         Map<?, ?> searchRsp = toMap(client().performRequest("GET", "/" + index + "/_search", Collections.emptyMap(),
@@ -297,7 +378,7 @@ public class FullClusterRestartIT extends ESRestTestCase {
         assertEquals(totalHits, totalCount);
     }
 
-    void assertRealtimeGetWorks(int count) throws IOException {
+    void assertRealtimeGetWorks() throws IOException {
         String requestBody = "{ \"index\": { \"refresh_interval\" : -1 }}";
         Response response = client().performRequest("PUT", "/" + index + "/_settings", Collections.emptyMap(),
                 new StringEntity(requestBody, ContentType.APPLICATION_JSON));
@@ -324,6 +405,74 @@ public class FullClusterRestartIT extends ESRestTestCase {
         assertEquals(200, response.getStatusLine().getStatusCode());
     }
 
+    void assertUpgradeWorks() throws Exception {
+        if (runningAgainstOldCluster) {
+            Map<String, Object> rsp = toMap(client().performRequest("GET", "/_upgrade"));
+            Map<?, ?> indexUpgradeStatus = (Map<?, ?>) XContentMapValues.extractValue("indices." + index, rsp);
+            int totalBytes = (Integer) indexUpgradeStatus.get("size_in_bytes");
+            assertThat(totalBytes, greaterThan(0));
+            int toUpgradeBytes = (Integer) indexUpgradeStatus.get("size_to_upgrade_in_bytes");
+            assertEquals(0, toUpgradeBytes);
+        } else {
+            // Pre upgrade checks:
+            Map<String, Object> rsp = toMap(client().performRequest("GET", "/_upgrade"));
+            Map<?, ?> indexUpgradeStatus = (Map<?, ?>) XContentMapValues.extractValue("indices." + index, rsp);
+            int totalBytes = (Integer) indexUpgradeStatus.get("size_in_bytes");
+            assertThat(totalBytes, greaterThan(0));
+            int toUpgradeBytes = (Integer) indexUpgradeStatus.get("size_to_upgrade_in_bytes");
+            assertThat(toUpgradeBytes, greaterThan(0));
+
+            // Upgrade segments:
+            Response r = client().performRequest("POST", "/" + index + "/_upgrade");
+            assertEquals(200, r.getStatusLine().getStatusCode());
+
+            // Post upgrade checks:
+            rsp = toMap(client().performRequest("GET", "/" + index + "/_upgrade"));
+            indexUpgradeStatus = (Map<?, ?>) XContentMapValues.extractValue("indices." + index, rsp);
+            totalBytes = (Integer) indexUpgradeStatus.get("size_in_bytes");
+            assertThat(totalBytes, greaterThan(0));
+            toUpgradeBytes = (Integer) indexUpgradeStatus.get("size_to_upgrade_in_bytes");
+            assertEquals(0, toUpgradeBytes);
+
+            rsp = toMap(client().performRequest("GET", "/" + index + "/_segments"));
+            Map<?, ?> shards = (Map<?, ?>) XContentMapValues.extractValue("indices." + index + ".shards", rsp);
+            for (Object shard : shards.values()) {
+                List<?> shardSegments = (List<?>) shard;
+                for (Object shardSegment : shardSegments) {
+                    Map<?, ?> shardSegmentRsp = (Map<?, ?>) shardSegment;
+                    Map<?, ?> segments = (Map<?, ?>) shardSegmentRsp.get("segments");
+                    for (Object segment : segments.values()) {
+                        Map<?, ?> segmentRsp = (Map<?, ?>) segment;
+                        org.apache.lucene.util.Version luceneVersion =
+                            org.apache.lucene.util.Version.parse((String) segmentRsp.get("version"));
+                        assertEquals("Un-upgraded segment " + segment, Version.CURRENT.luceneVersion.major, luceneVersion.major);
+                        assertEquals("Un-upgraded segment " + segment, Version.CURRENT.luceneVersion.minor, luceneVersion.minor);
+                        assertEquals("Un-upgraded segment " + segment, Version.CURRENT.luceneVersion.bugfix, luceneVersion.bugfix);
+                    }
+                }
+            }
+        }
+    }
+
+    void assertStoredBinaryFields(int count) throws Exception {
+        String requestBody = "{ \"query\": { \"match_all\" : {} }, \"size\": 100, \"stored_fields\": \"binary\"}";
+        Map<String, Object> rsp = toMap(client().performRequest("GET", "/" + index + "/_search",
+            Collections.emptyMap(), new StringEntity(requestBody, ContentType.APPLICATION_JSON)));
+
+        int totalCount = (Integer) XContentMapValues.extractValue("hits.total", rsp);
+        assertEquals(count, totalCount);
+        List<?> hits = (List<?>) XContentMapValues.extractValue("hits.hits", rsp);
+        assertEquals(100, hits.size());
+        for (Object hit : hits) {
+            Map<?, ?> hitRsp = (Map<?, ?>) hit;
+            List<?> values = (List<?>) XContentMapValues.extractValue("fields.binary", hitRsp);
+            assertEquals(1, values.size());
+            String value = (String) values.get(0);
+            byte[] binaryValue = Base64.getDecoder().decode(value);
+            assertEquals("Unexpected string length [" + value + "]", 16, binaryValue.length);
+        }
+    }
+
     static Map<String, Object> toMap(Response response) throws IOException {
         return toMap(EntityUtils.toString(response.getEntity()));
     }
@@ -490,7 +639,13 @@ public class FullClusterRestartIT extends ESRestTestCase {
         }
 
         // Check the metadata, especially the version
-        String response = toStr(client().performRequest("GET", "/_snapshot/repo/_all", singletonMap("verbose", "true")));
+        Map<String, String> params;
+        if (oldClusterVersion.onOrAfter(Version.V_5_5_0)) {
+            params = singletonMap("verbose", "true");
+        } else {
+            params = Collections.emptyMap();
+        }
+        String response = toStr(client().performRequest("GET", "/_snapshot/repo/_all", params));
         Map<String, Object> map = toMap(response);
         assertEquals(response, singletonList("snap"), XContentMapValues.extractValue("snapshots.snapshot", map));
         assertEquals(response, singletonList("SUCCESS"), XContentMapValues.extractValue("snapshots.state", map));

+ 0 - 81
test/framework/src/main/java/org/elasticsearch/test/OldIndexUtils.java

@@ -23,23 +23,14 @@ import org.apache.logging.log4j.Logger;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.util.TestUtil;
 import org.elasticsearch.Version;
-import org.elasticsearch.action.admin.indices.segments.IndexSegments;
-import org.elasticsearch.action.admin.indices.segments.IndexShardSegments;
-import org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse;
-import org.elasticsearch.action.admin.indices.segments.ShardSegments;
-import org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus;
-import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
 import org.elasticsearch.common.io.FileSystemUtils;
-import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.IndexFolderUpgrader;
 import org.elasticsearch.common.xcontent.NamedXContentRegistry;
 import org.elasticsearch.env.NodeEnvironment;
 import org.elasticsearch.index.MergePolicyConfig;
-import org.elasticsearch.index.engine.Segment;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,17 +41,14 @@ import java.nio.file.Path;
 import java.nio.file.SimpleFileVisitor;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
 import static junit.framework.TestCase.assertFalse;
 import static junit.framework.TestCase.assertTrue;
 import static org.elasticsearch.test.ESTestCase.randomInt;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 
@@ -141,24 +129,6 @@ public class OldIndexUtils {
         }
     }
 
-    public static void assertNotUpgraded(Client client, String... index) throws Exception {
-        for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
-            assertTrue("index " + status.getIndex() + " should not be zero sized", status.getTotalBytes() != 0);
-            // TODO: it would be better for this to be strictly greater, but sometimes an extra flush
-            // mysteriously happens after the second round of docs are indexed
-            assertTrue("index " + status.getIndex() + " should have recovered some segments from transaction log",
-                status.getTotalBytes() >= status.getToUpgradeBytes());
-            assertTrue("index " + status.getIndex() + " should need upgrading", status.getToUpgradeBytes() != 0);
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    public static Collection<IndexUpgradeStatus> getUpgradeStatus(Client client, String... indices) throws Exception {
-        UpgradeStatusResponse upgradeStatusResponse = client.admin().indices().prepareUpgradeStatus(indices).get();
-        assertNoFailures(upgradeStatusResponse);
-        return upgradeStatusResponse.getIndices().values();
-    }
-
     // randomly distribute the files from src over dests paths
     public static void copyIndex(final Logger logger, final Path src, final String folderName, final Path... dests) throws IOException {
         Path destinationDataPath = dests[randomInt(dests.length - 1)];
@@ -197,58 +167,7 @@ public class OldIndexUtils {
         });
     }
 
-    public static void assertUpgraded(Client client, String... index) throws Exception {
-        for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
-            assertTrue("index " + status.getIndex() + " should not be zero sized", status.getTotalBytes() != 0);
-            assertEquals("index " + status.getIndex() + " should be upgraded",
-                0, status.getToUpgradeBytes());
-        }
-
-        // double check using the segments api that all segments are actually upgraded
-        IndicesSegmentResponse segsRsp;
-        if (index == null) {
-            segsRsp = client.admin().indices().prepareSegments().execute().actionGet();
-        } else {
-            segsRsp = client.admin().indices().prepareSegments(index).execute().actionGet();
-        }
-        for (IndexSegments indexSegments : segsRsp.getIndices().values()) {
-            for (IndexShardSegments shard : indexSegments) {
-                for (ShardSegments segs : shard.getShards()) {
-                    for (Segment seg : segs.getSegments()) {
-                        assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(),
-                            Version.CURRENT.luceneVersion.major, seg.version.major);
-                        assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(),
-                            Version.CURRENT.luceneVersion.minor, seg.version.minor);
-                    }
-                }
-            }
-        }
-    }
-
-    public static boolean isUpgraded(Client client, String index) throws Exception {
-        Logger logger = Loggers.getLogger(OldIndexUtils.class);
-        int toUpgrade = 0;
-        for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
-            logger.info("Index: {}, total: {}, toUpgrade: {}", status.getIndex(), status.getTotalBytes(), status.getToUpgradeBytes());
-            toUpgrade += status.getToUpgradeBytes();
-        }
-        return toUpgrade == 0;
-    }
-
-    public static void assertUpgradeWorks(Client client, String indexName, Version version) throws Exception {
-        if (OldIndexUtils.isLatestLuceneVersion(version) == false) {
-            OldIndexUtils.assertNotUpgraded(client, indexName);
-        }
-        assertNoFailures(client.admin().indices().prepareUpgrade(indexName).get());
-        assertUpgraded(client, indexName);
-    }
-
     public static Version extractVersion(String index) {
         return Version.fromString(index.substring(index.indexOf('-') + 1, index.lastIndexOf('.')));
     }
-
-    public static boolean isLatestLuceneVersion(Version version) {
-        return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
-            version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
-    }
 }