-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more logging when failing watch history entry fails. #50931
Merged
martijnvg
merged 3 commits into
elastic:master
from
martijnvg:SmokeTestWatcherWithSecurityIT_more_logging
Jan 16, 2020
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,39 +305,58 @@ private ObjectPath getWatchHistoryEntry(String watchId) throws Exception { | |
|
||
private ObjectPath getWatchHistoryEntry(String watchId, String state) throws Exception { | ||
final AtomicReference<ObjectPath> objectPathReference = new AtomicReference<>(); | ||
assertBusy(() -> { | ||
client().performRequest(new Request("POST", "/.watcher-history-*/_refresh")); | ||
|
||
try (XContentBuilder builder = jsonBuilder()) { | ||
builder.startObject(); | ||
builder.startObject("query").startObject("bool").startArray("must"); | ||
builder.startObject().startObject("term").startObject("watch_id").field("value", watchId).endObject().endObject() | ||
try { | ||
assertBusy(() -> { | ||
client().performRequest(new Request("POST", "/.watcher-history-*/_refresh")); | ||
|
||
try (XContentBuilder builder = jsonBuilder()) { | ||
builder.startObject(); | ||
builder.startObject("query").startObject("bool").startArray("must"); | ||
builder.startObject().startObject("term").startObject("watch_id").field("value", watchId).endObject().endObject() | ||
.endObject(); | ||
if (Strings.isNullOrEmpty(state) == false) { | ||
builder.startObject().startObject("term").startObject("state").field("value", state).endObject().endObject() | ||
if (Strings.isNullOrEmpty(state) == false) { | ||
builder.startObject().startObject("term").startObject("state").field("value", state).endObject().endObject() | ||
.endObject(); | ||
} | ||
builder.endArray().endObject().endObject(); | ||
builder.startArray("sort").startObject().startObject("trigger_event.triggered_time").field("order", "desc").endObject() | ||
} | ||
builder.endArray().endObject().endObject(); | ||
builder.startArray("sort").startObject().startObject("trigger_event.triggered_time").field("order", "desc").endObject() | ||
.endObject().endArray(); | ||
builder.endObject(); | ||
|
||
Request searchRequest = new Request("POST", "/.watcher-history-*/_search"); | ||
searchRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true"); | ||
searchRequest.setJsonEntity(Strings.toString(builder)); | ||
Response response = client().performRequest(searchRequest); | ||
ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
int totalHits = objectPath.evaluate("hits.total"); | ||
assertThat(totalHits, is(greaterThanOrEqualTo(1))); | ||
String watchid = objectPath.evaluate("hits.hits.0._source.watch_id"); | ||
assertThat(watchid, is(watchId)); | ||
objectPathReference.set(objectPath); | ||
} catch (ResponseException e) { | ||
final String err = "Failed to perform search of watcher history"; | ||
logger.info(err, e); | ||
fail(err); | ||
builder.endObject(); | ||
|
||
Request searchRequest = new Request("POST", "/.watcher-history-*/_search"); | ||
searchRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true"); | ||
searchRequest.setJsonEntity(Strings.toString(builder)); | ||
Response response = client().performRequest(searchRequest); | ||
ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
int totalHits = objectPath.evaluate("hits.total"); | ||
assertThat(totalHits, is(greaterThanOrEqualTo(1))); | ||
String watchid = objectPath.evaluate("hits.hits.0._source.watch_id"); | ||
assertThat(watchid, is(watchId)); | ||
objectPathReference.set(objectPath); | ||
} catch (ResponseException e) { | ||
final String err = "Failed to perform search of watcher history"; | ||
logger.info(err, e); | ||
fail(err); | ||
} | ||
}); | ||
} catch (AssertionError ae) { | ||
{ | ||
Request request = new Request("GET", "/_watcher/stats"); | ||
Response response = client().performRequest(request); | ||
logger.info("watcher_stats: {}", EntityUtils.toString(response.getEntity())); | ||
} | ||
}); | ||
{ | ||
Request request = new Request("GET", "/_cluster/state"); | ||
Response response = client().performRequest(request); | ||
logger.info("cluster_state: {}", EntityUtils.toString(response.getEntity())); | ||
} | ||
{ | ||
Request request = new Request("GET", "/.watcher-history-*/_search"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this fails and is stuck for during the assertBusy, may result in alot of .watcher_history... should we increase the default size ? |
||
Response response = client().performRequest(request); | ||
logger.info("watcher_history_snippets: {}", EntityUtils.toString(response.getEntity())); | ||
} | ||
throw ae; | ||
} | ||
return objectPathReference.get(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want add
metric=_all
to include current and queued watches.