use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class ActiveShardsObserverIT method testCreateIndexNoActiveShardsTimesOut.
public void testCreateIndexNoActiveShardsTimesOut() throws Exception {
Settings.Builder settingsBuilder = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0);
if (internalCluster().getNodeNames().length > 0) {
String exclude = String.join(",", internalCluster().getNodeNames());
settingsBuilder.put("index.routing.allocation.exclude._name", exclude);
}
Settings settings = settingsBuilder.build();
final String indexName = "test-idx";
assertFalse(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(randomBoolean() ? ActiveShardCount.from(1) : ActiveShardCount.ALL).setTimeout("100ms").get().isShardsAcked());
waitForIndexCreationToComplete(indexName);
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class ActiveShardsObserverIT method testCreateIndexWaitsForAllActiveShards.
public void testCreateIndexWaitsForAllActiveShards() throws Exception {
// not enough data nodes, index creation times out
final int numReplicas = internalCluster().numDataNodes() + randomInt(4);
Settings settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), numReplicas).build();
final String indexName = "test-idx";
assertFalse(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).setTimeout("100ms").get().isShardsAcked());
waitForIndexCreationToComplete(indexName);
if (client().admin().indices().prepareExists(indexName).get().isExists()) {
client().admin().indices().prepareDelete(indexName).get();
}
// enough data nodes, all shards are active
settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 7)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), internalCluster().numDataNodes() - 1).build();
assertAcked(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).get());
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class AutoCreateIndexTests method testAutoCreationPatternDisabled.
public void testAutoCreationPatternDisabled() {
Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), "-index*").build();
AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings);
ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build();
expectForbidden(clusterState, autoCreateIndex, "index" + randomAsciiOfLengthBetween(1, 5), "-index*");
/* When patterns are specified, even if the are all negative, the default is can't create. So a pure negative pattern is the same
* as false, really. */
expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5));
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class AutoCreateIndexTests method testDynamicMappingDisabled.
public void testDynamicMappingDisabled() {
Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), randomFrom(true, randomAsciiOfLengthBetween(1, 10))).put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false).build();
AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings);
IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState()));
assertEquals("no such index and [index.mapper.dynamic] is [false]", e.getMessage());
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class AutoCreateIndexTests method testParseFailedMissingIndex.
public void testParseFailedMissingIndex() {
String prefix = randomFrom("+", "-");
Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), prefix).build();
try {
newAutoCreateIndex(settings);
fail("initialization should have failed");
} catch (IllegalArgumentException ex) {
assertEquals("Can't parse [" + prefix + "] for setting [action.auto_create_index] must contain an index name after [" + prefix + "]", ex.getMessage());
}
}
Aggregations