Tests: Add upgrade step to static bwc tests
This commit is contained in:
parent
060f963a8e
commit
7f9ffea97c
|
@ -19,15 +19,18 @@
|
||||||
|
|
||||||
package org.elasticsearch.bwcompat;
|
package org.elasticsearch.bwcompat;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexFormatTooOldException;
|
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
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.SearchHit;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
||||||
|
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -84,10 +87,14 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertOldIndexWorks(String index) throws Exception {
|
void assertOldIndexWorks(String index) throws Exception {
|
||||||
loadIndex(index);
|
Settings settings = ImmutableSettings.builder()
|
||||||
|
.put(InternalNode.HTTP_ENABLED, true) // for _upgrade
|
||||||
|
.build();
|
||||||
|
loadIndex(index, settings);
|
||||||
assertBasicSearchWorks();
|
assertBasicSearchWorks();
|
||||||
assertRealtimeGetWorks();
|
assertRealtimeGetWorks();
|
||||||
assertNewReplicasWork();
|
assertNewReplicasWork();
|
||||||
|
assertUpgradeWorks();
|
||||||
unloadIndex();
|
unloadIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +133,9 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
||||||
logger.debug("Creating another node for replica " + i);
|
logger.debug("Creating another node for replica " + i);
|
||||||
internalCluster().startNode(ImmutableSettings.builder()
|
internalCluster().startNode(ImmutableSettings.builder()
|
||||||
.put("data.node", true)
|
.put("data.node", true)
|
||||||
.put("master.node", false).build());
|
.put("master.node", false)
|
||||||
|
.put(InternalNode.HTTP_ENABLED, true) // for _upgrade
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
ensureGreen("test");
|
ensureGreen("test");
|
||||||
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
|
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
|
||||||
|
@ -138,4 +147,11 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
||||||
.execute().actionGet());
|
.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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class StaticIndexBackwardCompatibilityTest extends ElasticsearchIntegrati
|
||||||
static NodeInfo nodeInfo(final Client client) {
|
static NodeInfo nodeInfo(final Client client) {
|
||||||
final NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get();
|
final NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get();
|
||||||
final NodeInfo[] nodes = nodeInfos.getNodes();
|
final NodeInfo[] nodes = nodeInfos.getNodes();
|
||||||
assertEquals(1, nodes.length);
|
assertTrue(nodes.length > 0);
|
||||||
return nodes[0];
|
return nodes[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest {
|
||||||
return path;
|
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))) {
|
for (UpgradeStatus status : getUpgradeStatus(httpClient, upgradePath(index))) {
|
||||||
assertTrue("index " + status.indexName + " should not be zero sized", status.totalBytes != 0);
|
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
|
// 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))) {
|
for (UpgradeStatus status : getUpgradeStatus(httpClient, upgradePath(index))) {
|
||||||
assertTrue("index " + status.indexName + " should not be zero sized", status.totalBytes != 0);
|
assertTrue("index " + status.indexName + " should not be zero sized", status.totalBytes != 0);
|
||||||
assertEquals("index " + status.indexName + " should be upgraded",
|
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;
|
assert params.length % 2 == 0;
|
||||||
HttpRequestBuilder builder = httpClient.method("POST").path(upgradePath(index));
|
HttpRequestBuilder builder = httpClient.method("POST").path(upgradePath(index));
|
||||||
for (int i = 0; i < params.length; i += 2) {
|
for (int i = 0; i < params.length; i += 2) {
|
||||||
|
|
Loading…
Reference in New Issue