diff --git a/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java index bfc73e629e6b9..d69d0b562abcd 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java @@ -207,10 +207,11 @@ public void testGetShardSnapshotFailureHandlingLetOtherRepositoriesRequestsMakeP createIndexWithContent(indexName); int snapshotIdx = 0; - createSnapshot(failingRepoName, "empty-snap-" + snapshotIdx++, Collections.singletonList(indexName)); + createSnapshot(failingRepoName, String.format(Locale.ROOT, "snap-%03d", snapshotIdx++), Collections.singletonList(indexName)); SnapshotInfo latestSnapshot = null; for (String workingRepoName : workingRepoNames) { - latestSnapshot = createSnapshot(workingRepoName, "empty-snap-" + snapshotIdx++, Collections.singletonList(indexName)); + String snapshot = String.format(Locale.ROOT, "snap-%03d", snapshotIdx++); + latestSnapshot = createSnapshot(workingRepoName, snapshot, Collections.singletonList(indexName)); } final MockRepository repository = getRepositoryOnMaster(failingRepoName); @@ -264,7 +265,8 @@ public void testGetShardSnapshotInMultipleRepositoriesReturnsTheLatestSnapshot() int snapshotIdx = 0; SnapshotInfo expectedLatestSnapshot = null; for (String repository : repositories) { - expectedLatestSnapshot = createSnapshot(repository, "snap-" + snapshotIdx++, Collections.singletonList(indexName)); + String snapshot = String.format(Locale.ROOT, "snap-%03d", snapshotIdx++); + expectedLatestSnapshot = createSnapshot(repository, snapshot, Collections.singletonList(indexName)); } GetShardSnapshotResponse response = getLatestSnapshotForShardFuture(repositories, indexName, 0).actionGet(); diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java b/server/src/test/java/org/elasticsearch/indices/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java index b8156e4c2d0a0..6d00b3a931ef1 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java @@ -258,7 +258,11 @@ public void testPlannerTriesToUseMostFilesFromSnapshots() throws Exception { new ShardSnapshotsService(null, null, null, null) { @Override public void fetchLatestSnapshotsForShard(ShardId shardId, ActionListener> listener) { - listener.onResponse(Optional.of(availableSnapshots.get(availableSnapshots.size() - 1))); + if (availableSnapshots.isEmpty()) { + listener.onResponse(Optional.empty()); + } else { + listener.onResponse(Optional.of(availableSnapshots.get(availableSnapshots.size() - 1))); + } } }, true