remove irrelvant tests

This commit is contained in:
Areek Zillur 2016-03-16 13:27:22 -04:00
parent da165f425f
commit 44b3dc95a0
1 changed files with 1 additions and 82 deletions

View File

@ -32,7 +32,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -63,7 +62,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.startsWith;
@LuceneTestCase.SuppressFileSystems("ExtrasFS") // TODO: fix test to work with ExtrasFS
public class MetaDataStateFormatTests extends ESTestCase {
@ -232,85 +230,6 @@ public class MetaDataStateFormatTests extends ESTestCase {
}
}
// If the latest version doesn't use the legacy format while previous versions do, then fail hard
public void testLatestVersionDoesNotUseLegacy() throws IOException {
MetaDataStateFormat<MetaData> format = metaDataFormat(randomFrom(XContentType.values()));
final Path[] dirs = new Path[2];
dirs[0] = createTempDir();
dirs[1] = createTempDir();
for (Path dir : dirs) {
Files.createDirectories(dir.resolve(MetaDataStateFormat.STATE_DIR_NAME));
}
final Path dir1 = randomFrom(dirs);
final int v1 = randomInt(10);
// write a first state file in the new format
format.write(randomMeta(), v1, dir1);
// write older state files in the old format but with a newer version
final int numLegacyFiles = randomIntBetween(1, 5);
for (int i = 0; i < numLegacyFiles; ++i) {
final Path dir2 = randomFrom(dirs);
final int v2 = v1 + 1 + randomInt(10);
try (XContentBuilder xcontentBuilder = XContentFactory.contentBuilder(format.format(),
Files.newOutputStream(dir2.resolve(MetaDataStateFormat.STATE_DIR_NAME).resolve(MetaData.GLOBAL_STATE_FILE_PREFIX + v2)))) {
xcontentBuilder.startObject();
MetaData.Builder.toXContent(randomMeta(), xcontentBuilder, ToXContent.EMPTY_PARAMS);
xcontentBuilder.endObject();
}
}
try {
format.loadLatestState(logger, dirs);
fail("latest version can not be read");
} catch (IllegalStateException ex) {
assertThat(ex.getMessage(), startsWith("Could not find a state file to recover from among "));
}
// write the next state file in the new format and ensure it get's a higher ID
final MetaData meta = randomMeta();
format.write(meta, v1, dirs);
final MetaData metaData = format.loadLatestState(logger, dirs);
assertEquals(meta.clusterUUID(), metaData.clusterUUID());
final Path path = randomFrom(dirs);
final Path[] files = FileSystemUtils.files(path.resolve("_state"));
assertEquals(1, files.length);
assertEquals("global-" + format.findMaxStateId("global-", dirs) + ".st", files[0].getFileName().toString());
}
// If both the legacy and the new format are available for the latest version, prefer the new format
public void testPrefersNewerFormat() throws IOException {
MetaDataStateFormat<MetaData> format = metaDataFormat(randomFrom(XContentType.values()));
final Path[] dirs = new Path[2];
dirs[0] = createTempDir();
dirs[1] = createTempDir();
for (Path dir : dirs) {
Files.createDirectories(dir.resolve(MetaDataStateFormat.STATE_DIR_NAME));
}
final long v = randomInt(10);
MetaData meta = randomMeta();
String uuid = meta.clusterUUID();
// write a first state file in the old format
final Path dir2 = randomFrom(dirs);
MetaData meta2 = randomMeta();
assertFalse(meta2.clusterUUID().equals(uuid));
try (XContentBuilder xcontentBuilder = XContentFactory.contentBuilder(MetaData.FORMAT.format(),
Files.newOutputStream(dir2.resolve(MetaDataStateFormat.STATE_DIR_NAME).resolve(MetaData.GLOBAL_STATE_FILE_PREFIX + v)))) {
xcontentBuilder.startObject();
MetaData.Builder.toXContent(randomMeta(), xcontentBuilder, ToXContent.EMPTY_PARAMS);
xcontentBuilder.endObject();
}
// write a second state file in the new format but with the same version
format.write(meta, v, dirs);
MetaData state = format.loadLatestState(logger, dirs);
final Path path = randomFrom(dirs);
assertTrue(Files.exists(path.resolve(MetaDataStateFormat.STATE_DIR_NAME).resolve("global-" + (v+1) + ".st")));
assertEquals(state.clusterUUID(), uuid);
}
public void testLoadState() throws IOException {
final Path[] dirs = new Path[randomIntBetween(1, 5)];
int numStates = randomIntBetween(1, 5);
@ -330,7 +249,7 @@ public class MetaDataStateFormatTests extends ESTestCase {
Path file = dirs[i].resolve(MetaDataStateFormat.STATE_DIR_NAME).resolve("global-"+j);
Files.createFile(file); // randomly create 0-byte files -- there is extra logic to skip them
} else {
try (XContentBuilder xcontentBuilder = XContentFactory.contentBuilder(MetaData.FORMAT.format(),
try (XContentBuilder xcontentBuilder = XContentFactory.contentBuilder(type,
Files.newOutputStream(dirs[i].resolve(MetaDataStateFormat.STATE_DIR_NAME).resolve("global-" + j)))) {
xcontentBuilder.startObject();
MetaData.Builder.toXContent(meta.get(j), xcontentBuilder, ToXContent.EMPTY_PARAMS);