Skip to content

Wrap ResponseException in AssertionError in ILM/CCR tests #48489

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -108,7 +109,6 @@ public void testBasicCCRAndILMIntegration() throws Exception {
}
}

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48461")
public void testCCRUnfollowDuringSnapshot() throws Exception {
String indexName = "unfollow-test-index";
if ("leader".equals(targetCluster)) {
Expand Down Expand Up @@ -746,10 +746,27 @@ private static Object getIndexSetting(RestClient client, String index, String se
return settings.get(setting);
}

private static void assertDocumentExists(RestClient client, String index, String id) throws IOException {
Request request = new Request("HEAD", "/" + index + "/_doc/" + id);
Response response = client.performRequest(request);
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
private void assertDocumentExists(RestClient client, String index, String id) throws IOException {
Request request = new Request("GET", "/" + index + "/_doc/" + id);
Response response;
try {
response = client.performRequest(request);
if (response.getStatusLine().getStatusCode() != 200) {
if (response.getEntity() != null) {
logger.error(EntityUtils.toString(response.getEntity()));
} else {
logger.error("response body was null");
}
fail("HTTP response code expected to be [200] but was [" + response.getStatusLine().getStatusCode() + "]");
}
} catch (ResponseException ex) {
if (ex.getResponse().getEntity() != null) {
logger.error(EntityUtils.toString(ex.getResponse().getEntity()), ex);
} else {
logger.error("response body was null");
}
fail("HTTP response code expected to be [200] but was [" + ex.getResponse().getStatusLine().getStatusCode() + "]");
}
}

private void createNewSingletonPolicy(String policyName, String phaseName, LifecycleAction action, TimeValue after) throws IOException {
Expand Down