matchedInProgress = currentSnapshots(repositoryName, Collections.emptyList()).stream()
- .filter(s -> s.snapshot().getSnapshotId().getName().equals(snapshotName)).findFirst();
+ .filter(s -> snNames.contains(s.snapshot().getSnapshotId().getName())).findAny();
if (matchedInProgress.isPresent()) {
- matchedEntry = matchedInProgress.map(s -> s.snapshot().getSnapshotId());
+ matchedEntry.add(matchedInProgress.map(s -> s.snapshot().getSnapshotId()).get());
// Derive repository generation if a snapshot is in progress because it will increment the generation when it finishes
repoGenId = matchedInProgress.get().repositoryStateId() + 1L;
}
+
+ if (matchedEntry.isEmpty()) {
+ throw new SnapshotMissingException(repositoryName, snNames.toString());
}
- if (matchedEntry.isPresent() == false) {
- throw new SnapshotMissingException(repositoryName, snapshotName);
- }
- deleteSnapshot(new Snapshot(repositoryName, matchedEntry.get()), listener, repoGenId, immediatePriority);
+ deleteSnapshots(matchedEntry, listener, repositoryName, repoGenId, immediatePriority);
}, listener::onFailure));
}
@@ -1188,28 +1190,28 @@ public void deleteSnapshot(final String repositoryName, final String snapshotNam
*
* If the snapshot is still running cancels the snapshot first and then deletes it from the repository.
*
- * @param snapshot snapshot
+ * @param snapshots snapshots
* @param listener listener
* @param repositoryStateId the unique id for the state of the repository
*/
- private void deleteSnapshot(final Snapshot snapshot, final ActionListener listener, final long repositoryStateId,
- final boolean immediatePriority) {
- logger.info("deleting snapshot [{}]", snapshot);
+ private void deleteSnapshots(Collection snapshots, ActionListener listener, String repository,
+ long repositoryStateId, boolean immediatePriority) {
+ logger.info("deleting snapshots {} from [{}]", snapshots, repository);
Priority priority = immediatePriority ? Priority.IMMEDIATE : Priority.NORMAL;
clusterService.submitStateUpdateTask("delete snapshot", new ClusterStateUpdateTask(priority) {
- boolean waitForSnapshot = false;
+ Snapshot waitForSnapshot;
@Override
public ClusterState execute(ClusterState currentState) {
SnapshotDeletionsInProgress deletionsInProgress = currentState.custom(SnapshotDeletionsInProgress.TYPE);
if (deletionsInProgress != null && deletionsInProgress.hasDeletionsInProgress()) {
- throw new ConcurrentSnapshotExecutionException(snapshot,
+ throw new ConcurrentSnapshotExecutionException(repository, snapshots,
"cannot delete - another snapshot is currently being deleted in [" + deletionsInProgress + "]");
}
final RepositoryCleanupInProgress repositoryCleanupInProgress = currentState.custom(RepositoryCleanupInProgress.TYPE);
if (repositoryCleanupInProgress != null && repositoryCleanupInProgress.hasCleanupInProgress()) {
- throw new ConcurrentSnapshotExecutionException(snapshot.getRepository(), snapshot.getSnapshotId().getName(),
+ throw new ConcurrentSnapshotExecutionException(repository, snapshots,
"cannot delete snapshot while a repository cleanup is in-progress in [" + repositoryCleanupInProgress + "]");
}
RestoreInProgress restoreInProgress = currentState.custom(RestoreInProgress.TYPE);
@@ -1218,34 +1220,50 @@ public ClusterState execute(ClusterState currentState) {
// otherwise we could end up deleting a snapshot that is being restored
// and the files the restore depends on would all be gone
if (restoreInProgress.isEmpty() == false) {
- throw new ConcurrentSnapshotExecutionException(snapshot,
+ throw new ConcurrentSnapshotExecutionException(repository, snapshots,
"cannot delete snapshot during a restore in progress in [" + restoreInProgress + "]");
}
}
ClusterState.Builder clusterStateBuilder = ClusterState.builder(currentState);
- SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE);
- SnapshotsInProgress.Entry snapshotEntry = snapshots != null ? snapshots.snapshot(snapshot) : null;
+ SnapshotsInProgress snapshotsInProgress = currentState.custom(SnapshotsInProgress.TYPE);
+ final SnapshotsInProgress.Entry snapshotEntry;
+ if (snapshotsInProgress != null) {
+ assert snapshotsInProgress.entries().size() <= 1 :
+ "Assumed one or no snapshot ongoing but saw [" + snapshotsInProgress + "]";
+ snapshotEntry = snapshots.stream()
+ .filter(sn -> snapshotsInProgress.snapshot(new Snapshot(repository, sn)) != null)
+ .findFirst().map(sn -> snapshotsInProgress.snapshot(new Snapshot(repository, sn)))
+ .orElse(null);
+ } else {
+ snapshotEntry = null;
+ }
if (snapshotEntry == null) {
// This snapshot is not running - delete
- if (snapshots != null && !snapshots.entries().isEmpty()) {
+ if (snapshotsInProgress != null && !snapshotsInProgress.entries().isEmpty()) {
// However other snapshots are running - cannot continue
- throw new ConcurrentSnapshotExecutionException(snapshot, "another snapshot is currently running cannot delete");
+ throw new ConcurrentSnapshotExecutionException(repository, snapshots,
+ "another snapshot is currently running cannot delete");
}
- // add the snapshot deletion to the cluster state
- SnapshotDeletionsInProgress.Entry entry = new SnapshotDeletionsInProgress.Entry(
- snapshot,
- threadPool.absoluteTimeInMillis(),
- repositoryStateId
- );
- if (deletionsInProgress != null) {
- deletionsInProgress = deletionsInProgress.withAddedEntry(entry);
- } else {
- deletionsInProgress = SnapshotDeletionsInProgress.newInstance(entry);
+ for (SnapshotId snapshot : snapshots) {
+ // add the snapshot deletion to the cluster state
+ SnapshotDeletionsInProgress.Entry entry = new SnapshotDeletionsInProgress.Entry(
+ new Snapshot(repository, snapshot),
+ threadPool.absoluteTimeInMillis(),
+ repositoryStateId
+ );
+ if (deletionsInProgress != null) {
+ if (deletionsInProgress.getEntries().stream().noneMatch(
+ e -> e.getSnapshot().getSnapshotId().equals(snapshot))) {
+ deletionsInProgress = deletionsInProgress.withAddedEntry(entry);
+ }
+ } else {
+ deletionsInProgress = SnapshotDeletionsInProgress.newInstance(entry);
+ }
}
clusterStateBuilder.putCustom(SnapshotDeletionsInProgress.TYPE, deletionsInProgress);
} else {
// This snapshot is currently running - stopping shards first
- waitForSnapshot = true;
+ waitForSnapshot = snapshotEntry.snapshot();
final ImmutableOpenMap shards;
@@ -1305,16 +1323,17 @@ public void onFailure(String source, Exception e) {
@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
- if (waitForSnapshot) {
+ if (waitForSnapshot != null) {
logger.trace("adding snapshot completion listener to wait for deleted snapshot to finish");
- addListener(snapshot, ActionListener.wrap(
+ addListener(waitForSnapshot, ActionListener.wrap(
snapshotInfo -> {
logger.debug("deleted snapshot completed - deleting files");
threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() -> {
try {
- deleteSnapshot(snapshot.getRepository(), snapshot.getSnapshotId().getName(), listener, true);
+ deleteSnapshots(waitForSnapshot.getRepository(),
+ snapshots.stream().map(SnapshotId::getName).toArray(String[]::new), listener, true);
} catch (Exception ex) {
- logger.warn(() -> new ParameterizedMessage("[{}] failed to delete snapshot", snapshot), ex);
+ logger.warn(() -> new ParameterizedMessage("[{}] failed to delete snapshot", waitForSnapshot), ex);
}
}
);
@@ -1323,12 +1342,14 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
logger.warn("deleted snapshot failed - deleting files", e);
threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() -> {
try {
- deleteSnapshot(snapshot.getRepository(), snapshot.getSnapshotId().getName(), listener, true);
+ deleteSnapshots(
+ waitForSnapshot.getRepository(),
+ snapshots.stream().map(SnapshotId::getName).toArray(String[]::new), listener, true);
} catch (SnapshotMissingException smex) {
logger.info(() -> new ParameterizedMessage(
"Tried deleting in-progress snapshot [{}], but it could not be found after failing to abort.",
smex.getSnapshotName()), e);
- listener.onFailure(new SnapshotException(snapshot,
+ listener.onFailure(new SnapshotException(waitForSnapshot,
"Tried deleting in-progress snapshot [" + smex.getSnapshotName() + "], but it " +
"could not be found after failing to abort.", smex));
}
@@ -1337,7 +1358,8 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
));
} else {
logger.debug("deleted snapshot is not running - deleting files");
- deleteSnapshotFromRepository(snapshot, listener, repositoryStateId, newState.nodes().getMinNodeVersion());
+ deleteSnapshotsFromRepository(
+ snapshots, listener, repositoryStateId, repository, newState.nodes().getMinNodeVersion());
}
}
});
@@ -1381,20 +1403,21 @@ public static boolean isRepositoryInUse(ClusterState clusterState, String reposi
/**
* Deletes snapshot from repository
*
- * @param snapshot snapshot
- * @param listener listener
+ * @param snapshots snapshot
+ * @param listener listener
* @param repositoryStateId the unique id representing the state of the repository at the time the deletion began
* @param version minimum ES version the repository should be readable by
*/
- private void deleteSnapshotFromRepository(Snapshot snapshot, @Nullable ActionListener listener, long repositoryStateId,
- Version version) {
+ private void deleteSnapshotsFromRepository(Collection snapshots, @Nullable ActionListener listener,
+ long repositoryStateId, String repositoryName, Version version) {
threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(ActionRunnable.wrap(listener, l -> {
- Repository repository = repositoriesService.repository(snapshot.getRepository());
- repository.deleteSnapshot(snapshot.getSnapshotId(), repositoryStateId, version.onOrAfter(SHARD_GEN_IN_REPO_DATA_VERSION),
+ Repository repository = repositoriesService.repository(repositoryName);
+ repository.deleteSnapshot(snapshots, repositoryStateId,
+ version.onOrAfter(SHARD_GEN_IN_REPO_DATA_VERSION),
ActionListener.wrap(v -> {
- logger.info("snapshot [{}] deleted", snapshot);
- removeSnapshotDeletionFromClusterState(snapshot, null, l);
- }, ex -> removeSnapshotDeletionFromClusterState(snapshot, ex, l)
+ logger.info("snapshots {} deleted", snapshots);
+ removeSnapshotDeletionFromClusterState(snapshots, null, l);
+ }, ex -> removeSnapshotDeletionFromClusterState(snapshots, ex, l)
));
}));
}
@@ -1402,8 +1425,8 @@ private void deleteSnapshotFromRepository(Snapshot snapshot, @Nullable ActionLis
/**
* Removes the snapshot deletion from {@link SnapshotDeletionsInProgress} in the cluster state.
*/
- private void removeSnapshotDeletionFromClusterState(final Snapshot snapshot, @Nullable final Exception failure,
- @Nullable final ActionListener listener) {
+ private void removeSnapshotDeletionFromClusterState(Collection snapshots, @Nullable Exception failure,
+ @Nullable ActionListener listener) {
clusterService.submitStateUpdateTask("remove snapshot deletion metadata", new ClusterStateUpdateTask() {
@Override
public ClusterState execute(ClusterState currentState) {
@@ -1411,10 +1434,11 @@ public ClusterState execute(ClusterState currentState) {
if (deletions != null) {
boolean changed = false;
if (deletions.hasDeletionsInProgress()) {
- assert deletions.getEntries().size() == 1 : "should have exactly one deletion in progress";
- SnapshotDeletionsInProgress.Entry entry = deletions.getEntries().get(0);
- deletions = deletions.withRemovedEntry(entry);
- changed = true;
+ for (SnapshotDeletionsInProgress.Entry entry : deletions.getEntries().stream()
+ .filter(e -> snapshots.contains(e.getSnapshot().getSnapshotId())).collect(Collectors.toList())) {
+ changed = true;
+ deletions = deletions.withRemovedEntry(entry);
+ }
}
if (changed) {
return ClusterState.builder(currentState).putCustom(SnapshotDeletionsInProgress.TYPE, deletions).build();
@@ -1425,7 +1449,7 @@ public ClusterState execute(ClusterState currentState) {
@Override
public void onFailure(String source, Exception e) {
- logger.warn(() -> new ParameterizedMessage("[{}] failed to remove snapshot deletion metadata", snapshot), e);
+ logger.warn(() -> new ParameterizedMessage("{} failed to remove snapshot deletion metadata", snapshots), e);
if (listener != null) {
listener.onFailure(e);
}
diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
index 05ff6567aa58d..797826203057e 100644
--- a/server/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
+++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/snapshots/SnapshotBlocksIT.java
@@ -124,7 +124,8 @@ public void testDeleteSnapshotWithBlocks() {
logger.info("--> deleting a snapshot is allowed when the cluster is read only");
try {
setClusterReadOnly(true);
- assertTrue(client().admin().cluster().prepareDeleteSnapshot(REPOSITORY_NAME, SNAPSHOT_NAME).get().isAcknowledged());
+ assertTrue(
+ client().admin().cluster().prepareDeleteSnapshots(REPOSITORY_NAME, new String[]{SNAPSHOT_NAME}).get().isAcknowledged());
} finally {
setClusterReadOnly(false);
}
diff --git a/server/src/test/java/org/elasticsearch/repositories/RepositoriesServiceTests.java b/server/src/test/java/org/elasticsearch/repositories/RepositoriesServiceTests.java
index 2daa4afe3e149..1402e5ec19207 100644
--- a/server/src/test/java/org/elasticsearch/repositories/RepositoriesServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/repositories/RepositoriesServiceTests.java
@@ -47,6 +47,7 @@
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -163,7 +164,8 @@ public void finalizeSnapshot(SnapshotId snapshotId, ShardGenerations indices, lo
}
@Override
- public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener listener) {
+ public void deleteSnapshot(Collection snapshotId, long repositoryStateId, boolean writeShardGens,
+ ActionListener listener) {
listener.onResponse(null);
}
diff --git a/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java b/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java
index 12adfb49120a7..9a63aa610a02b 100644
--- a/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java
+++ b/server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java
@@ -66,7 +66,8 @@ public void testIndicesToUpdateAfterRemovingSnapshot() {
final Set snapshotIds = repositoryData.getSnapshots(index);
return snapshotIds.contains(randomSnapshot) && snapshotIds.size() > 1;
}).toArray(IndexId[]::new);
- assertThat(repositoryData.indicesToUpdateAfterRemovingSnapshot(randomSnapshot), containsInAnyOrder(indicesToUpdate));
+ assertThat(repositoryData.indicesToUpdateAfterRemovingSnapshot(
+ Collections.singleton(randomSnapshot)), containsInAnyOrder(indicesToUpdate));
}
public void testXContent() throws IOException {
@@ -148,7 +149,7 @@ public void testRemoveSnapshot() {
List snapshotIds = new ArrayList<>(repositoryData.getSnapshotIds());
assertThat(snapshotIds.size(), greaterThan(0));
SnapshotId removedSnapshotId = snapshotIds.remove(randomIntBetween(0, snapshotIds.size() - 1));
- RepositoryData newRepositoryData = repositoryData.removeSnapshot(removedSnapshotId, ShardGenerations.EMPTY);
+ RepositoryData newRepositoryData = repositoryData.removeSnapshot(Collections.singleton(removedSnapshotId), ShardGenerations.EMPTY);
// make sure the repository data's indices no longer contain the removed snapshot
for (final IndexId indexId : newRepositoryData.getIndices().values()) {
assertFalse(newRepositoryData.getSnapshots(indexId).contains(removedSnapshotId));
diff --git a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java
index 13102182cd7b0..9c2ee15932b8b 100644
--- a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java
+++ b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java
@@ -182,7 +182,7 @@ public void testIndexGenerationalFiles() throws Exception {
// removing a snapshot and writing to a new index generational file
repositoryData = ESBlobStoreRepositoryIntegTestCase.getRepositoryData(repository).removeSnapshot(
- repositoryData.getSnapshotIds().iterator().next(), ShardGenerations.EMPTY);
+ Collections.singleton(repositoryData.getSnapshotIds().iterator().next()), ShardGenerations.EMPTY);
writeIndexGen(repository, repositoryData, repositoryData.getGenId());
assertEquals(ESBlobStoreRepositoryIntegTestCase.getRepositoryData(repository), repositoryData);
assertThat(repository.latestIndexBlobId(), equalTo(expectedGeneration + 2L));
diff --git a/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
index ab5aebe853b9e..86f4bb737d7ea 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
@@ -474,7 +474,7 @@ public void testSnapshotWithStuckNode() throws Exception {
logger.info("--> execution was blocked on node [{}], aborting snapshot", blockedNode);
ActionFuture deleteSnapshotResponseFuture = internalCluster().client(nodes.get(0))
- .admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap").execute();
+ .admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap"}).execute();
// Make sure that abort makes some progress
Thread.sleep(100);
unblockNode("test-repo", blockedNode);
@@ -1156,7 +1156,7 @@ public void testSnapshotTotalAndIncrementalSizes() throws IOException {
// drop 1st one to avoid miscalculation as snapshot reuses some files of prev snapshot
assertTrue(client.admin().cluster()
- .prepareDeleteSnapshot(repositoryName, snapshot0)
+ .prepareDeleteSnapshots(repositoryName, new String[]{snapshot0})
.get().isAcknowledged());
response = client.admin().cluster().prepareSnapshotStatus(repositoryName)
diff --git a/server/src/test/java/org/elasticsearch/snapshots/MetadataLoadingDuringSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/MetadataLoadingDuringSnapshotRestoreIT.java
index 3d65782d4824d..3bb6f24f46abb 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/MetadataLoadingDuringSnapshotRestoreIT.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/MetadataLoadingDuringSnapshotRestoreIT.java
@@ -139,7 +139,7 @@ public void testWhenMetadataAreLoaded() throws Exception {
assertIndexMetadataLoads("snap", "others", 3);
// Deleting a snapshot does not load the global metadata state but loads each index metadata
- assertAcked(client().admin().cluster().prepareDeleteSnapshot("repository", "snap").get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots("repository", new String[]{"snap"}).get());
assertGlobalMetadataLoads("snap", 1);
assertIndexMetadataLoads("snap", "docs", 4);
assertIndexMetadataLoads("snap", "others", 3);
diff --git a/server/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java
index e93bb00d3d09e..9ef7800303442 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java
@@ -84,13 +84,13 @@ public void testConcurrentSnapshotDeletionsNotAllowed() throws Exception {
((MockRepository)internalCluster().getInstance(RepositoriesService.class, blockedNode).repository(repo)).blockOnDataFiles(true);
logger.info("--> start deletion of first snapshot");
ActionFuture future =
- client().admin().cluster().prepareDeleteSnapshot(repo, snapshot2).execute();
+ client().admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot2}).execute();
logger.info("--> waiting for block to kick in on node [{}]", blockedNode);
waitForBlock(blockedNode, repo, TimeValue.timeValueSeconds(10));
logger.info("--> try deleting the second snapshot, should fail because the first deletion is in progress");
try {
- client().admin().cluster().prepareDeleteSnapshot(repo, snapshot1).get();
+ client().admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot1}).get();
fail("should not be able to delete snapshots concurrently");
} catch (ConcurrentSnapshotExecutionException e) {
assertThat(e.getMessage(), containsString("cannot delete - another snapshot is currently being deleted"));
@@ -103,7 +103,7 @@ public void testConcurrentSnapshotDeletionsNotAllowed() throws Exception {
assertAcked(future.actionGet());
logger.info("--> delete second snapshot, which should now work");
- client().admin().cluster().prepareDeleteSnapshot(repo, snapshot1).get();
+ client().admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot1}).get();
assertTrue(client().admin().cluster().prepareGetSnapshots(repo).setSnapshots("_all").get().getSnapshots(repo).isEmpty());
}
@@ -129,7 +129,8 @@ public void testSnapshottingWithInProgressDeletionNotAllowed() throws Exception
String blockedNode = internalCluster().getMasterName();
((MockRepository)internalCluster().getInstance(RepositoriesService.class, blockedNode).repository(repo)).blockOnDataFiles(true);
logger.info("--> start deletion of snapshot");
- ActionFuture future = client().admin().cluster().prepareDeleteSnapshot(repo, snapshot1).execute();
+ ActionFuture future =
+ client().admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot1}).execute();
logger.info("--> waiting for block to kick in on node [{}]", blockedNode);
waitForBlock(blockedNode, repo, TimeValue.timeValueSeconds(10));
@@ -184,7 +185,8 @@ public void testRestoreWithInProgressDeletionsNotAllowed() throws Exception {
String blockedNode = internalCluster().getMasterName();
((MockRepository)internalCluster().getInstance(RepositoriesService.class, blockedNode).repository(repo)).blockOnDataFiles(true);
logger.info("--> start deletion of snapshot");
- ActionFuture future = client().admin().cluster().prepareDeleteSnapshot(repo, snapshot2).execute();
+ ActionFuture future =
+ client().admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot2}).execute();
logger.info("--> waiting for block to kick in on node [{}]", blockedNode);
waitForBlock(blockedNode, repo, TimeValue.timeValueSeconds(10));
diff --git a/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
index e31ad37296093..6b6567792a128 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
@@ -1300,8 +1300,14 @@ public void testDeleteSnapshot() throws Exception {
int numberOfFilesBeforeDeletion = numberOfFiles(repo);
logger.info("--> delete all snapshots except the first one and last one");
- for (int i = 1; i < numberOfSnapshots - 1; i++) {
- client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-" + i).get();
+
+ if (randomBoolean()) {
+ for (int i = 1; i < numberOfSnapshots - 1; i++) {
+ client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap-" + i}).get();
+ }
+ } else {
+ client.admin().cluster().prepareDeleteSnapshots(
+ "test-repo", IntStream.range(1, numberOfSnapshots - 1).mapToObj(i -> "test-snap-" + i).toArray(String[]::new)).get();
}
int numberOfFilesAfterDeletion = numberOfFiles(repo);
@@ -1320,7 +1326,7 @@ public void testDeleteSnapshot() throws Exception {
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits().value, equalTo(10L * numberOfSnapshots));
logger.info("--> delete the last snapshot");
- client.admin().cluster().prepareDeleteSnapshot("test-repo", lastSnapshot).get();
+ client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{lastSnapshot}).get();
logger.info("--> make sure that number of files is back to what it was when the first snapshot was made");
assertFileCount(repo, numberOfFiles[0]);
}
@@ -1465,7 +1471,7 @@ public void testDeleteSnapshotWithMissingIndexAndShardMetadata() throws Exceptio
}
logger.info("--> delete snapshot");
- client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();
+ client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap-1"}).get();
logger.info("--> make sure snapshot doesn't exist");
@@ -1506,7 +1512,7 @@ public void testDeleteSnapshotWithMissingMetadata() throws Exception {
Files.delete(metadata);
logger.info("--> delete snapshot");
- client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();
+ client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap-1"}).get();
logger.info("--> make sure snapshot doesn't exist");
expectThrows(SnapshotMissingException.class, () -> client.admin().cluster().prepareGetSnapshots("test-repo")
@@ -1543,7 +1549,7 @@ public void testDeleteSnapshotWithCorruptedSnapshotFile() throws Exception {
outChan.truncate(randomInt(10));
}
logger.info("--> delete snapshot");
- client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();
+ client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap-1"}).get();
logger.info("--> make sure snapshot doesn't exist");
expectThrows(SnapshotMissingException.class,
@@ -1604,7 +1610,7 @@ public void testDeleteSnapshotWithCorruptedGlobalState() throws Exception {
assertThat(snapshotStatusResponse.getSnapshots(), hasSize(1));
assertThat(snapshotStatusResponse.getSnapshots().get(0).getSnapshot().getSnapshotId().getName(), equalTo("test-snap"));
- assertAcked(client().admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap").get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots("test-repo", new String[]{"test-snap"}).get());
expectThrows(SnapshotMissingException.class, () -> client().admin().cluster()
.prepareGetSnapshots("test-repo").addSnapshots("test-snap").get().getSnapshots("test-repo"));
assertThrows(client().admin().cluster().prepareSnapshotStatus("test-repo").addSnapshots("test-snap"),
@@ -2018,8 +2024,8 @@ public void testReadonlyRepository() throws Exception {
assertThat(getSnapshotsResponse.getSnapshots("readonly-repo").size(), equalTo(1));
logger.info("--> try deleting snapshot");
- assertThrows(client.admin().cluster().prepareDeleteSnapshot("readonly-repo", "test-snap"), RepositoryException.class,
- "cannot delete snapshot from a readonly repository");
+ assertThrows(client.admin().cluster().prepareDeleteSnapshots("readonly-repo", new String[]{"test-snap"}),
+ RepositoryException.class, "cannot delete snapshot from a readonly repository");
logger.info("--> try making another snapshot");
assertThrows(client.admin().cluster().prepareCreateSnapshot("readonly-repo", "test-snap-2")
@@ -2713,14 +2719,14 @@ public void testDeleteSnapshotWhileRestoringFails() throws Exception {
logger.info("--> try deleting the snapshot while the restore is in progress (should throw an error)");
ConcurrentSnapshotExecutionException e = expectThrows(ConcurrentSnapshotExecutionException.class, () ->
- client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).get());
+ client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{snapshotName}).get());
assertEquals(repoName, e.getRepositoryName());
assertEquals(snapshotName, e.getSnapshotName());
assertThat(e.getMessage(), containsString("cannot delete snapshot during a restore"));
logger.info("-- try deleting another snapshot while the restore is in progress (should throw an error)");
e = expectThrows(ConcurrentSnapshotExecutionException.class, () ->
- client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName2).get());
+ client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{snapshotName2}).get());
assertEquals(repoName, e.getRepositoryName());
assertEquals(snapshotName2, e.getSnapshotName());
assertThat(e.getMessage(), containsString("cannot delete snapshot during a restore"));
@@ -2759,7 +2765,7 @@ public void testSnapshotName() throws Exception {
() -> client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("_foo")
.get().getSnapshots("test-repo"));
expectThrows(SnapshotMissingException.class,
- () -> client.admin().cluster().prepareDeleteSnapshot("test-repo", "_foo").get());
+ () -> client.admin().cluster().prepareDeleteSnapshots("test-repo", new String[] {"_foo"}).get());
expectThrows(SnapshotMissingException.class,
() -> client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("_foo").get());
}
@@ -2958,7 +2964,8 @@ public void testRestoreSnapshotWithCorruptedIndexMetadata() throws Exception {
}
}
- assertAcked(client().admin().cluster().prepareDeleteSnapshot("test-repo", snapshotInfo.snapshotId().getName()).get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots("test-repo",
+ new String[]{snapshotInfo.snapshotId().getName()}).get());
}
/**
@@ -3103,7 +3110,7 @@ public void testCannotCreateSnapshotsWithSameName() throws Exception {
}
logger.info("--> delete the first snapshot");
- client.admin().cluster().prepareDeleteSnapshot(repositoryName, snapshotName).get();
+ client.admin().cluster().prepareDeleteSnapshots(repositoryName, new String[]{snapshotName}).get();
logger.info("--> try creating a snapshot with the same name, now it should work because the first one was deleted");
createSnapshotResponse = client.admin()
@@ -3172,7 +3179,7 @@ public void testGetSnapshotsRequest() throws Exception {
assertEquals("snap-on-empty-repo", getSnapshotsResponse.getSnapshots("test-repo").get(0).snapshotId().getName());
unblockNode(repositoryName, initialBlockedNode); // unblock node
responseListener.actionGet(TimeValue.timeValueMillis(10000L)); // timeout after 10 seconds
- client.admin().cluster().prepareDeleteSnapshot(repositoryName, "snap-on-empty-repo").get();
+ client.admin().cluster().prepareDeleteSnapshots(repositoryName, new String[]{"snap-on-empty-repo"}).get();
final int numSnapshots = randomIntBetween(1, 3) + 1;
logger.info("--> take {} snapshot(s)", numSnapshots - 1);
@@ -3839,7 +3846,7 @@ public void testSnapshotDifferentIndicesBySameName() {
expectedCount = docCount;
}
logger.info("--> deleting snapshot [{}]", snapshotToDelete);
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotToDelete).get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{snapshotToDelete}).get());
logger.info("--> restoring snapshot [{}]", snapshotToRestore);
client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotToRestore).setIndices(indexName).setRenamePattern(indexName)
.setRenameReplacement("restored-3").setWaitForCompletion(true).get();
diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
index 28d2beb2efcc4..3a8ed1203273f 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
@@ -40,7 +40,7 @@
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.create.TransportCreateSnapshotAction;
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotAction;
-import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotsRequest;
import org.elasticsearch.action.admin.cluster.snapshots.delete.TransportDeleteSnapshotAction;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotAction;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
@@ -408,8 +408,8 @@ public void testConcurrentSnapshotCreateAndDelete() {
final StepListener deleteSnapshotStepListener = new StepListener<>();
- continueOrDie(createSnapshotResponseStepListener, createSnapshotResponse -> client().admin().cluster().deleteSnapshot(
- new DeleteSnapshotRequest(repoName, snapshotName), deleteSnapshotStepListener));
+ continueOrDie(createSnapshotResponseStepListener, createSnapshotResponse -> client().admin().cluster().deleteSnapshots(
+ new DeleteSnapshotsRequest(repoName, snapshotName), deleteSnapshotStepListener));
final StepListener createAnotherSnapshotResponseStepListener = new StepListener<>();
@@ -460,8 +460,8 @@ public void testConcurrentSnapshotCreateAndDeleteOther() {
final StepListener deleteSnapshotStepListener = new StepListener<>();
continueOrDie(createOtherSnapshotResponseStepListener,
- createSnapshotResponse -> client().admin().cluster().deleteSnapshot(
- new DeleteSnapshotRequest(repoName, snapshotName), ActionListener.wrap(
+ createSnapshotResponse -> client().admin().cluster().deleteSnapshots(
+ new DeleteSnapshotsRequest(repoName, snapshotName), ActionListener.wrap(
resp -> deleteSnapshotStepListener.onResponse(true),
e -> {
final Throwable unwrapped =
@@ -546,8 +546,8 @@ public void run() {
testClusterNodes.randomDataNodeSafe().client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName)
.execute(ActionListener.wrap(() -> {
createdSnapshot.set(true);
- testClusterNodes.randomDataNodeSafe().client.admin().cluster().deleteSnapshot(
- new DeleteSnapshotRequest(repoName, snapshotName), noopListener());
+ testClusterNodes.randomDataNodeSafe().client.admin().cluster().deleteSnapshots(
+ new DeleteSnapshotsRequest(repoName, snapshotName), noopListener());
}));
scheduleNow(
() -> testClusterNodes.randomMasterNodeSafe().client.admin().cluster().reroute(
diff --git a/test/framework/src/main/java/org/elasticsearch/index/shard/RestoreOnlyRepository.java b/test/framework/src/main/java/org/elasticsearch/index/shard/RestoreOnlyRepository.java
index f0118d3c0b699..41a5994367ba0 100644
--- a/test/framework/src/main/java/org/elasticsearch/index/shard/RestoreOnlyRepository.java
+++ b/test/framework/src/main/java/org/elasticsearch/index/shard/RestoreOnlyRepository.java
@@ -38,6 +38,7 @@
import org.elasticsearch.snapshots.SnapshotShardFailure;
import java.io.IOException;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -101,7 +102,8 @@ public void finalizeSnapshot(SnapshotId snapshotId, ShardGenerations shardGenera
}
@Override
- public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener listener) {
+ public void deleteSnapshot(Collection snapshotId, long repositoryStateId, boolean writeShardGens,
+ ActionListener listener) {
listener.onResponse(null);
}
diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java
index c6e76ac7174ed..276350adc23f4 100644
--- a/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java
@@ -21,7 +21,7 @@
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryResponse;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
-import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotsRequest;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.blobstore.BlobMetaData;
@@ -131,7 +131,7 @@ public void testCreateSnapshot() {
assertTrue(client().admin()
.cluster()
- .prepareDeleteSnapshot("test-repo", snapshotName)
+ .prepareDeleteSnapshots("test-repo", new String[]{snapshotName})
.get()
.isAcknowledged());
}
@@ -216,7 +216,7 @@ public void testCleanup() throws Exception {
createDanglingIndex(repo, genericExec);
logger.info("--> deleting a snapshot to trigger repository cleanup");
- client().admin().cluster().deleteSnapshot(new DeleteSnapshotRequest("test-repo", snapshotName)).actionGet();
+ client().admin().cluster().deleteSnapshots(new DeleteSnapshotsRequest("test-repo", snapshotName)).actionGet();
assertConsistentRepository(repo, genericExec);
diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java
index ccf3853ebe64b..68a17c913b29f 100644
--- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java
@@ -151,13 +151,13 @@ public void testSnapshotAndRestore() throws Exception {
}
logger.info("--> delete snapshot {}:{}", repoName, snapshotName);
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{snapshotName}).get());
expectThrows(SnapshotMissingException.class, () ->
client().admin().cluster().prepareGetSnapshots(repoName).setSnapshots(snapshotName).get().getSnapshots(repoName));
expectThrows(SnapshotMissingException.class, () ->
- client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).get());
+ client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{snapshotName}).get());
expectThrows(SnapshotRestoreException.class, () ->
client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(randomBoolean()).get());
@@ -214,7 +214,7 @@ public void testMultipleSnapshotAndRollback() throws Exception {
for (int i = 0; i < iterationCount; i++) {
logger.info("--> delete snapshot {}:{}", repoName, snapshotName + "-" + i);
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName + "-" + i).get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repoName, new String[] {snapshotName + "-" + i}).get());
}
}
@@ -252,7 +252,7 @@ public void testIndicesDeletedFromRepository() throws Exception {
assertEquals(createSnapshotResponse.getSnapshotInfo().successfulShards(), createSnapshotResponse.getSnapshotInfo().totalShards());
logger.info("--> delete a snapshot");
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "test-snap").get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{"test-snap"}).get());
logger.info("--> verify index folder deleted from blob container");
RepositoriesService repositoriesSvc = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
@@ -272,7 +272,7 @@ public void testIndicesDeletedFromRepository() throws Exception {
}
}
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "test-snap2").get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repoName, new String[]{"test-snap2"}).get());
}
protected void addRandomDocuments(String name, int numDocs) throws InterruptedException {
diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java
index 03f89125ad979..d1bea24c05ea8 100644
--- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java
@@ -150,7 +150,7 @@ public final void testSnapshotWithLargeSegmentFiles() throws Exception {
ensureGreen(index);
assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs);
- assertAcked(client().admin().cluster().prepareDeleteSnapshot(repository, snapshot).get());
+ assertAcked(client().admin().cluster().prepareDeleteSnapshots(repository, new String[]{snapshot}).get());
}
protected static String httpServerUrl() {
diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java
index 20c098ee7f82a..f82c050356624 100644
--- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java
+++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java
@@ -82,6 +82,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -255,7 +256,8 @@ public void finalizeSnapshot(SnapshotId snapshotId, ShardGenerations shardGenera
}
@Override
- public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener listener) {
+ public void deleteSnapshot(Collection snapshotId, long repositoryStateId, boolean writeShardGens,
+ ActionListener listener) {
throw new UnsupportedOperationException("Unsupported for repository of type: " + TYPE);
}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java
index 25de192e76d04..ef58295863582 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SnapshotRetentionTask.java
@@ -388,7 +388,7 @@ void deleteSnapshot(String slmPolicy, String repo, SnapshotId snapshot, Snapshot
ActionListener listener) {
logger.info("[{}] snapshot retention deleting snapshot [{}]", repo, snapshot);
CountDownLatch latch = new CountDownLatch(1);
- client.admin().cluster().prepareDeleteSnapshot(repo, snapshot.getName())
+ client.admin().cluster().prepareDeleteSnapshots(repo, new String[]{snapshot.getName()})
.execute(new LatchedActionListener<>(new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java
index 7c7a555a8d5d9..20fd6c6745c4d 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java
@@ -119,7 +119,7 @@ public void testSnapshotInProgress() throws Exception {
// Cancel/delete the snapshot
try {
- client().admin().cluster().prepareDeleteSnapshot(REPO, snapshotName).get();
+ client().admin().cluster().prepareDeleteSnapshots(REPO, new String[]{snapshotName}).get();
} catch (SnapshotMissingException e) {
// ignore
}
@@ -223,7 +223,7 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
assertBusy(() -> {
try {
logger.info("--> cancelling snapshot {}", secondSnapName);
- client().admin().cluster().prepareDeleteSnapshot(REPO, secondSnapName).get();
+ client().admin().cluster().prepareDeleteSnapshots(REPO, new String[]{secondSnapName}).get();
} catch (ConcurrentSnapshotExecutionException e) {
logger.info("--> attempted to stop second snapshot", e);
// just wait and retry
diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java
index 520d495101fdc..34a7350d029fe 100644
--- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java
+++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java
@@ -126,7 +126,8 @@ public void testSnapshotUserRoleUnathorizedForDestructiveActions() {
() -> client.admin().cluster().prepareRestoreSnapshot("repo", randomAlphaOfLength(4).toLowerCase(Locale.ROOT)).get(),
"cluster:admin/snapshot/restore", "snapshot_user");
assertThrowsAuthorizationException(
- () -> client.admin().cluster().prepareDeleteSnapshot("repo", randomAlphaOfLength(4).toLowerCase(Locale.ROOT)).get(),
+ () -> client.admin().cluster().prepareDeleteSnapshots("repo",
+ new String[]{randomAlphaOfLength(4).toLowerCase(Locale.ROOT)}).get(),
"cluster:admin/snapshot/delete", "snapshot_user");
// try destructive/revealing actions on all indices
for (final String indexToTest : Arrays.asList(INTERNAL_SECURITY_MAIN_INDEX_7, SECURITY_MAIN_ALIAS, ordinaryIndex)) {
diff --git a/x-pack/snapshot-tool/src/test/java/org/elasticsearch/snapshots/AbstractCleanupTests.java b/x-pack/snapshot-tool/src/test/java/org/elasticsearch/snapshots/AbstractCleanupTests.java
index f51ee07ce56ed..f065307ca1355 100644
--- a/x-pack/snapshot-tool/src/test/java/org/elasticsearch/snapshots/AbstractCleanupTests.java
+++ b/x-pack/snapshot-tool/src/test/java/org/elasticsearch/snapshots/AbstractCleanupTests.java
@@ -262,12 +262,12 @@ public void testCleanup() throws Throwable {
logger.info("--> perform cleanup by removing snapshots");
assertTrue(client().admin()
.cluster()
- .prepareDeleteSnapshot("test-repo", "snap1")
+ .prepareDeleteSnapshots("test-repo", new String[]{"snap1"})
.get()
.isAcknowledged());
assertTrue(client().admin()
.cluster()
- .prepareDeleteSnapshot("test-repo", "snap2")
+ .prepareDeleteSnapshots("test-repo", new String[]{"snap2"})
.get()
.isAcknowledged());
}