Skip to content

Commit eca5735

Browse files
Remove Outdated GetSnapshots BwC Handling in Rest Tests (#74734)
The group-by-repository response format is gone as a result of #74451 => cleaning up its last remnants from REST tests.
1 parent 4fa1c8d commit eca5735

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,7 @@ private void assertClosedIndex(final String index, final boolean checkRoutingTab
10521052
private void checkSnapshot(final String snapshotName, final int count, final Version tookOnVersion) throws IOException {
10531053
// Check the snapshot metadata, especially the version
10541054
Request listSnapshotRequest = new Request("GET", "/_snapshot/repo/" + snapshotName);
1055-
Map<String, Object> responseMap = entityAsMap(client().performRequest(listSnapshotRequest));
1056-
Map<String, Object> snapResponse;
1057-
if (responseMap.get("responses") != null) {
1058-
snapResponse = (Map<String, Object>) ((List<Object>) responseMap.get("responses")).get(0);
1059-
} else {
1060-
snapResponse = responseMap;
1061-
}
1055+
Map<String, Object> snapResponse = entityAsMap(client().performRequest(listSnapshotRequest));
10621056

10631057
assertEquals(singletonList(snapshotName), XContentMapValues.extractValue("snapshots.snapshot", snapResponse));
10641058
assertEquals(singletonList("SUCCESS"), XContentMapValues.extractValue("snapshots.state", snapResponse));

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,7 @@ private List<Map<String, Object>> listSnapshots(String repoName) throws IOExcept
261261
new Request("GET", "/_snapshot/" + repoName + "/_all")).getEntity().getContent();
262262
XContentParser parser = JsonXContent.jsonXContent.createParser(
263263
xContentRegistry(), DeprecationHandler.THROW_UNSUPPORTED_OPERATION, entity)) {
264-
final Map<String, Object> raw = parser.map();
265-
// Bwc lookup since the format of the snapshots response changed between versions
266-
if (raw.containsKey("snapshots")) {
267-
return (List<Map<String, Object>>) raw.get("snapshots");
268-
} else {
269-
return (List<Map<String, Object>>) ((List<Map<?, ?>>) raw.get("responses")).get(0).get("snapshots");
270-
}
264+
return (List<Map<String, Object>>) parser.map().get("snapshots");
271265
}
272266
}
273267

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -840,15 +840,7 @@ protected void wipeSearchableSnapshotsIndices() throws IOException {
840840
Request listRequest = new Request("GET", "/_snapshot/" + repoName + "/_all");
841841
listRequest.addParameter("ignore_unavailable", "true");
842842

843-
Map<?, ?> response = entityAsMap(adminClient.performRequest(listRequest));
844-
Map<?, ?> oneRepoResponse;
845-
if (response.containsKey("responses")) {
846-
oneRepoResponse = ((Map<?,?>)((List<?>) response.get("responses")).get(0));
847-
} else {
848-
oneRepoResponse = response;
849-
}
850-
851-
List<?> snapshots = (List<?>) oneRepoResponse.get("snapshots");
843+
List<?> snapshots = (List<?>) entityAsMap(adminClient.performRequest(listRequest)).get("snapshots");
852844
for (Object snapshot : snapshots) {
853845
Map<?, ?> snapshotInfo = (Map<?, ?>) snapshot;
854846
String name = (String) snapshotInfo.get("snapshot");

0 commit comments

Comments
 (0)