Fix testCorruptedIndex (#38161)
Folks at the Lucene project do not seem to be interested in classifying corruptions and distinguishing them from file-system exceptions (see https://issues.apache.org/jira/browse/LUCENE-8525), so we'll just cop out as well. Closes #34322
This commit is contained in:
parent
e18cac3659
commit
ce469cfda5
|
@ -71,6 +71,8 @@ public class TruncateTranslogAction {
|
|||
commits = DirectoryReader.listCommits(indexDirectory);
|
||||
} catch (IndexNotFoundException infe) {
|
||||
throw new ElasticsearchException("unable to find a valid shard at [" + indexPath + "]", infe);
|
||||
} catch (IOException e) {
|
||||
throw new ElasticsearchException("unable to list commits at [" + indexPath + "]", e);
|
||||
}
|
||||
|
||||
// Retrieve the generation and UUID from the existing data
|
||||
|
|
|
@ -56,6 +56,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.either;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -174,7 +175,7 @@ public class RemoveCorruptedShardDataCommandTests extends IndexShardTestCase {
|
|||
fail();
|
||||
} catch (ElasticsearchException e) {
|
||||
if (corruptSegments) {
|
||||
assertThat(e.getMessage(), is("Index is unrecoverable"));
|
||||
assertThat(e.getMessage(), either(is("Index is unrecoverable")).or(startsWith("unable to list commits")));
|
||||
} else {
|
||||
assertThat(e.getMessage(), containsString("aborted by user"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue