Skip to content

Commit

Permalink
Remove Outdated GetSnapshots BwC Handling in Rest Tests (#74734)
Browse files Browse the repository at this point in the history
The group-by-repository response format is gone as a result of #74451
=> cleaning up its last remnants from REST tests.
  • Loading branch information
original-brownbear authored Jun 30, 2021
1 parent 4fa1c8d commit eca5735
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1052,13 +1052,7 @@ private void assertClosedIndex(final String index, final boolean checkRoutingTab
private void checkSnapshot(final String snapshotName, final int count, final Version tookOnVersion) throws IOException {
// Check the snapshot metadata, especially the version
Request listSnapshotRequest = new Request("GET", "/_snapshot/repo/" + snapshotName);
Map<String, Object> responseMap = entityAsMap(client().performRequest(listSnapshotRequest));
Map<String, Object> snapResponse;
if (responseMap.get("responses") != null) {
snapResponse = (Map<String, Object>) ((List<Object>) responseMap.get("responses")).get(0);
} else {
snapResponse = responseMap;
}
Map<String, Object> snapResponse = entityAsMap(client().performRequest(listSnapshotRequest));

assertEquals(singletonList(snapshotName), XContentMapValues.extractValue("snapshots.snapshot", snapResponse));
assertEquals(singletonList("SUCCESS"), XContentMapValues.extractValue("snapshots.state", snapResponse));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,7 @@ private List<Map<String, Object>> listSnapshots(String repoName) throws IOExcept
new Request("GET", "/_snapshot/" + repoName + "/_all")).getEntity().getContent();
XContentParser parser = JsonXContent.jsonXContent.createParser(
xContentRegistry(), DeprecationHandler.THROW_UNSUPPORTED_OPERATION, entity)) {
final Map<String, Object> raw = parser.map();
// Bwc lookup since the format of the snapshots response changed between versions
if (raw.containsKey("snapshots")) {
return (List<Map<String, Object>>) raw.get("snapshots");
} else {
return (List<Map<String, Object>>) ((List<Map<?, ?>>) raw.get("responses")).get(0).get("snapshots");
}
return (List<Map<String, Object>>) parser.map().get("snapshots");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,15 +840,7 @@ protected void wipeSearchableSnapshotsIndices() throws IOException {
Request listRequest = new Request("GET", "/_snapshot/" + repoName + "/_all");
listRequest.addParameter("ignore_unavailable", "true");

Map<?, ?> response = entityAsMap(adminClient.performRequest(listRequest));
Map<?, ?> oneRepoResponse;
if (response.containsKey("responses")) {
oneRepoResponse = ((Map<?,?>)((List<?>) response.get("responses")).get(0));
} else {
oneRepoResponse = response;
}

List<?> snapshots = (List<?>) oneRepoResponse.get("snapshots");
List<?> snapshots = (List<?>) entityAsMap(adminClient.performRequest(listRequest)).get("snapshots");
for (Object snapshot : snapshots) {
Map<?, ?> snapshotInfo = (Map<?, ?>) snapshot;
String name = (String) snapshotInfo.get("snapshot");
Expand Down

0 comments on commit eca5735

Please sign in to comment.