Skip to content

Remove Outdated GetSnapshots BwC Handling in Rest Tests #74734

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
Show file tree
Hide file tree
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 @@ -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