|
8 | 8 | import org.apache.lucene.index.DirectoryReader;
|
9 | 9 | import org.apache.lucene.index.FilterDirectoryReader;
|
10 | 10 | import org.apache.lucene.index.NoMergePolicy;
|
| 11 | +import org.apache.lucene.search.IndexSearcher; |
11 | 12 | import org.apache.lucene.search.MatchAllDocsQuery;
|
12 | 13 | import org.apache.lucene.search.ReferenceManager;
|
13 | 14 | import org.apache.lucene.search.TopDocs;
|
|
33 | 34 | import java.util.concurrent.atomic.AtomicInteger;
|
34 | 35 | import java.util.concurrent.atomic.AtomicLong;
|
35 | 36 |
|
| 37 | +import static org.hamcrest.Matchers.equalTo; |
| 38 | + |
36 | 39 | public class FrozenEngineTests extends EngineTestCase {
|
37 | 40 |
|
38 | 41 | public void testAcquireReleaseReset() throws IOException {
|
@@ -321,4 +324,32 @@ public void testCanMatch() throws IOException {
|
321 | 324 | }
|
322 | 325 | }
|
323 | 326 | }
|
| 327 | + |
| 328 | + public void testSearchers() throws Exception { |
| 329 | + IOUtils.close(engine, store); |
| 330 | + final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); |
| 331 | + try (Store store = createStore()) { |
| 332 | + EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, null, |
| 333 | + globalCheckpoint::get, new NoneCircuitBreakerService()); |
| 334 | + final int totalDocs; |
| 335 | + try (InternalEngine engine = createEngine(config)) { |
| 336 | + applyOperations(engine, generateHistoryOnReplica(between(10, 1000), false, randomBoolean(), randomBoolean())); |
| 337 | + globalCheckpoint.set(engine.getLocalCheckpoint()); |
| 338 | + engine.syncTranslog(); |
| 339 | + engine.flush(); |
| 340 | + engine.refresh("test"); |
| 341 | + try (Engine.Searcher engineSearcher = engine.acquireSearcher("test")) { |
| 342 | + final IndexSearcher searcher = new IndexSearcher(engineSearcher.getDirectoryReader()); |
| 343 | + totalDocs = searcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs.length; |
| 344 | + } |
| 345 | + } |
| 346 | + try (FrozenEngine frozenEngine = new FrozenEngine(config)) { |
| 347 | + try (Engine.Searcher engineSearcher = frozenEngine.acquireSearcher("test")) { |
| 348 | + IndexSearcher searcher = new IndexSearcher(engineSearcher.getDirectoryReader()); |
| 349 | + TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE); |
| 350 | + assertThat(topDocs.scoreDocs.length, equalTo(totalDocs)); |
| 351 | + } |
| 352 | + } |
| 353 | + } |
| 354 | + } |
324 | 355 | }
|
0 commit comments