Tests: Add logic to handle static index upgrade case where index is
already on latest version. See #9207
This commit is contained in:
parent
d226a973f7
commit
4cda543637
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.bwcompat;
|
package org.elasticsearch.bwcompat;
|
||||||
|
|
||||||
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
|
@ -94,10 +95,17 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
||||||
assertBasicSearchWorks();
|
assertBasicSearchWorks();
|
||||||
assertRealtimeGetWorks();
|
assertRealtimeGetWorks();
|
||||||
assertNewReplicasWork();
|
assertNewReplicasWork();
|
||||||
assertUpgradeWorks();
|
assertUpgradeWorks(isLatestLuceneVersion(index));
|
||||||
unloadIndex();
|
unloadIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isLatestLuceneVersion(String index) {
|
||||||
|
String versionStr = index.substring(index.indexOf('-') + 1, index.lastIndexOf('.'));
|
||||||
|
Version version = Version.fromString(versionStr);
|
||||||
|
return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
|
||||||
|
version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
|
||||||
|
}
|
||||||
|
|
||||||
void assertBasicSearchWorks() {
|
void assertBasicSearchWorks() {
|
||||||
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery());
|
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery());
|
||||||
SearchResponse searchRsp = searchReq.get();
|
SearchResponse searchRsp = searchReq.get();
|
||||||
|
@ -147,10 +155,12 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
||||||
.execute().actionGet());
|
.execute().actionGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertUpgradeWorks() throws Exception {
|
void assertUpgradeWorks(boolean alreadyLatest) throws Exception {
|
||||||
HttpRequestBuilder httpClient = httpClient();
|
HttpRequestBuilder httpClient = httpClient();
|
||||||
|
|
||||||
|
if (alreadyLatest == false) {
|
||||||
UpgradeTest.assertNotUpgraded(httpClient, "test");
|
UpgradeTest.assertNotUpgraded(httpClient, "test");
|
||||||
|
}
|
||||||
UpgradeTest.runUpgrade(httpClient, "test", "wait_for_completion", "true");
|
UpgradeTest.runUpgrade(httpClient, "test", "wait_for_completion", "true");
|
||||||
UpgradeTest.assertUpgraded(httpClient, "test");
|
UpgradeTest.assertUpgraded(httpClient, "test");
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,9 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest {
|
||||||
for (ShardSegments segs : shard.getShards()) {
|
for (ShardSegments segs : shard.getShards()) {
|
||||||
for (Segment seg : segs.getSegments()) {
|
for (Segment seg : segs.getSegments()) {
|
||||||
assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(),
|
assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(),
|
||||||
Version.CURRENT.luceneVersion, seg.version);
|
Version.CURRENT.luceneVersion.major, seg.version.major);
|
||||||
|
assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(),
|
||||||
|
Version.CURRENT.luceneVersion.minor, seg.version.minor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue