Tests: Skip Version.CURRENT for static bwc indexes

The current version is normally a snapshot while in development.
However, when the release process changes the snapshot flag to false,
this causes the static bwc tests to fail because they cannot
find an index for the current version.  Instead, this change
skips the current version, because there is no need to test
a verion's bwc against itself.

closes #10292
closes #10293
This commit is contained in:
Ryan Ernst 2015-03-27 01:52:48 -07:00
parent 3f8908acfb
commit 96fa466414
2 changed files with 12 additions and 10 deletions

View File

@ -65,9 +65,9 @@ import static org.hamcrest.CoreMatchers.equalTo;
public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardCompatibilityTest {
// TODO: test for proper exception on unsupported indexes (maybe via separate test?)
// We have a 0.20.6.zip etc for this.
static List<String> indexes;
@BeforeClass
public static void initIndexes() throws Exception {
indexes = new ArrayList<>();
@ -80,19 +80,20 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
}
Collections.sort(indexes);
}
public void testAllVersionsTested() throws Exception {
SortedSet<String> expectedVersions = new TreeSet<>();
for (java.lang.reflect.Field field : Version.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == Version.class) {
Version v = (Version)field.get(Version.class);
if (v.snapshot()) continue;
if (v.onOrBefore(Version.V_0_20_6)) continue;
if (v.snapshot()) continue; // snapshots are unreleased, so there is no backcompat yet
if (v.onOrBefore(Version.V_0_20_6)) continue; // we can only test back one major lucene version
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
expectedVersions.add("index-" + v.toString() + ".zip");
}
}
for (String index : indexes) {
if (expectedVersions.remove(index) == false) {
logger.warn("Old indexes tests contain extra index: " + index);
@ -131,11 +132,11 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
assertDeleteByQueryWorked(version);
unloadIndex();
}
Version extractVersion(String index) {
return Version.fromString(index.substring(index.indexOf('-') + 1, index.lastIndexOf('.')));
}
boolean isLatestLuceneVersion(Version version) {
return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
@ -147,7 +148,7 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
ElasticsearchAssertions.assertNoFailures(searchRsp);
long numDocs = searchRsp.getHits().getTotalHits();
logger.info("Found " + numDocs + " in old index");
searchReq.addSort("long_sort", SortOrder.ASC);
ElasticsearchAssertions.assertNoFailures(searchReq.get());
@ -229,7 +230,7 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.queryStringQuery("long_sort:[10 TO 20]"));
assertEquals(0, searchReq.get().getHits().getTotalHits());
}
void assertUpgradeWorks(boolean alreadyLatest) throws Exception {
HttpRequestBuilder httpClient = httpClient();

View File

@ -72,6 +72,7 @@ public class RestoreBackwardsCompatTests extends AbstractSnapshotTests {
Version v = (Version) field.get(Version.class);
if (v.snapshot()) continue;
if (v.onOrBefore(Version.V_1_0_0_Beta1)) continue;
if (v.equals(Version.CURRENT)) continue;
expectedVersions.add(v.toString());
}