timoninmaxim commented on a change in pull request #9719:
URL: https://github.com/apache/ignite/pull/9719#discussion_r783729863



##########
File path: 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java
##########
@@ -144,6 +153,117 @@ public void testCorrectClosingFileDescriptors() throws 
Exception {
         );
     }
 
+    /** */
+    @Test
+    public void testNoNextIfLowBoundInTheEnd() throws Exception {
+        String dir = createWalFiles(3);
+
+        WALIterator iter = createWalIterator(dir, null, null, false);
+
+        assertFalse(iter.lastRead().isPresent());
+
+        while (iter.hasNext()) {
+            IgniteBiTuple<WALPointer, WALRecord> curr = iter.next();
+
+            assertEquals("Last read should point to the current record", 
curr.get1(), iter.lastRead().get());
+        }
+
+        iter.close();
+
+        iter = createWalIterator(dir, iter.lastRead().get().next(), null, 
false);
+
+        assertFalse(iter.lastRead().isPresent());
+
+        assertFalse(iter.hasNext());
+
+        iter.close();
+    }
+
+    /** */
+    @Test
+    public void testNextRecordReturnedForLowBounds() throws Exception {
+        String dir = createWalFiles(3);
+
+        WALIterator iter = createWalIterator(dir, null, null, false);
+
+        IgniteBiTuple<WALPointer, WALRecord> prev = iter.next();
+
+        assertEquals("Last read should point to the current record", 
prev.get1(), iter.lastRead().get());
+
+        iter.close();
+
+        iter = createWalIterator(dir, iter.lastRead().get().next(), null, 
false);
+
+        assertFalse(iter.lastRead().isPresent());
+
+        while (iter.hasNext()) {
+            IgniteBiTuple<WALPointer, WALRecord> cur = iter.next();
+
+            assertEquals("Last read should point to the current record", 
cur.get1(), iter.lastRead().get());
+
+            assertFalse(
+                "Should read next record[prev=" + prev.get1() + ", cur=" + 
cur.get1() + ']',
+                prev.get1().equals(cur.get1())
+            );
+
+            prev = cur;
+
+            iter.close();
+
+            iter = createWalIterator(dir, iter.lastRead().get().next(), null, 
false);
+
+            assertFalse(iter.lastRead().isPresent());
+        }
+
+        iter.close();
+    }
+
+    /** */
+    @Test
+    public void testLastRecordFiltered() throws Exception {
+        String dir = createWalFiles();
+
+        WALIterator iter = createWalIterator(dir, null, null, false);
+
+        IgniteBiTuple<WALPointer, WALRecord> lastRec = null;
+
+        // Search for the last record.
+        while (iter.hasNext())
+            lastRec = iter.next();
+
+        iter.close();
+
+        assertNotNull(lastRec);
+
+        WALPointer lastPointer = iter.lastRead().get();
+
+        WALRecord.RecordType lastRecType = lastRec.get2().type();
+
+        // Iterating and filter out last record.
+        iter = createWalIterator(dir, null, null, false, (type, ptr) -> type 
!= lastRecType);
+
+        while (iter.hasNext()) {

Review comment:
       Let's add here `assertTrue(iter.hasNext());`
   




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to