Skip to content

Commit

Permalink
Make Watcher validation message copy/pasteable
Browse files Browse the repository at this point in the history
Watcher validates `action.auto_create_index` upon startup. If a user
specifies a pattern that does not contain watcher indices, it raises an
error message to include a list of three indices. However, the indices
are separated by a comma and a space which is not considered in parsing.

With this commit we change the error message string so it does not
contain the additional space thus making it more straightforward to copy
it to the configuration file.

Closes elastic#33369
  • Loading branch information
danielmitterdorfer committed Sep 7, 2018
1 parent 7b923ea commit 99470f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -535,7 +535,7 @@ static void validAutoCreateIndex(Settings settings, Logger logger) {

String errorMessage = LoggerMessageFormat.format("the [action.auto_create_index] setting value [{}] is too" +
" restrictive. disable [action.auto_create_index] or set it to " +
"[{}, {}, {}*]", (Object) value, Watch.INDEX, TriggeredWatchStoreField.INDEX_NAME, HistoryStoreField.INDEX_PREFIX);
"[{},{},{}*]", (Object) value, Watch.INDEX, TriggeredWatchStoreField.INDEX_NAME, HistoryStoreField.INDEX_PREFIX);
if (Booleans.isFalse(value)) {
throw new IllegalArgumentException(errorMessage);
}
Expand Down
Expand Up @@ -37,7 +37,7 @@ public void testValidAutoCreateIndex() {

IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", false).build(), logger));
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
assertThat(exception.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history-*]"));

Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index",
".watches,.triggered_watches,.watcher-history*").build(), logger);
Expand All @@ -46,16 +46,16 @@ public void testValidAutoCreateIndex() {

exception = expectThrows(IllegalArgumentException.class,
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".watches").build(), logger));
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
assertThat(exception.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history-*]"));

exception = expectThrows(IllegalArgumentException.class,
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".triggered_watch").build(), logger));
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
assertThat(exception.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history-*]"));

exception = expectThrows(IllegalArgumentException.class,
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".watcher-history-*").build(),
logger));
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
assertThat(exception.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history-*]"));
}

public void testWatcherDisabledTests() throws Exception {
Expand Down

0 comments on commit 99470f0

Please sign in to comment.