diff --git a/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java b/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java index e2e6f575c50..958b2c5838d 100644 --- a/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java +++ b/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java @@ -19,15 +19,18 @@ package org.elasticsearch.bwcompat; -import org.apache.lucene.index.IndexFormatTooOldException; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.node.internal.InternalNode; +import org.elasticsearch.rest.action.admin.indices.upgrade.UpgradeTest; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.rest.client.http.HttpRequestBuilder; import org.hamcrest.Matchers; import java.util.Arrays; @@ -84,10 +87,14 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp } void assertOldIndexWorks(String index) throws Exception { - loadIndex(index); + Settings settings = ImmutableSettings.builder() + .put(InternalNode.HTTP_ENABLED, true) // for _upgrade + .build(); + loadIndex(index, settings); assertBasicSearchWorks(); assertRealtimeGetWorks(); assertNewReplicasWork(); + assertUpgradeWorks(); unloadIndex(); } @@ -126,7 +133,9 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp logger.debug("Creating another node for replica " + i); internalCluster().startNode(ImmutableSettings.builder() .put("data.node", true) - .put("master.node", false).build()); + .put("master.node", false) + .put(InternalNode.HTTP_ENABLED, true) // for _upgrade + .build()); } ensureGreen("test"); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder() @@ -137,5 +146,12 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp .put("number_of_replicas", 0)) .execute().actionGet()); } + + void assertUpgradeWorks() throws Exception { + HttpRequestBuilder httpClient = httpClient(); + UpgradeTest.assertNotUpgraded(httpClient, "test"); + UpgradeTest.runUpgrade(httpClient, "test", "wait_for_completion", "true"); + UpgradeTest.assertUpgraded(httpClient, "test"); + } } diff --git a/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityTest.java b/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityTest.java index 525be1360be..14b7eb91333 100644 --- a/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityTest.java +++ b/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityTest.java @@ -81,7 +81,7 @@ public class StaticIndexBackwardCompatibilityTest extends ElasticsearchIntegrati static NodeInfo nodeInfo(final Client client) { final NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get(); final NodeInfo[] nodes = nodeInfos.getNodes(); - assertEquals(1, nodes.length); + assertTrue(nodes.length > 0); return nodes[0]; } } diff --git a/src/test/java/org/elasticsearch/rest/action/admin/indices/upgrade/UpgradeTest.java b/src/test/java/org/elasticsearch/rest/action/admin/indices/upgrade/UpgradeTest.java index 1ffbba781f8..bc32c60de46 100644 --- a/src/test/java/org/elasticsearch/rest/action/admin/indices/upgrade/UpgradeTest.java +++ b/src/test/java/org/elasticsearch/rest/action/admin/indices/upgrade/UpgradeTest.java @@ -174,7 +174,7 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest { return path; } - static void assertNotUpgraded(HttpRequestBuilder httpClient, String index) throws Exception { + public static void assertNotUpgraded(HttpRequestBuilder httpClient, String index) throws Exception { for (UpgradeStatus status : getUpgradeStatus(httpClient, upgradePath(index))) { assertTrue("index " + status.indexName + " should not be zero sized", status.totalBytes != 0); // TODO: it would be better for this to be strictly greater, but sometimes an extra flush @@ -185,7 +185,7 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest { } } - static void assertUpgraded(HttpRequestBuilder httpClient, String index) throws Exception { + public static void assertUpgraded(HttpRequestBuilder httpClient, String index) throws Exception { for (UpgradeStatus status : getUpgradeStatus(httpClient, upgradePath(index))) { assertTrue("index " + status.indexName + " should not be zero sized", status.totalBytes != 0); assertEquals("index " + status.indexName + " should be upgraded", @@ -233,7 +233,7 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest { } } - static void runUpgrade(HttpRequestBuilder httpClient, String index, String... params) throws Exception { + public static void runUpgrade(HttpRequestBuilder httpClient, String index, String... params) throws Exception { assert params.length % 2 == 0; HttpRequestBuilder builder = httpClient.method("POST").path(upgradePath(index)); for (int i = 0; i < params.length; i += 2) {