vigyasharma commented on code in PR #14417: URL: https://github.com/apache/lucene/pull/14417#discussion_r2015817265
########## lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java: ########## @@ -5037,4 +5037,45 @@ public void testDocValuesSkippingIndexWithoutDocValues() throws Exception { } } } + + public void testAdvanceSegmentInfosCounter() throws IOException { + Directory dir = newDirectory(); + + IndexWriter writer; + IndexReader reader; + + writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))); + + // add 10 documents + for (int i = 0; i < 10; i++) { + addDocWithIndex(writer, i); + writer.commit(); + } + long beforeAdvanceSegmentCounter = writer.getSegmentInfosCounter(); + writer.advanceSegmentInfosCounter(1); + assertEquals(beforeAdvanceSegmentCounter, writer.getSegmentInfosCounter()); + + writer.advanceSegmentInfosCounter(1000); + assertEquals(1000, writer.getSegmentInfosCounter()); + + // add 40 documents + for (int i = 10; i < 50; i++) { + addDocWithIndex(writer, i); + writer.commit(); + } + + assertEquals(1041, writer.getSegmentInfosCounter()); Review Comment: I think it's sufficient to assert that the counter value is `>=1000` i.e. higher than what you advanced it to. `SegmentInfos.counter` is public and gets incremented each time a segment is named, including background merges. Asserting on an exact value can make the test flaky. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org