Skip to content

Commit 0cdaab0

Browse files
committed
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 Conflicts: src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java
1 parent 5c41bd2 commit 0cdaab0

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555

5656
@TimeoutSuite(millis = 40 * TimeUnits.MINUTE)
5757
public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardCompatibilityTest {
58-
58+
5959
static List<String> indexes;
60-
60+
6161
@BeforeClass
6262
public static void initIndexes() throws Exception {
6363
indexes = new ArrayList<>();
@@ -70,19 +70,20 @@ public static void initIndexes() throws Exception {
7070
}
7171
Collections.sort(indexes);
7272
}
73-
73+
7474
public void testAllVersionsTested() throws Exception {
7575
SortedSet<String> expectedVersions = new TreeSet<>();
7676
for (java.lang.reflect.Field field : Version.class.getDeclaredFields()) {
7777
if (Modifier.isStatic(field.getModifiers()) && field.getType() == Version.class) {
7878
Version v = (Version)field.get(Version.class);
79-
if (v.snapshot()) continue;
80-
if (v.before(Version.V_0_20_0_RC1)) continue;
79+
if (v.snapshot()) continue; // snapshots are unreleased, so there is no backcompat yet
80+
if (v.onOrBefore(Version.V_0_20_0_RC1)) continue; // we can only test back one major lucene version
81+
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
8182

8283
expectedVersions.add("index-" + v.toString() + ".zip");
8384
}
8485
}
85-
86+
8687
for (String index : indexes) {
8788
if (expectedVersions.remove(index) == false) {
8889
logger.warn("Old indexes tests contain extra index: " + index);
@@ -128,11 +129,11 @@ void assertOldIndexWorks(String index) throws Exception {
128129
assertDeleteByQueryWorked(version);
129130
unloadIndex();
130131
}
131-
132+
132133
Version extractVersion(String index) {
133134
return Version.fromString(index.substring(index.indexOf('-') + 1, index.lastIndexOf('.')));
134135
}
135-
136+
136137
boolean isLatestLuceneVersion(Version version) {
137138
return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
138139
version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
@@ -144,7 +145,7 @@ void assertBasicSearchWorks() {
144145
ElasticsearchAssertions.assertNoFailures(searchRsp);
145146
long numDocs = searchRsp.getHits().getTotalHits();
146147
logger.info("Found " + numDocs + " in old index");
147-
148+
148149
searchReq.addSort("long_sort", SortOrder.ASC);
149150
ElasticsearchAssertions.assertNoFailures(searchReq.get());
150151

@@ -203,7 +204,7 @@ void assertDeleteByQueryWorked(Version version) throws Exception {
203204
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.queryStringQuery("long_sort:[10 TO 20]"));
204205
assertEquals(0, searchReq.get().getHits().getTotalHits());
205206
}
206-
207+
207208
void assertUpgradeWorks(boolean alreadyLatest) throws Exception {
208209
HttpRequestBuilder httpClient = httpClient();
209210

src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public void restoreOldSnapshots() throws Exception {
7272
Version v = (Version) field.get(Version.class);
7373
if (v.snapshot()) continue;
7474
if (v.onOrBefore(Version.V_1_0_0_Beta1)) continue;
75+
if (v.equals(Version.CURRENT)) continue;
7576

7677
expectedVersions.add(v.toString());
7778
}

0 commit comments

Comments
 (0)