Cross Cluster Search: optionally skip disconnected clusters (elastic/x-pack-elasticsearch#2823)
Original commit: elastic/x-pack-elasticsearch@3b0017df1f
This commit is contained in:
parent
f06acdc219
commit
941c0a5701
|
@ -75,7 +75,8 @@ public class InternalClientIntegTests extends ESSingleNodeTestCase {
|
|||
String scrollId = randomAlphaOfLength(5);
|
||||
SearchHit[] hits = new SearchHit[] {new SearchHit(1)};
|
||||
InternalSearchResponse internalResponse = new InternalSearchResponse(new SearchHits(hits, 1, 1), null, null, null, false, false, 1);
|
||||
SearchResponse response = new SearchResponse(internalResponse, scrollId, 1, 1, 0, 0, ShardSearchFailure.EMPTY_ARRAY);
|
||||
SearchResponse response = new SearchResponse(internalResponse, scrollId, 1, 1, 0, 0, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
|
||||
Answer<?> returnResponse = invocation -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -140,7 +140,7 @@ public class WatcherServiceTests extends ESTestCase {
|
|||
// empty scroll response, no further scrolling needed
|
||||
SearchResponseSections scrollSearchSections = new SearchResponseSections(SearchHits.empty(), null, null, false, false, null, 1);
|
||||
SearchResponse scrollSearchResponse = new SearchResponse(scrollSearchSections, "scrollId", 1, 1, 0, 10,
|
||||
ShardSearchFailure.EMPTY_ARRAY);
|
||||
ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY);
|
||||
|
||||
// one search response containing active and inactive watches
|
||||
int count = randomIntBetween(2, 200);
|
||||
|
@ -166,7 +166,8 @@ public class WatcherServiceTests extends ESTestCase {
|
|||
}
|
||||
SearchHits searchHits = new SearchHits(hits, count, 1.0f);
|
||||
SearchResponseSections sections = new SearchResponseSections(searchHits, null, null, false, false, null, 1);
|
||||
SearchResponse searchResponse = new SearchResponse(sections, "scrollId", 1, 1, 0, 10, ShardSearchFailure.EMPTY_ARRAY);
|
||||
SearchResponse searchResponse = new SearchResponse(sections, "scrollId", 1, 1, 0, 10, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
|
||||
// we do need to to use this kind of mocking because of the internal client, which calls doExecute at the end on the supplied
|
||||
// client instance
|
||||
|
|
|
@ -84,7 +84,8 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
|||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(
|
||||
new SearchHits(new SearchHit[]{hit}, 1L, 1f), null, null, null, false, false, 1);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
|
||||
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
|
||||
assertThat(condition.execute(ctx).met(), is(true));
|
||||
|
|
|
@ -94,7 +94,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
|
||||
public void testExecute() throws Exception {
|
||||
ScriptCondition condition = new ScriptCondition(mockScript("ctx.payload.hits.total > 1"), scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
assertFalse(condition.execute(ctx).met());
|
||||
}
|
||||
|
@ -102,7 +103,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
public void testExecuteMergedParams() throws Exception {
|
||||
Script script = new Script(ScriptType.INLINE, "mockscript", "ctx.payload.hits.total > threshold", singletonMap("threshold", 1));
|
||||
ScriptCondition executable = new ScriptCondition(script, scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
assertFalse(executable.execute(ctx).met());
|
||||
}
|
||||
|
@ -115,7 +117,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
parser.nextToken();
|
||||
ScriptCondition executable = ScriptCondition.parse(scriptService, "_watch", parser);
|
||||
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
|
||||
assertFalse(executable.execute(ctx).met());
|
||||
|
@ -179,7 +182,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
public void testScriptConditionThrowException() throws Exception {
|
||||
ScriptCondition condition = new ScriptCondition(
|
||||
mockScript("null.foo"), scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
ScriptException exception = expectThrows(ScriptException.class, () -> condition.execute(ctx));
|
||||
assertThat(exception.getMessage(), containsString("Error evaluating null.foo"));
|
||||
|
@ -187,7 +191,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
|
||||
public void testScriptConditionReturnObjectThrowsException() throws Exception {
|
||||
ScriptCondition condition = new ScriptCondition(mockScript("return new Object()"), scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||
Exception exception = expectThrows(IllegalStateException.class, () -> condition.execute(ctx));
|
||||
assertThat(exception.getMessage(),
|
||||
|
@ -197,7 +202,8 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
public void testScriptConditionAccessCtx() throws Exception {
|
||||
ScriptCondition condition = new ScriptCondition(mockScript("ctx.trigger.scheduled_time.getMillis() < new Date().time"),
|
||||
scriptService);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, new ShardSearchFailure[0]);
|
||||
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 0, 500L, ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY);
|
||||
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
|
||||
Thread.sleep(10);
|
||||
assertThat(condition.execute(ctx).met(), is(true));
|
||||
|
|
|
@ -199,8 +199,8 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
hit.sourceRef(source);
|
||||
hits = new SearchHits(new SearchHit[]{hit}, 1, 1.0f);
|
||||
SearchResponse searchResponse2 = new SearchResponse(
|
||||
new InternalSearchResponse(hits, null, null, null, false, null, 1), "_scrollId1", 1, 1, 0, 1, null);
|
||||
SearchResponse searchResponse3 = new SearchResponse(InternalSearchResponse.empty(), "_scrollId2", 1, 1, 0, 1, null);
|
||||
new InternalSearchResponse(hits, null, null, null, false, null, 1), "_scrollId1", 1, 1, 0, 1, null, null);
|
||||
SearchResponse searchResponse3 = new SearchResponse(InternalSearchResponse.empty(), "_scrollId2", 1, 1, 0, 1, null, null);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
SearchScrollRequest request = (SearchScrollRequest) invocation.getArguments()[0];
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SearchInputTests extends ESTestCase {
|
|||
ArgumentCaptor<SearchRequest> requestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
|
||||
PlainActionFuture<SearchResponse> searchFuture = PlainActionFuture.newFuture();
|
||||
SearchResponse searchResponse = new SearchResponse(InternalSearchResponse.empty(), "", 1, 1, 0, 1234,
|
||||
ShardSearchFailure.EMPTY_ARRAY);
|
||||
ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY);
|
||||
searchFuture.onResponse(searchResponse);
|
||||
when(client.search(requestCaptor.capture())).thenReturn(searchFuture);
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class SearchInputTests extends ESTestCase {
|
|||
ArgumentCaptor<SearchRequest> requestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
|
||||
PlainActionFuture<SearchResponse> searchFuture = PlainActionFuture.newFuture();
|
||||
SearchResponse searchResponse = new SearchResponse(InternalSearchResponse.empty(), "", 1, 1, 0, 1234,
|
||||
ShardSearchFailure.EMPTY_ARRAY);
|
||||
ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY);
|
||||
searchFuture.onResponse(searchResponse);
|
||||
when(client.search(requestCaptor.capture())).thenReturn(searchFuture);
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class SearchInputTests extends ESTestCase {
|
|||
ArgumentCaptor<SearchRequest> requestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
|
||||
PlainActionFuture<SearchResponse> searchFuture = PlainActionFuture.newFuture();
|
||||
SearchResponse searchResponse = new SearchResponse(InternalSearchResponse.empty(), "", 1, 1, 0, 1234,
|
||||
ShardSearchFailure.EMPTY_ARRAY);
|
||||
ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY);
|
||||
searchFuture.onResponse(searchResponse);
|
||||
when(client.search(requestCaptor.capture())).thenReturn(searchFuture);
|
||||
|
||||
|
|
Loading…
Reference in New Issue