summaryrefslogtreecommitdiff
path: root/test/framework
diff options
context:
space:
mode:
authorMartijn van Groningen <martijn.v.groningen@gmail.com>2017-06-16 19:02:16 +0200
committerMartijn van Groningen <martijn.v.groningen@gmail.com>2017-06-19 12:27:24 +0200
commitbcaa413b0b61c0b86f1da4fbbebd6def18a98107 (patch)
tree6ebac837b14ccbf34b0b51ec17091bd9f49c62bf /test/framework
parentdf5640efd751acde861841f2f9cab9dfab87a7c5 (diff)
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
Diffstat (limited to 'test/framework')
-rw-r--r--test/framework/src/main/java/org/elasticsearch/test/OldIndexUtils.java81
1 files changed, 0 insertions, 81 deletions
diff --git a/test/framework/src/main/java/org/elasticsearch/test/OldIndexUtils.java b/test/framework/src/main/java/org/elasticsearch/test/OldIndexUtils.java
index 81d8fa84a1..bdbc462066 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/OldIndexUtils.java
+++ b/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;
- }
}