Tests: Remove accidentally added bwc behavior for auto choosing a

version.

An early version of #7966 had the ability to choose a bwc version
automatically, but this was removed before the change was committed.
However, the change was not removed from the ongoing work in #7922
and it made it in unknowningly.
This commit is contained in:
Ryan Ernst 2014-10-31 19:09:38 -07:00
parent 7761154e83
commit 02debfd127
1 changed files with 9 additions and 36 deletions

View File

@ -34,7 +34,6 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import java.io.File; import java.io.File;
import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -83,50 +82,24 @@ public abstract class ElasticsearchBackwardsCompatIntegrationTest extends Elasti
private static File backwardsCompatibilityPath() { private static File backwardsCompatibilityPath() {
String path = System.getProperty(TESTS_BACKWARDS_COMPATIBILITY_PATH); String path = System.getProperty(TESTS_BACKWARDS_COMPATIBILITY_PATH);
if (path == null || path.isEmpty()) { if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("Invalid Backwards tests location path:" + path); throw new IllegalArgumentException("Must specify backwards test path with property " + TESTS_BACKWARDS_COMPATIBILITY_PATH);
} }
String version = System.getProperty(TESTS_BACKWARDS_COMPATIBILITY_VERSION); String version = System.getProperty(TESTS_BACKWARDS_COMPATIBILITY_VERSION);
if (version == null || version.isEmpty()) { if (version == null || version.isEmpty()) {
throw new IllegalArgumentException("Invalid Backwards tests version:" + version); throw new IllegalArgumentException("Must specify backwards test version with property " + TESTS_BACKWARDS_COMPATIBILITY_VERSION);
} }
if (Version.fromString(version).before(Version.CURRENT.minimumCompatibilityVersion())) { if (Version.fromString(version).before(Version.CURRENT.minimumCompatibilityVersion())) {
throw new IllegalArgumentException("Backcompat elasticsearch version must be same major version as current. " + throw new IllegalArgumentException("Backcompat elasticsearch version must be same major version as current. " +
"backcompat: " + version + ", current: " + Version.CURRENT.toString()); "backcompat: " + version + ", current: " + Version.CURRENT.toString());
} }
File dir; File file = new File(path, "elasticsearch-" + version);
if (version == null || version.isEmpty()) { if (!file.exists()) {
// choose a random version throw new IllegalArgumentException("Backwards tests location is missing: " + file.getAbsolutePath());
// TODO: how can we put the version selected in the repeat test output?
File[] subdirs = new File(path).listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().startsWith("elasticsearch-") && file.isDirectory();
}
});
if (subdirs == null || subdirs.length == 0) {
throw new IllegalArgumentException("Backwards dir " + path + " must be a directory, and contain elasticsearch releases");
}
dir = subdirs[randomInt(subdirs.length - 1)];
version = dir.getName().substring("elasticsearch-".length());
} else {
dir = new File(path, "elasticsearch-" + version);
if (!dir.exists()) {
throw new IllegalArgumentException("Backwards tests location is missing: " + dir.getAbsolutePath());
}
if (!dir.isDirectory()) {
throw new IllegalArgumentException("Backwards tests location is not a directory: " + dir.getAbsolutePath());
}
} }
if (!file.isDirectory()) {
Version v = Version.fromString(version); throw new IllegalArgumentException("Backwards tests location is not a directory: " + file.getAbsolutePath());
if (v == null) {
throw new IllegalArgumentException("Backcompat elasticsearch version could not be parsed: " + version);
} }
if (v.major != Version.CURRENT.major) { return file;
throw new IllegalArgumentException("Backcompat elasticsearch version must be same major version as current. " +
"backcompat: " + version + ", current: " + Version.CURRENT.toString());
}
return dir;
} }
public CompositeTestCluster backwardsCluster() { public CompositeTestCluster backwardsCluster() {