Fix SearchableSnapshotDirectoryTests#testRecoveryStateIsKeptOpenAfterPreWarmFailure (#61343)
The test didn't take into account the case where 0 documents are indexed into the shard, meaning that files aren't loaded during the pre-warm phase. The test injects FileSystem failures, if the snapshot doesn't contain any files, pre-warm doesn't read any files and the recovery completes normally. Closes #61295 Backport of #61317
This commit is contained in:
parent
1182248994
commit
89a7f32100
|
@ -776,7 +776,16 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
|||
try {
|
||||
SearchableSnapshotRecoveryState recoveryState = createRecoveryState();
|
||||
testDirectories(true, true, recoveryState, Settings.EMPTY, (directory, snapshotDirectory) -> {
|
||||
assertBusy(() -> assertThat(recoveryState.getStage(), equalTo(RecoveryState.Stage.FINALIZE)));
|
||||
boolean areAllFilesReused = snapshotDirectory.snapshot()
|
||||
.indexFiles()
|
||||
.stream()
|
||||
.allMatch(fileInfo -> fileInfo.metadata().hashEqualsContents());
|
||||
assertBusy(() -> {
|
||||
// When the number of indexed documents == 0, the index snapshot only contains the
|
||||
// commit file, meaning that the recovery won't fail in that case.
|
||||
RecoveryState.Stage expectedStage = areAllFilesReused ? RecoveryState.Stage.DONE : RecoveryState.Stage.FINALIZE;
|
||||
assertThat(recoveryState.getStage(), equalTo(expectedStage));
|
||||
});
|
||||
// All pre-warm tasks failed
|
||||
assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0L));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue