use of org.opensearch.indices.InvalidIndexTemplateException in project OpenSearch by opensearch-project.
the class SearchPhaseExecutionExceptionTests method testPhaseFailureWithSearchShardFailure.
public void testPhaseFailureWithSearchShardFailure() {
final ShardSearchFailure[] shardSearchFailures = new ShardSearchFailure[randomIntBetween(1, 5)];
for (int i = 0; i < shardSearchFailures.length; i++) {
Exception cause = randomFrom(new ParsingException(1, 2, "foobar", null), new InvalidIndexTemplateException("foo", "bar"));
shardSearchFailures[i] = new ShardSearchFailure(cause, new SearchShardTarget("node_" + i, new ShardId("test", "_na_", i), null, OriginalIndices.NONE));
}
final String phase = randomFrom("fetch", "search", "other");
SearchPhaseExecutionException actual = new SearchPhaseExecutionException(phase, "unexpected failures", new OpenSearchRejectedExecutionException("OpenSearch rejected execution of fetch phase"), shardSearchFailures);
assertEquals(actual.status(), RestStatus.BAD_REQUEST);
}
use of org.opensearch.indices.InvalidIndexTemplateException in project OpenSearch by opensearch-project.
the class HiddenIndexIT method testGlobalTemplateCannotMakeIndexHidden.
public void testGlobalTemplateCannotMakeIndexHidden() {
InvalidIndexTemplateException invalidIndexTemplateException = expectThrows(InvalidIndexTemplateException.class, () -> client().admin().indices().preparePutTemplate("a_global_template").setPatterns(Collections.singletonList("*")).setSettings(Settings.builder().put("index.hidden", randomBoolean()).build()).get());
assertThat(invalidIndexTemplateException.getMessage(), containsString("global templates may not specify the setting index.hidden"));
}
Aggregations