Fix DestructiveOperationsIntegrationTests to wait for index to be allocated before closing

This commit is contained in:
Simon Willnauer 2014-01-14 19:38:39 +01:00
parent 9440655ab9
commit d1a4f889ae
1 changed files with 15 additions and 15 deletions

View File

@ -53,12 +53,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat
try { try {
// should fail since index1 is the only index. // should fail since index1 is the only index.
client().admin().indices().prepareDelete("i*").get(); client().admin().indices().prepareDelete("i*").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
try { try {
client().admin().indices().prepareDelete("_all").get(); client().admin().indices().prepareDelete("_all").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
settings = ImmutableSettings.builder() settings = ImmutableSettings.builder()
@ -78,26 +78,26 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat
assertAcked(client().admin().indices().prepareCreate("index1").get()); assertAcked(client().admin().indices().prepareCreate("index1").get());
assertAcked(client().admin().indices().prepareCreate("1index").get()); assertAcked(client().admin().indices().prepareCreate("1index").get());
ensureYellow();// wait for primaries to be allocated
// Should succeed, since no wildcards // Should succeed, since no wildcards
assertAcked(client().admin().indices().prepareClose("1index").get()); assertAcked(client().admin().indices().prepareClose("1index").get());
try { try {
client().admin().indices().prepareClose("_all").get(); client().admin().indices().prepareClose("_all").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
try { try {
assertAcked(client().admin().indices().prepareOpen("_all").get()); assertAcked(client().admin().indices().prepareOpen("_all").get());
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) { } catch (ElasticsearchIllegalArgumentException e) {
} }
try { try {
client().admin().indices().prepareClose("*").get(); client().admin().indices().prepareClose("*").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
try { try {
assertAcked(client().admin().indices().prepareOpen("*").get()); assertAcked(client().admin().indices().prepareOpen("*").get());
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) { } catch (ElasticsearchIllegalArgumentException e) {
} }
@ -124,12 +124,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat
try { try {
client().prepareDeleteByQuery("_all").setQuery(QueryBuilders.matchAllQuery()).get(); client().prepareDeleteByQuery("_all").setQuery(QueryBuilders.matchAllQuery()).get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
try { try {
client().prepareDeleteByQuery().setQuery(QueryBuilders.matchAllQuery()).get(); client().prepareDeleteByQuery().setQuery(QueryBuilders.matchAllQuery()).get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
settings = ImmutableSettings.builder() settings = ImmutableSettings.builder()
@ -157,12 +157,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat
client().admin().indices().prepareDeleteMapping("1index").setType("1").get(); client().admin().indices().prepareDeleteMapping("1index").setType("1").get();
try { try {
client().admin().indices().prepareDeleteMapping("_all").setType("1").get(); client().admin().indices().prepareDeleteMapping("_all").setType("1").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
try { try {
client().admin().indices().prepareDeleteMapping().setType("1").get(); client().admin().indices().prepareDeleteMapping().setType("1").get();
assert false; fail();
} catch (ElasticsearchIllegalArgumentException e) {} } catch (ElasticsearchIllegalArgumentException e) {}
settings = ImmutableSettings.builder() settings = ImmutableSettings.builder()
@ -170,10 +170,10 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat
.build(); .build();
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings));
client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string").get(); assertAcked(client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string"));
client().admin().indices().prepareDeleteMapping().setType("1").get(); assertAcked(client().admin().indices().prepareDeleteMapping().setType("1"));
client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string").get(); assertAcked(client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string"));
client().admin().indices().prepareDeleteMapping("_all").setType("1").get(); assertAcked(client().admin().indices().prepareDeleteMapping("_all").setType("1"));
} }
} }