Skip to content

Commit

Permalink
Fixed failure for testDeletePercolatorType where the .percolator mapp…
Browse files Browse the repository at this point in the history
…ing hasn't propagated to master that was dynamically created via an index call, which made the delete mapping call fail.
  • Loading branch information
martijnvg committed Jan 28, 2014
1 parent b5a6a5a commit cb75830
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/test/java/org/elasticsearch/percolator/PercolatorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
package org.elasticsearch.percolator;

import com.google.common.base.Predicate;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.action.percolate.PercolateResponse;
Expand Down Expand Up @@ -1490,13 +1491,8 @@ public int compare(PercolateResponse.Match a, PercolateResponse.Match b) {

@Test
public void testDeletePercolatorType() throws Exception {
DeleteIndexResponse deleteIndexResponse = client().admin().indices().prepareDelete("_all").execute().actionGet();
assertThat("Delete Index failed - not acked", deleteIndexResponse.isAcknowledged(), equalTo(true));
ensureGreen();

client().admin().indices().prepareCreate("test1").execute().actionGet();
client().admin().indices().prepareCreate("test2").execute().actionGet();
ensureGreen();
assertAcked(client().admin().indices().prepareCreate("test1"));
assertAcked(client().admin().indices().prepareCreate("test2"));

client().prepareIndex("test1", PercolatorService.TYPE_NAME, "1")
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
Expand All @@ -1511,6 +1507,19 @@ public void testDeletePercolatorType() throws Exception {
.execute().actionGet();
assertMatchCount(response, 2l);

awaitBusy(new Predicate<Object>() {
@Override
public boolean apply(Object o) {
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("test1", "test2").get();
boolean hasPercolatorType = getMappingsResponse.getMappings().get("test1").containsKey(PercolatorService.TYPE_NAME);
if (hasPercolatorType) {
return getMappingsResponse.getMappings().get("test2").containsKey(PercolatorService.TYPE_NAME);
} else {
return false;
}
}
});

assertAcked(client().admin().indices().prepareDeleteMapping("test1").setType(PercolatorService.TYPE_NAME));
response = client().preparePercolate()
.setIndices("test1", "test2").setDocumentType("type").setOnlyCount(true)
Expand Down

0 comments on commit cb75830

Please sign in to comment.