Skip to content

Commit

Permalink
Retry response exceptions in the test.
Browse files Browse the repository at this point in the history
Relates to #30777
  • Loading branch information
martijnvg committed Jan 27, 2020
1 parent 7e0f73e commit e253b7e
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -320,17 +321,21 @@ private ObjectPath getWatchHistoryEntry(String watchId, String state) throws Exc
.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);
}
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);
throw new AssertionError(err, e);
}
});
} catch (AssertionError ae) {
{
Expand Down

0 comments on commit e253b7e

Please sign in to comment.