Tests: add 0.20 index and fix test bugs in assertNewReplicasWork()

This commit is contained in:
Robert Muir 2015-01-05 15:27:57 -05:00
parent 0d9fad79e0
commit 8f2f2c5663
2 changed files with 15 additions and 12 deletions

View File

@ -35,9 +35,13 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardCompatibilityTest { public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardCompatibilityTest {
List<String> indexes = Arrays.asList( List<String> indexes = Arrays.asList(
// not yet: until https://github.com/elasticsearch/elasticsearch/pull/9142
// "index-0.20.6.zip",
"index-0.90.0.zip", "index-0.90.0.zip",
"index-0.90.1.zip", "index-0.90.1.zip",
"index-0.90.2.zip", "index-0.90.2.zip",
@ -92,16 +96,16 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
SearchResponse searchRsp = searchReq.get(); SearchResponse searchRsp = searchReq.get();
ElasticsearchAssertions.assertNoFailures(searchRsp); ElasticsearchAssertions.assertNoFailures(searchRsp);
long numDocs = searchRsp.getHits().getTotalHits(); long numDocs = searchRsp.getHits().getTotalHits();
logger.debug("Found " + numDocs + " in old index"); logger.info("Found " + numDocs + " in old index");
searchReq.addSort("long_sort", SortOrder.ASC); searchReq.addSort("long_sort", SortOrder.ASC);
ElasticsearchAssertions.assertNoFailures(searchReq.get()); ElasticsearchAssertions.assertNoFailures(searchReq.get());
} }
void assertRealtimeGetWorks() { void assertRealtimeGetWorks() {
client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder() assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
.put("refresh_interval", -1) .put("refresh_interval", -1)
.build()); .build()));
SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()); SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery());
SearchHit hit = searchReq.get().getHits().getAt(0); SearchHit hit = searchReq.get().getHits().getAt(0);
String docId = hit.getId(); String docId = hit.getId();
@ -111,13 +115,13 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
Map<String, Object> source = getRsp.getSourceAsMap(); Map<String, Object> source = getRsp.getSourceAsMap();
assertThat(source, Matchers.hasKey("foo")); assertThat(source, Matchers.hasKey("foo"));
client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder() assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
.put("refresh_interval", "1s") .put("refresh_interval", "1s")
.build()); .build()));
} }
void assertNewReplicasWork() { void assertNewReplicasWork() {
final int numReplicas = randomIntBetween(1, 2); final int numReplicas = randomIntBetween(2, 3);
for (int i = 0; i < numReplicas; ++i) { for (int i = 0; i < numReplicas; ++i) {
logger.debug("Creating another node for replica " + i); logger.debug("Creating another node for replica " + i);
internalCluster().startNode(ImmutableSettings.builder() internalCluster().startNode(ImmutableSettings.builder()
@ -125,14 +129,13 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
.put("master.node", false).build()); .put("master.node", false).build());
} }
ensureGreen("test"); ensureGreen("test");
client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder() assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
.put("number_of_replicas", numReplicas) .put("number_of_replicas", numReplicas)).execute().actionGet());
.build());
ensureGreen("test"); // TODO: what is the proper way to wait for new replicas to recover? ensureGreen("test"); // TODO: what is the proper way to wait for new replicas to recover?
client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder() assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder()
.put("number_of_replicas", 0) .put("number_of_replicas", 0))
.build()); .execute().actionGet());
} }
} }