Fixes CreateIndexIT test that assumes an index create propogated

before calling delete.
This commit is contained in:
Ali Beyad 2016-08-03 16:24:24 -04:00
parent e249ad8dfe
commit be87d50f32
1 changed files with 3 additions and 6 deletions

View File

@ -481,29 +481,26 @@ public class CreateIndexIT extends ESIntegTestCase {
* This test ensures that index creation adheres to the {@link IndexMetaData#SETTING_WAIT_FOR_ACTIVE_SHARDS}. * This test ensures that index creation adheres to the {@link IndexMetaData#SETTING_WAIT_FOR_ACTIVE_SHARDS}.
*/ */
public void testDefaultWaitForActiveShardsUsesIndexSetting() throws Exception { public void testDefaultWaitForActiveShardsUsesIndexSetting() throws Exception {
final String indexName = "test";
final int numReplicas = internalCluster().numDataNodes(); final int numReplicas = internalCluster().numDataNodes();
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), Integer.toString(numReplicas)) .put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), Integer.toString(numReplicas))
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1)
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), numReplicas) .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), numReplicas)
.build(); .build();
assertAcked(client().admin().indices().prepareCreate(indexName).setSettings(settings).get()); assertAcked(client().admin().indices().prepareCreate("test-idx-1").setSettings(settings).get());
assertAcked(client().admin().indices().prepareDelete(indexName));
// all should fail // all should fail
settings = Settings.builder() settings = Settings.builder()
.put(settings) .put(settings)
.put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "all") .put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "all")
.build(); .build();
assertFalse(client().admin().indices().prepareCreate(indexName).setSettings(settings).setTimeout("100ms").get().isShardsAcked()); assertFalse(client().admin().indices().prepareCreate("test-idx-2").setSettings(settings).setTimeout("100ms").get().isShardsAcked());
assertAcked(client().admin().indices().prepareDelete(indexName));
// the numeric equivalent of all should also fail // the numeric equivalent of all should also fail
settings = Settings.builder() settings = Settings.builder()
.put(settings) .put(settings)
.put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), Integer.toString(numReplicas + 1)) .put(SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), Integer.toString(numReplicas + 1))
.build(); .build();
assertFalse(client().admin().indices().prepareCreate(indexName).setSettings(settings).setTimeout("100ms").get().isShardsAcked()); assertFalse(client().admin().indices().prepareCreate("test-idx-3").setSettings(settings).setTimeout("100ms").get().isShardsAcked());
} }
} }