Added an AwaitsFix to testDeleteAllOneIndex. Martijn is on it.

This commit is contained in:
Boaz Leskes 2013-10-10 08:52:11 +02:00
parent 15b4d70298
commit 2cd1f53f69
1 changed files with 12 additions and 10 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.deleteByQuery;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder;
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
import org.elasticsearch.action.search.SearchResponse;
@ -44,24 +45,25 @@ public class DeleteByQueryTests extends AbstractIntegrationTest {
DeleteByQueryResponse actionGet = deleteByQueryRequestBuilder.execute().actionGet();
assertThat(actionGet.getIndices().size(), equalTo(0));
}
@Test
@LuceneTestCase.AwaitsFix(bugUrl = "Martijn is working on a fix for a failure here caused by a shard reject the delete because it's in a POST_RECOVERY state")
public void testDeleteAllOneIndex() {
String json = "{" + "\"user\":\"kimchy\"," + "\"postDate\":\"2013-01-30\"," + "\"message\":\"trying out Elastic Search\"" + "}";
client().prepareIndex("twitter", "tweet").setSource(json).setRefresh(true).execute().actionGet();
SearchResponse search = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
assertThat(search.getHits().totalHits(), equalTo(1l));
DeleteByQueryRequestBuilder deleteByQueryRequestBuilder = client().prepareDeleteByQuery();
deleteByQueryRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
DeleteByQueryResponse actionGet = deleteByQueryRequestBuilder.execute().actionGet();
assertThat(actionGet.status(), equalTo(RestStatus.OK));
assertThat(actionGet.getIndex("twitter"), notNullValue());
assertThat(actionGet.getIndex("twitter").getFailedShards(), equalTo(0));
client().admin().indices().prepareRefresh().execute().actionGet();
search = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
assertThat(search.getHits().totalHits(), equalTo(0l));
@ -109,24 +111,24 @@ public class DeleteByQueryTests extends AbstractIntegrationTest {
assertThat(response.getIndex("twitter").getSuccessfulShards(), equalTo(0));
assertThat(response.getIndex("twitter").getFailedShards(), equalTo(5));
}
@Test
public void testDeleteByFieldQuery() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
int numDocs = atLeast(10);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "test", Integer.toString(i))
.setRouting(randomAsciiOfLengthBetween(1,5))
.setSource("foo", "bar").get();
.setRouting(randomAsciiOfLengthBetween(1, 5))
.setSource("foo", "bar").get();
}
refresh();
assertHitCount(client().prepareCount("test").setQuery(QueryBuilders.fieldQuery("_id",Integer.toString(between(0,numDocs-1)))).get(), 1);
assertHitCount(client().prepareCount("test").setQuery(QueryBuilders.fieldQuery("_id", Integer.toString(between(0, numDocs - 1)))).get(), 1);
assertHitCount(client().prepareCount("test").setQuery(QueryBuilders.matchAllQuery()).get(), numDocs);
client().prepareDeleteByQuery("test")
.setQuery(QueryBuilders.fieldQuery("_id", Integer.toString(between(0,numDocs-1))))
.setQuery(QueryBuilders.fieldQuery("_id", Integer.toString(between(0, numDocs - 1))))
.execute().actionGet();
refresh();
assertHitCount(client().prepareCount("test").setQuery(QueryBuilders.matchAllQuery()).get(), numDocs-1);
assertHitCount(client().prepareCount("test").setQuery(QueryBuilders.matchAllQuery()).get(), numDocs - 1);
}