[TEST] handle failed search requests differently

This commit is contained in:
Martijn van Groningen 2018-09-18 15:55:16 +02:00
parent 8e0d74adad
commit 9fe5a273aa
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
2 changed files with 13 additions and 6 deletions

View File

@ -274,11 +274,14 @@ public class FollowIndexSecurityIT extends ESRestTestCase {
} }
private static void verifyCcrMonitoring(String expectedLeaderIndex, String expectedFollowerIndex) throws IOException { private static void verifyCcrMonitoring(String expectedLeaderIndex, String expectedFollowerIndex) throws IOException {
ensureYellow(".monitoring-*");
Request request = new Request("GET", "/.monitoring-*/_search"); Request request = new Request("GET", "/.monitoring-*/_search");
request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}"); request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}");
Map<String, ?> response = toMap(adminClient().performRequest(request)); Map<String, ?> response;
try {
response = toMap(adminClient().performRequest(request));
} catch (ResponseException e) {
throw new AssertionError("error while searching", e);
}
int numberOfOperationsReceived = 0; int numberOfOperationsReceived = 0;
int numberOfOperationsIndexed = 0; int numberOfOperationsIndexed = 0;

View File

@ -9,6 +9,7 @@ import org.apache.http.HttpHost;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request; import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response; import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
@ -160,11 +161,14 @@ public class FollowIndexIT extends ESRestTestCase {
} }
private static void verifyCcrMonitoring(final String expectedLeaderIndex, final String expectedFollowerIndex) throws IOException { private static void verifyCcrMonitoring(final String expectedLeaderIndex, final String expectedFollowerIndex) throws IOException {
ensureYellow(".monitoring-*");
Request request = new Request("GET", "/.monitoring-*/_search"); Request request = new Request("GET", "/.monitoring-*/_search");
request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}"); request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}");
Map<String, ?> response = toMap(client().performRequest(request)); Map<String, ?> response;
try {
response = toMap(client().performRequest(request));
} catch (ResponseException e) {
throw new AssertionError("error while searching", e);
}
int numberOfOperationsReceived = 0; int numberOfOperationsReceived = 0;
int numberOfOperationsIndexed = 0; int numberOfOperationsIndexed = 0;