There is a small chance that the file deletion will run on the searchable snapshot thread pool and not on the test thread now that the cache is non-blocking in which case we fail the assertion unless we wait for that thread.
This commit is contained in:
parent
adc5509eda
commit
17843a40ef
|
@ -481,6 +481,7 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
|||
final ShardId shardId = new ShardId(indexSettings.getIndex(), randomIntBetween(0, 10));
|
||||
final List<Releasable> releasables = new ArrayList<>();
|
||||
|
||||
final ThreadPool threadPool = new TestThreadPool(getTestName(), SearchableSnapshots.executorBuilders());
|
||||
try (Directory directory = newDirectory()) {
|
||||
final IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
|
||||
try (IndexWriter writer = new IndexWriter(directory, indexWriterConfig)) {
|
||||
|
@ -507,9 +508,6 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
|||
writer.commit();
|
||||
}
|
||||
|
||||
final ThreadPool threadPool = new TestThreadPool(getTestName(), SearchableSnapshots.executorBuilders());
|
||||
releasables.add(() -> terminate(threadPool));
|
||||
|
||||
final Store store = new Store(shardId, indexSettings, directory, new DummyShardLock(shardId));
|
||||
store.incRef();
|
||||
releasables.add(store::decRef);
|
||||
|
@ -628,6 +626,8 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
|||
} finally {
|
||||
Releasables.close(releasables);
|
||||
}
|
||||
} finally {
|
||||
terminate(threadPool);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,7 +740,7 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
|||
assertListOfFiles(cacheDir, allOf(greaterThan(0), lessThanOrEqualTo(nbRandomFiles)), greaterThan(0L));
|
||||
if (randomBoolean()) {
|
||||
directory.clearCache();
|
||||
assertListOfFiles(cacheDir, equalTo(0), equalTo(0L));
|
||||
assertBusy(() -> assertListOfFiles(cacheDir, equalTo(0), equalTo(0L)));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue