[TEST] only assert consistency before closing
This commit is contained in:
parent
60eaeb5052
commit
7a6fb892c9
|
@ -473,8 +473,12 @@ public class Store extends AbstractIndexShardComponent implements CloseableIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
private void innerClose() throws IOException {
|
private void innerClose() throws IOException {
|
||||||
assert DistributorDirectory.assertConsistency(logger, distributorDirectory);
|
try {
|
||||||
super.close();
|
assert DistributorDirectory.assertConsistency(logger, distributorDirectory);
|
||||||
|
} finally {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.ThreadedIndexingAndSearchingTestCase;
|
import org.apache.lucene.index.ThreadedIndexingAndSearchingTestCase;
|
||||||
import org.apache.lucene.search.IndexSearcher;
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.FilterDirectory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
|
@ -125,8 +126,7 @@ public class DistributorInTheWildTest extends ThreadedIndexingAndSearchingTestCa
|
||||||
if (random().nextBoolean() && dir instanceof MockDirectoryWrapper) {
|
if (random().nextBoolean() && dir instanceof MockDirectoryWrapper) {
|
||||||
return ((MockDirectoryWrapper) dir).getOpenDeletedFiles();
|
return ((MockDirectoryWrapper) dir).getOpenDeletedFiles();
|
||||||
}
|
}
|
||||||
DistributorDirectory d = dir instanceof MockDirectoryWrapper ? (DistributorDirectory)((MockDirectoryWrapper) dir).getDelegate() : (DistributorDirectory) dir;
|
DistributorDirectory d = DirectoryUtils.getLeaf(dir, DistributorDirectory.class, null);
|
||||||
assertTrue(DistributorDirectory.assertConsistency(logger, d));
|
|
||||||
Distributor distributor = d.getDistributor();
|
Distributor distributor = d.getDistributor();
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
for (Directory subDir : distributor.all()) {
|
for (Directory subDir : distributor.all()) {
|
||||||
|
@ -151,11 +151,19 @@ public class DistributorInTheWildTest extends ThreadedIndexingAndSearchingTestCa
|
||||||
for (Directory dir : directories) {
|
for (Directory dir : directories) {
|
||||||
((MockDirectoryWrapper) dir).setCheckIndexOnClose(false);
|
((MockDirectoryWrapper) dir).setCheckIndexOnClose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
FilterDirectory distributorDirectory = new FilterDirectory(new DistributorDirectory(directories)) {
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
assertTrue(DistributorDirectory.assertConsistency(logger, (DistributorDirectory) this.getDelegate()));
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
return new MockDirectoryWrapper(random(), new DistributorDirectory(directories));
|
return new MockDirectoryWrapper(random(), distributorDirectory);
|
||||||
} else {
|
} else {
|
||||||
return new DistributorDirectory(directories);
|
return distributorDirectory;
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
|
Loading…
Reference in New Issue