Watcher: Hardcode index names for auto index create validation (elastic/elasticsearch#2834)
This is broken in 2.x and returns a wrong index name. We should just use the indices, that are hardcoded in the error message. Relates elastic/elasticsearch#2831 Original commit: elastic/x-pack-elasticsearch@457be61013
This commit is contained in:
parent
bd91603f6d
commit
81382262ec
|
@ -145,7 +145,7 @@ public class IndexActionIT extends AbstractWatcherIntegrationTestCase {
|
|||
|
||||
assertThat(client().admin().indices().prepareExists("idx").get().isExists(), is(false));
|
||||
|
||||
assertThat(docCount(HistoryStore.INDEX_PREFIX + "*", HistoryStore.DOC_TYPE, searchSource()
|
||||
assertThat(docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", HistoryStore.DOC_TYPE, searchSource()
|
||||
.query(matchQuery("result.actions.status", "failure"))), is(1L));
|
||||
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class WatchAckIT extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(),
|
||||
is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION));
|
||||
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX + "*", null,
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
||||
matchQuery(WatchRecord.Field.STATE.getPreferredName(), ExecutionState.THROTTLED.id()));
|
||||
assertThat(throttledCount, greaterThan(0L));
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public class WatchAckIT extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(),
|
||||
is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION));
|
||||
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX + "*", null,
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
||||
matchQuery(WatchRecord.Field.STATE.getPreferredName(), ExecutionState.THROTTLED.id()));
|
||||
assertThat(throttledCount, greaterThan(0L));
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||
|
@ -32,6 +31,7 @@ import org.elasticsearch.xpack.watcher.condition.ConditionModule;
|
|||
import org.elasticsearch.xpack.watcher.execution.ExecutionModule;
|
||||
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
|
||||
import org.elasticsearch.xpack.watcher.execution.InternalWatchExecutor;
|
||||
import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore;
|
||||
import org.elasticsearch.xpack.watcher.history.HistoryModule;
|
||||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
import org.elasticsearch.xpack.watcher.input.InputModule;
|
||||
|
@ -66,6 +66,7 @@ import org.elasticsearch.xpack.watcher.transport.actions.stats.WatcherStatsActio
|
|||
import org.elasticsearch.xpack.watcher.trigger.TriggerModule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleModule;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchModule;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStore;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
|
@ -216,7 +217,7 @@ public class Watcher implements ActionPlugin {
|
|||
|
||||
String errorMessage = LoggerMessageFormat.format("the [action.auto_create_index] setting value [{}] is too" +
|
||||
" restrictive. disable [action.auto_create_index] or set it to " +
|
||||
"[.watches,.triggered_watches,.watcher-history*]", (Object) value);
|
||||
"[{}, {}, {}*]", (Object) value, WatchStore.INDEX, TriggeredWatchStore.INDEX_NAME, HistoryStore.INDEX_PREFIX);
|
||||
if (Booleans.isExplicitFalse(value)) {
|
||||
throw new IllegalArgumentException(errorMessage);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ import static org.elasticsearch.xpack.watcher.support.Exceptions.ioException;
|
|||
*/
|
||||
public class HistoryStore extends AbstractComponent {
|
||||
|
||||
public static final String INDEX_PREFIX = ".watcher-history-" + WatcherIndexTemplateRegistry.INDEX_TEMPLATE_VERSION + "-";
|
||||
public static final String INDEX_PREFIX = ".watcher-history-";
|
||||
public static final String INDEX_PREFIX_WITH_TEMPLATE = INDEX_PREFIX + WatcherIndexTemplateRegistry.INDEX_TEMPLATE_VERSION + "-";
|
||||
public static final String DOC_TYPE = "watch_record";
|
||||
|
||||
static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd");
|
||||
|
@ -123,7 +124,7 @@ public class HistoryStore extends AbstractComponent {
|
|||
* Calculates the correct history index name for a given time
|
||||
*/
|
||||
public static String getHistoryIndexNameForTime(DateTime time) {
|
||||
return INDEX_PREFIX + indexTimeFormat.print(time);
|
||||
return INDEX_PREFIX_WITH_TEMPLATE + indexTimeFormat.print(time);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,34 +15,27 @@ public class WatcherPluginTests extends ESTestCase {
|
|||
public void testValidAutoCreateIndex() {
|
||||
Watcher.validAutoCreateIndex(Settings.EMPTY);
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", true).build());
|
||||
try {
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", false).build());
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history*]"));
|
||||
}
|
||||
|
||||
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", false).build()));
|
||||
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
|
||||
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index",
|
||||
".watches,.triggered_watches,.watcher-history*").build());
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", "*w*").build());
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".w*,.t*").build());
|
||||
try {
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".watches").build());
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history*]"));
|
||||
}
|
||||
try {
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".triggered_watch").build());
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history*]"));
|
||||
}
|
||||
try {
|
||||
Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".watcher-history*").build());
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), containsString("[.watches,.triggered_watches,.watcher-history*]"));
|
||||
}
|
||||
|
||||
exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> Watcher.validAutoCreateIndex(Settings.builder().put("action.auto_create_index", ".watches").build()));
|
||||
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()));
|
||||
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()));
|
||||
assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
actionsCount = docCount("actions", "action", matchAllQuery());
|
||||
assertThat(actionsCount, is(2L));
|
||||
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX + "*", null,
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
||||
matchQuery(WatchRecord.Field.STATE.getPreferredName(), ExecutionState.THROTTLED.id()));
|
||||
assertThat(throttledCount, is(1L));
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
long actionsCount = docCount("actions", "action", matchAllQuery());
|
||||
assertThat(actionsCount, is(1L));
|
||||
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX + "*", null,
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
||||
matchQuery(WatchRecord.Field.STATE.getPreferredName(), ExecutionState.THROTTLED.id()));
|
||||
assertThat(throttledCount, greaterThanOrEqualTo(1L));
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
actionsCount = docCount("actions", "action", matchAllQuery());
|
||||
assertThat(actionsCount, is(2L));
|
||||
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX + "*", null,
|
||||
long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null,
|
||||
matchQuery(WatchRecord.Field.STATE.getPreferredName(), ExecutionState.THROTTLED.id()));
|
||||
assertThat(throttledCount, is(1L));
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class IndexActionIntegrationTests extends AbstractWatcherIntegrationTestC
|
|||
|
||||
assertThat(client().admin().indices().prepareExists("idx").get().isExists(), is(false));
|
||||
|
||||
assertThat(docCount(HistoryStore.INDEX_PREFIX + "*", HistoryStore.DOC_TYPE, searchSource()
|
||||
assertThat(docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", HistoryStore.DOC_TYPE, searchSource()
|
||||
.query(matchQuery("result.actions.status", "failure"))), is(1L));
|
||||
|
||||
}
|
||||
|
|
|
@ -109,13 +109,13 @@ public class ManualExecutionTests extends AbstractWatcherIntegrationTestCase {
|
|||
ManualExecutionContext ctx = ctxBuilder.build();
|
||||
|
||||
refresh();
|
||||
long oldRecordCount = docCount(HistoryStore.INDEX_PREFIX + "*", HistoryStore.DOC_TYPE, matchAllQuery());
|
||||
long oldRecordCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", HistoryStore.DOC_TYPE, matchAllQuery());
|
||||
|
||||
WatchRecord watchRecord = executionService().execute(ctx);
|
||||
|
||||
refresh();
|
||||
|
||||
long newRecordCount = docCount(HistoryStore.INDEX_PREFIX + "*", HistoryStore.DOC_TYPE, matchAllQuery());
|
||||
long newRecordCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", HistoryStore.DOC_TYPE, matchAllQuery());
|
||||
long expectedCount = oldRecordCount + (recordExecution ? 1 : 0);
|
||||
|
||||
assertThat("the expected count of history records should be [" + expectedCount + "]", newRecordCount, equalTo(expectedCount));
|
||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.history;
|
|||
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
|
@ -17,9 +16,7 @@ import org.elasticsearch.xpack.notification.email.support.EmailServer;
|
|||
import org.elasticsearch.xpack.watcher.execution.ExecutionState;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchResponse;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
|
||||
|
@ -107,7 +104,7 @@ public class HistoryTemplateEmailMappingsTests extends AbstractWatcherIntegratio
|
|||
// the action should fail as no email server is available
|
||||
assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1);
|
||||
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSource(searchSource()
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource()
|
||||
.aggregation(terms("from").field("result.actions.email.message.from"))
|
||||
.aggregation(terms("to").field("result.actions.email.message.to"))
|
||||
.aggregation(terms("cc").field("result.actions.email.message.cc"))
|
||||
|
|
|
@ -93,7 +93,7 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration
|
|||
// the action should fail as no email server is available
|
||||
assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1);
|
||||
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSource(searchSource()
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource()
|
||||
.aggregation(terms("input_result_path").field("result.input.http.request.path"))
|
||||
.aggregation(terms("input_result_host").field("result.input.http.request.host"))
|
||||
.aggregation(terms("webhook_path").field("result.actions.webhook.request.path")))
|
||||
|
|
|
@ -55,7 +55,7 @@ public class HistoryTemplateIndexActionMappingsTests extends AbstractWatcherInte
|
|||
flush();
|
||||
refresh();
|
||||
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSource(searchSource()
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource()
|
||||
.aggregation(terms("index_action_indices").field("result.actions.index.response.index"))
|
||||
.aggregation(terms("index_action_types").field("result.actions.index.response.type")))
|
||||
.get();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherInte
|
|||
// the action should fail as no email server is available
|
||||
assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1);
|
||||
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSource(searchSource()
|
||||
SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource()
|
||||
.aggregation(terms("input_search_type").field("result.input.search.request.search_type"))
|
||||
.aggregation(terms("input_indices").field("result.input.search.request.indices"))
|
||||
.aggregation(terms("input_types").field("result.input.search.request.types"))
|
||||
|
|
|
@ -149,7 +149,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
|
|||
|
||||
// Check that the input result payload has been filtered
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setQuery(matchQuery("watch_id", "_name1"))
|
||||
.setSize(1)
|
||||
|
|
|
@ -312,7 +312,8 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
|
||||
protected long watchRecordCount(QueryBuilder query) {
|
||||
refresh();
|
||||
return docCount(HistoryStore.INDEX_PREFIX + "*", HistoryStore.DOC_TYPE, SearchSourceBuilder.searchSource().query(query));
|
||||
return docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*",
|
||||
HistoryStore.DOC_TYPE, SearchSourceBuilder.searchSource().query(query));
|
||||
}
|
||||
|
||||
protected long docCount(String index, String type, SearchSourceBuilder source) {
|
||||
|
@ -324,7 +325,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
}
|
||||
|
||||
protected SearchResponse searchHistory(SearchSourceBuilder builder) {
|
||||
return client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSource(builder).get();
|
||||
return client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(builder).get();
|
||||
}
|
||||
|
||||
protected <T> T getInstanceFromMaster(Class<T> type) {
|
||||
|
@ -398,7 +399,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
assertBusy(() -> {
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state,
|
||||
IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*");
|
||||
IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*");
|
||||
assertThat(watchHistoryIndices, not(emptyArray()));
|
||||
for (String index : watchHistoryIndices) {
|
||||
IndexRoutingTable routingTable = state.getRoutingTable().index(index);
|
||||
|
@ -407,7 +408,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
}
|
||||
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state",
|
||||
ExecutionState.EXECUTED.id())))
|
||||
|
@ -432,14 +433,15 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
}
|
||||
|
||||
protected SearchResponse searchWatchRecords(Callback<SearchRequestBuilder> requestBuilderCallback) {
|
||||
SearchRequestBuilder builder = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setTypes(HistoryStore.DOC_TYPE);
|
||||
SearchRequestBuilder builder =
|
||||
client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setTypes(HistoryStore.DOC_TYPE);
|
||||
requestBuilderCallback.handle(builder);
|
||||
return builder.get();
|
||||
}
|
||||
|
||||
protected long historyRecordsCount(String watchName) {
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setSize(0)
|
||||
.setQuery(matchQuery("watch_id", watchName))
|
||||
|
@ -449,7 +451,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
|
||||
protected long findNumberOfPerformedActions(String watchName) {
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", ExecutionState.EXECUTED.id())))
|
||||
.get();
|
||||
|
@ -465,7 +467,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
// so we to check first is this index is created and shards are started
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state,
|
||||
IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*");
|
||||
IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*");
|
||||
assertThat(watchHistoryIndices, not(emptyArray()));
|
||||
for (String index : watchHistoryIndices) {
|
||||
IndexRoutingTable routingTable = state.getRoutingTable().index(index);
|
||||
|
@ -473,7 +475,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
assertThat(routingTable.allPrimaryShardsActive(), is(true));
|
||||
}
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state",
|
||||
ExecutionState.EXECUTION_NOT_NEEDED.id())))
|
||||
|
@ -497,7 +499,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
assertBusy(() -> {
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, IndicesOptions.lenientExpandOpen(),
|
||||
HistoryStore.INDEX_PREFIX + "*");
|
||||
HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*");
|
||||
assertThat(watchHistoryIndices, not(emptyArray()));
|
||||
for (String index : watchHistoryIndices) {
|
||||
IndexRoutingTable routingTable = state.getRoutingTable().index(index);
|
||||
|
@ -506,7 +508,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
}
|
||||
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
|
||||
.setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", recordState.id())))
|
||||
.get();
|
||||
|
|
|
@ -140,7 +140,7 @@ public class WatcherScheduleEngineBenchmark {
|
|||
try (Node node = new MockNode(settings, Arrays.asList(XPackPlugin.class, XPackPlugin.class))) {
|
||||
try (final Client client = node.client()) {
|
||||
client.admin().cluster().prepareHealth().setWaitForNodes("2").get();
|
||||
client.admin().indices().prepareDelete(HistoryStore.INDEX_PREFIX + "*").get();
|
||||
client.admin().indices().prepareDelete(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get();
|
||||
client.admin().cluster().prepareHealth(WatchStore.INDEX, "test").setWaitForYellowStatus().get();
|
||||
|
||||
Clock clock = node.injector().getInstance(Clock.class);
|
||||
|
@ -185,10 +185,10 @@ public class WatcherScheduleEngineBenchmark {
|
|||
}
|
||||
}
|
||||
}
|
||||
client.admin().indices().prepareRefresh(HistoryStore.INDEX_PREFIX + "*").get();
|
||||
client.admin().indices().prepareRefresh(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get();
|
||||
Script script = new Script("doc['trigger_event.schedule.triggered_time'].value - doc['trigger_event.schedule" +
|
||||
".scheduled_time'].value");
|
||||
SearchResponse searchResponse = client.prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client.prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setQuery(QueryBuilders.rangeQuery("trigger_event.schedule.scheduled_time").gte(startTime).lte(endTime))
|
||||
.addAggregation(terms("state").field("state"))
|
||||
.addAggregation(histogram("delay")
|
||||
|
|
|
@ -208,7 +208,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
|
|||
startWatcher();
|
||||
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").get();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get();
|
||||
assertHitCount(searchResponse, 1);
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), Matchers.equalTo(wid.value()));
|
||||
assertThat(searchResponse.getHits().getAt(0).sourceAsMap().get(WatchRecord.Field.STATE.getPreferredName()).toString(),
|
||||
|
|
|
@ -71,7 +71,7 @@ public class WatchMetadataTests extends AbstractWatcherIntegrationTestCase {
|
|||
}
|
||||
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*")
|
||||
SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*")
|
||||
.setQuery(termQuery("metadata.foo", "bar"))
|
||||
.get();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), greaterThan(0L));
|
||||
|
|
Loading…
Reference in New Issue