From d1a4f889aeabe1a99cd0ba62766b585715f1623b Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 14 Jan 2014 19:38:39 +0100 Subject: [PATCH] Fix DestructiveOperationsIntegrationTests to wait for index to be allocated before closing --- ...DestructiveOperationsIntegrationTests.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationTests.java b/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationTests.java index b7a26dd185a..cd0ab6efec8 100644 --- a/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationTests.java +++ b/src/test/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIntegrationTests.java @@ -53,12 +53,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat try { // should fail since index1 is the only index. client().admin().indices().prepareDelete("i*").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} try { client().admin().indices().prepareDelete("_all").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} settings = ImmutableSettings.builder() @@ -78,26 +78,26 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat assertAcked(client().admin().indices().prepareCreate("index1").get()); assertAcked(client().admin().indices().prepareCreate("1index").get()); - + ensureYellow();// wait for primaries to be allocated // Should succeed, since no wildcards assertAcked(client().admin().indices().prepareClose("1index").get()); try { client().admin().indices().prepareClose("_all").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} try { assertAcked(client().admin().indices().prepareOpen("_all").get()); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) { } try { client().admin().indices().prepareClose("*").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} try { assertAcked(client().admin().indices().prepareOpen("*").get()); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) { } @@ -124,12 +124,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat try { client().prepareDeleteByQuery("_all").setQuery(QueryBuilders.matchAllQuery()).get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} try { client().prepareDeleteByQuery().setQuery(QueryBuilders.matchAllQuery()).get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} settings = ImmutableSettings.builder() @@ -157,12 +157,12 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat client().admin().indices().prepareDeleteMapping("1index").setType("1").get(); try { client().admin().indices().prepareDeleteMapping("_all").setType("1").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} try { client().admin().indices().prepareDeleteMapping().setType("1").get(); - assert false; + fail(); } catch (ElasticsearchIllegalArgumentException e) {} settings = ImmutableSettings.builder() @@ -170,10 +170,10 @@ public class DestructiveOperationsIntegrationTests extends ElasticsearchIntegrat .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); - client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string").get(); - client().admin().indices().prepareDeleteMapping().setType("1").get(); - client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string").get(); - client().admin().indices().prepareDeleteMapping("_all").setType("1").get(); + assertAcked(client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string")); + assertAcked(client().admin().indices().prepareDeleteMapping().setType("1")); + assertAcked(client().admin().indices().preparePutMapping("1index").setType("1").setSource("field1", "type=string")); + assertAcked(client().admin().indices().prepareDeleteMapping("_all").setType("1")); } }