Add more logging when failing watch history entry fails. (#50931)
Relates to #30777
This commit is contained in:
parent
76660a5a4f
commit
7af0474101
|
@ -308,22 +308,23 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
|
|
||||||
private ObjectPath getWatchHistoryEntry(String watchId, String state) throws Exception {
|
private ObjectPath getWatchHistoryEntry(String watchId, String state) throws Exception {
|
||||||
final AtomicReference<ObjectPath> objectPathReference = new AtomicReference<>();
|
final AtomicReference<ObjectPath> objectPathReference = new AtomicReference<>();
|
||||||
assertBusy(() -> {
|
try {
|
||||||
client().performRequest(new Request("POST", "/.watcher-history-*/_refresh"));
|
assertBusy(() -> {
|
||||||
|
client().performRequest(new Request("POST", "/.watcher-history-*/_refresh"));
|
||||||
|
|
||||||
try (XContentBuilder builder = jsonBuilder()) {
|
try (XContentBuilder builder = jsonBuilder()) {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.startObject("query").startObject("bool").startArray("must");
|
builder.startObject("query").startObject("bool").startArray("must");
|
||||||
builder.startObject().startObject("term").startObject("watch_id").field("value", watchId).endObject().endObject()
|
builder.startObject().startObject("term").startObject("watch_id").field("value", watchId).endObject().endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
if (Strings.isNullOrEmpty(state) == false) {
|
if (Strings.isNullOrEmpty(state) == false) {
|
||||||
builder.startObject().startObject("term").startObject("state").field("value", state).endObject().endObject()
|
builder.startObject().startObject("term").startObject("state").field("value", state).endObject().endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
}
|
}
|
||||||
builder.endArray().endObject().endObject();
|
builder.endArray().endObject().endObject();
|
||||||
builder.startArray("sort").startObject().startObject("trigger_event.triggered_time").field("order", "desc").endObject()
|
builder.startArray("sort").startObject().startObject("trigger_event.triggered_time").field("order", "desc").endObject()
|
||||||
.endObject().endArray();
|
.endObject().endArray();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
Request searchRequest = new Request("POST", "/.watcher-history-*/_search");
|
Request searchRequest = new Request("POST", "/.watcher-history-*/_search");
|
||||||
searchRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
|
searchRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
|
||||||
|
@ -336,7 +337,43 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
assertThat(watchid, is(watchId));
|
assertThat(watchid, is(watchId));
|
||||||
objectPathReference.set(objectPath);
|
objectPathReference.set(objectPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (AssertionError ae) {
|
||||||
|
{
|
||||||
|
Request request = new Request("GET", "/_watcher/stats");
|
||||||
|
request.addParameter("metric", "_all");
|
||||||
|
request.addParameter("pretty", "true");
|
||||||
|
try {
|
||||||
|
Response response = client().performRequest(request);
|
||||||
|
logger.info("watcher_stats: {}", EntityUtils.toString(response.getEntity()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("error while fetching watcher_stats", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Request request = new Request("GET", "/_cluster/state");
|
||||||
|
request.addParameter("pretty", "true");
|
||||||
|
try {
|
||||||
|
Response response = client().performRequest(request);
|
||||||
|
logger.info("cluster_state: {}", EntityUtils.toString(response.getEntity()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("error while fetching cluster_state", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Request request = new Request("GET", "/.watcher-history-*/_search");
|
||||||
|
request.addParameter("size", "100");
|
||||||
|
request.addParameter("sort", "trigger_event.triggered_time:desc");
|
||||||
|
request.addParameter("pretty", "true");
|
||||||
|
try {
|
||||||
|
Response response = client().performRequest(request);
|
||||||
|
logger.info("watcher_history_snippets: {}", EntityUtils.toString(response.getEntity()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("error while fetching watcher_history_snippets", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw ae;
|
||||||
|
}
|
||||||
return objectPathReference.get();
|
return objectPathReference.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue