vigyasharma commented on code in PR #14417: URL: https://github.com/apache/lucene/pull/14417#discussion_r2015832195
########## lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java: ########## @@ -5037,4 +5037,47 @@ 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()); Review Comment: Do we need this check? Let's assert with `gte` to avoid flakiness. ########## lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java: ########## @@ -5037,4 +5037,47 @@ 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()); Review Comment: Let's add a similar `gte` check here as in the assert below, instead of assuming that counter value is 1. -- 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