Manually Craft CreateSnapshotRequest to fix BwC Test (#57661) (#57715)

We can't use the high level create snapshot request any longer
since we changed some of its default parameters in `8` and those
are not understood by older versions like `7.4`.

Closes #57650
This commit is contained in:
Armin Braun 2020-06-05 15:49:44 +02:00 committed by GitHub
parent c75c8b6e9d
commit 8805c1f112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -21,7 +21,6 @@ package org.elasticsearch.upgrades;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
@ -291,7 +290,11 @@ public class MultiVersionRepositoryAccessIT extends ESRestTestCase {
}
private static void createSnapshot(RestHighLevelClient client, String repoName, String name, String index) throws IOException {
client.snapshot().create(new CreateSnapshotRequest(repoName, name).waitForCompletion(true).indices(index), RequestOptions.DEFAULT);
final Request createSnapshotRequest = new Request("PUT", "/_snapshot/" + repoName + "/" + name);
createSnapshotRequest.addParameter("wait_for_completion", "true");
createSnapshotRequest.setJsonEntity("{ \"indices\" : \"" + index + "\"}");
final Response response = client.getLowLevelClient().performRequest(createSnapshotRequest);
assertThat(response.getStatusLine().getStatusCode(), is(HttpURLConnection.HTTP_OK));
}
private void createIndex(RestHighLevelClient client, String name, int shards) throws IOException {