浏览代码

Manually Craft CreateSnapshotRequest to fix BwC Test (#57661)

* Manually Craft CreateSnapshotRequest to fix BwC Test

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
Armin Braun 5 年之前
父节点
当前提交
a86fceebe6

+ 5 - 4
qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java

@@ -19,10 +19,8 @@
 
 package org.elasticsearch.upgrades;
 
-import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
 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.restore.RestoreSnapshotRequest;
 import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
@@ -65,7 +63,6 @@ import static org.hamcrest.Matchers.is;
  *     <li>Run against the current version cluster from the second step: {@link TestStep#STEP4_NEW_CLUSTER}</li>
  * </ul>
  */
-@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/57650")
 public class MultiVersionRepositoryAccessIT extends ESRestTestCase {
 
     private enum TestStep {
@@ -290,7 +287,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 {