Skip to content

Commit

Permalink
Fix IndexSnapshotsServiceIT and SnapshotsRecoveryPlannerServiceTests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcofdez committed Aug 11, 2021
1 parent d8e30cf commit d41d912
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ public void testPlannerTriesToUseMostFilesFromSnapshots() throws Exception {
new ShardSnapshotsService(null, null, null, null) {
@Override
public void fetchLatestSnapshotsForShard(ShardId shardId, ActionListener<Optional<ShardSnapshot>> 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
Expand Down

0 comments on commit d41d912

Please sign in to comment.