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;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -94,10 +95,17 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
|||
assertBasicSearchWorks();
|
||||
assertRealtimeGetWorks();
|
||||
assertNewReplicasWork();
|
||||
assertUpgradeWorks();
|
||||
assertUpgradeWorks(isLatestLuceneVersion(index));
|
||||
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() {
|
||||
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery());
|
||||
SearchResponse searchRsp = searchReq.get();
|
||||
|
@ -147,10 +155,12 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
|
|||
.execute().actionGet());
|
||||
}
|
||||
|
||||
void assertUpgradeWorks() throws Exception {
|
||||
void assertUpgradeWorks(boolean alreadyLatest) throws Exception {
|
||||
HttpRequestBuilder httpClient = httpClient();
|
||||
|
||||
if (alreadyLatest == false) {
|
||||
UpgradeTest.assertNotUpgraded(httpClient, "test");
|
||||
}
|
||||
UpgradeTest.runUpgrade(httpClient, "test", "wait_for_completion", "true");
|
||||
UpgradeTest.assertUpgraded(httpClient, "test");
|
||||
}
|
||||
|
|
|
@ -204,7 +204,9 @@ public class UpgradeTest extends ElasticsearchBackwardsCompatIntegrationTest {
|
|||
for (ShardSegments segs : shard.getShards()) {
|
||||
for (Segment seg : segs.getSegments()) {
|
||||
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