[TEST] Fix per-segment / per-commit exclude logic in CorruptFileTest

This commit is contained in:
Simon Willnauer 2014-08-29 11:43:48 +02:00
parent b2827a09a9
commit 88aec9e3c0
1 changed files with 13 additions and 4 deletions

View File

@ -464,10 +464,10 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
files.addAll(Arrays.asList(file.listFiles(new FileFilter() { files.addAll(Arrays.asList(file.listFiles(new FileFilter() {
@Override @Override
public boolean accept(File pathname) { public boolean accept(File pathname) {
return pathname.isFile() && !"write.lock".equals(pathname.getName()) && if (pathname.isFile() && "write.lock".equals(pathname.getName()) == false) {
(includePerCommitFiles == true // .del and segments_N are per commit files and might change after corruption return (includePerCommitFiles || isPerSegmentFile(pathname.getName()));
|| pathname.getName().startsWith("segments") == false }
|| pathname.getName().endsWith(".del") == false); return false; // no dirs no write.locks
} }
}))); })));
} }
@ -514,6 +514,15 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
return shardRouting; return shardRouting;
} }
private static final boolean isPerCommitFile(String fileName) {
// .del and segments_N are per commit files and might change after corruption
return fileName.startsWith("segments") || fileName.endsWith(".del");
}
private static final boolean isPerSegmentFile(String fileName) {
return isPerCommitFile(fileName) == false;
}
/** /**
* prunes the list of index files such that only the latest del generation files are contained. * prunes the list of index files such that only the latest del generation files are contained.
*/ */