@Test
    public void testAppendIndex() throws Exception {
        this.indexDB.startServiceManager();
        {
            // Append 10 index to first file , and come to the file end (size:130)
            for (int i = 0; i < 10; i++) {
                this.indexDB.appendIndexAsync(i, i, IndexType.IndexSegment);
            }
            // Write 5 index to second file , wrotePosition = 30 + 50
            Pair<Integer, Long> posPair = null;
            for (int i = 10; i <= 15; i++) {
                posPair = this.indexDB.appendIndexAsync(i, i, IndexType.IndexSegment);
            }

            this.indexDB.waitForFlush(posPair.getSecond(), 100);

            assertEquals(this.indexDB.lookupIndex(15).getOffset(), 5);
            assertEquals(this.indexDB.getFlushedPosition(), 212);
        }
    }
Test for Service , which enables auto flush
jraft-extension/java-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/db/IndexDBTest.java