Skip to content

Commit

Permalink
Dump recovery if fail to get doc count with preference (#40168)
Browse files Browse the repository at this point in the history
With this change, we will dump the recovery state if we fail to get doc
count for a given index with a preference in rolling upgrade tests. We
should have more information to look into why the provided preference is
not valid. I also unmuted `testRelocationWithConcurrentIndexing` in this
change.

Relates #34950
  • Loading branch information
dnhatn committed Mar 19, 2019
1 parent 85bb5a7 commit d588647
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.upgrades;

import org.apache.http.util.EntityUtils;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.Request;
Expand Down Expand Up @@ -171,14 +172,27 @@ public void testRecoveryWithConcurrentIndexing() throws Exception {
}

private void assertCount(final String index, final String preference, final int expectedCount) throws IOException {
final Request request = new Request("GET", index + "/_count");
request.addParameter("preference", preference);
final Response response = client().performRequest(request);
final int actualCount = Integer.parseInt(ObjectPath.createFromResponse(response).evaluate("count").toString());
assertThat("preference [" + preference + "]", actualCount, equalTo(expectedCount));
final int actualDocs;
try {
final Request request = new Request("GET", index + "/_count");
if (preference != null) {
request.addParameter("preference", preference);
}
final Response response = client().performRequest(request);
actualDocs = Integer.parseInt(ObjectPath.createFromResponse(response).evaluate("count").toString());
} catch (ResponseException e) {
try {
final Response recoveryStateResponse = client().performRequest(new Request("GET", index + "/_recovery"));
fail("failed to get doc count for index [" + index + "] with preference [" + preference + "]" + " response [" + e + "]"
+ " recovery [" + EntityUtils.toString(recoveryStateResponse.getEntity()) + "]");
} catch (Exception inner) {
e.addSuppressed(inner);
}
throw e;
}
assertThat("preference [" + preference + "]", actualDocs, equalTo(expectedCount));
}


private String getNodeId(Predicate<Version> versionPredicate) throws IOException {
Response response = client().performRequest(new Request("GET", "_nodes"));
ObjectPath objectPath = ObjectPath.createFromResponse(response);
Expand All @@ -192,7 +206,6 @@ private String getNodeId(Predicate<Version> versionPredicate) throws IOException
return null;
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/34950")
public void testRelocationWithConcurrentIndexing() throws Exception {
final String index = "relocation_with_concurrent_indexing";
switch (CLUSTER_TYPE) {
Expand Down

0 comments on commit d588647

Please sign in to comment.