|
29 | 29 | import java.nio.file.Path; |
30 | 30 | import java.util.Comparator; |
31 | 31 |
|
| 32 | +import static org.hamcrest.Matchers.equalTo; |
32 | 33 | import static org.hamcrest.Matchers.greaterThan; |
33 | 34 | import static org.hamcrest.Matchers.notNullValue; |
34 | 35 | import static org.junit.Assert.assertEquals; |
35 | 36 | import static org.junit.Assert.assertThat; |
36 | 37 |
|
37 | 38 | public class LeafSorterOptimizationTests extends EngineTestCase { |
38 | 39 |
|
39 | | - public void testReadOnlyEngineUsesLeafSorter() throws IOException { |
| 40 | + public void testReadOnlyEngineConfiguresLeafSorter() throws IOException { |
40 | 41 | Path translogPath = createTempDir(); |
41 | 42 | try (Store store = createStore()) { |
42 | 43 | store.createEmpty(Version.CURRENT.luceneVersion); |
@@ -145,27 +146,13 @@ public void testReadOnlyEngineUsesLeafSorter() throws IOException { |
145 | 146 | // Always verify we have at least one leaf |
146 | 147 | assertThat("Should have at least one leaf", reader.leaves().size(), greaterThan(0)); |
147 | 148 |
|
148 | | - // Verify the leaf sorter is configured regardless of segment count |
| 149 | + // Test that ReadOnlyEngine can be created with a leaf sorter configured |
| 150 | + // and that it can acquire a searcher successfully |
149 | 151 | assertThat("Leaf sorter should be configured", readOnlyEngine.config().getLeafSorter(), notNullValue()); |
150 | | - |
151 | | - // Test that the leaf sorter is configured and the engine has leaves |
152 | | - // Note: The actual sorting behavior may vary depending on the engine implementation |
153 | | - // and Lucene's internal segment management. The key test is that the leaf sorter |
154 | | - // is properly configured and the engine can create a searcher with leaves. |
| 152 | + assertThat("Leaf sorter should match the configured one", readOnlyEngine.config().getLeafSorter(), equalTo(leafSorter)); |
| 153 | + |
| 154 | + // Verify basic functionality - we can read from the engine |
155 | 155 | assertThat("Should have at least one leaf", reader.leaves().size(), greaterThan(0)); |
156 | | - |
157 | | - // Verify the leaf sorter is configured (this is the main test) |
158 | | - assertThat("Leaf sorter should be configured", readOnlyEngine.config().getLeafSorter(), notNullValue()); |
159 | | - |
160 | | - // Log the leaf order for debugging (but don't fail the test) |
161 | | - if (reader.leaves().size() > 1) { |
162 | | - java.util.List<Integer> leafSizes = new java.util.ArrayList<>(); |
163 | | - for (org.apache.lucene.index.LeafReaderContext ctx : reader.leaves()) { |
164 | | - leafSizes.add(ctx.reader().maxDoc()); |
165 | | - } |
166 | | - // The test passes as long as the leaf sorter is configured |
167 | | - // The actual sorting behavior is implementation-dependent |
168 | | - } |
169 | 156 | } |
170 | 157 | } |
171 | 158 | } |
|
0 commit comments