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:
Yannick Welsch 2019-02-01 12:51:38 +01:00 committed by GitHub
parent e18cac3659
commit ce469cfda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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"));
}