leekeiabstraction commented on code in PR #193:
URL: 
https://github.com/apache/flink-connector-aws/pull/193#discussion_r2014373683


##########
flink-connector-aws/flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/source/reader/DynamoDbStreamsSourceReaderTest.java:
##########
@@ -158,4 +163,128 @@ void testAddSplitsRegistersAndUpdatesShardMetricGroup() 
throws Exception {
         TestUtil.assertMillisBehindLatest(
                 split, TestUtil.MILLIS_BEHIND_LATEST_TEST_VALUE, 
metricListener);
     }
+
+    @Test
+    void testSnapshotStateWithFinishedSplits() throws Exception {
+        // Create and add a split
+        DynamoDbStreamsShardSplit split = getTestSplit();
+        List<DynamoDbStreamsShardSplit> splits = 
Collections.singletonList(split);
+        sourceReader.addSplits(splits);
+
+        // Set checkpoint ID by taking initial snapshot
+        List<DynamoDbStreamsShardSplit> initialSnapshot = 
sourceReader.snapshotState(1L);
+        assertThat(initialSnapshot).hasSize(1).containsExactly(split);
+
+        // Simulate split finishing
+        Map<String, DynamoDbStreamsShardSplitState> finishedSplits = new 
HashMap<>();
+        finishedSplits.put(split.splitId(), new 
DynamoDbStreamsShardSplitState(split));
+        sourceReader.onSplitFinished(finishedSplits);
+
+        // Take another snapshot
+        List<DynamoDbStreamsShardSplit> snapshotSplits = 
sourceReader.snapshotState(2L);
+        List<DynamoDbStreamsShardSplit> snapshotFinishedSplits =
+                snapshotSplits.stream()
+                        .filter(DynamoDbStreamsShardSplit::isFinished)
+                        .collect(Collectors.toList());
+        // Verify we have 2 splits - the original split and the finished split
+        assertThat(snapshotFinishedSplits)

Review Comment:
   Description in comment and actual assertion differs, assertion only asserts 
'original' split.



##########
flink-connector-aws/flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/source/reader/DynamoDbStreamsSourceReaderTest.java:
##########
@@ -158,4 +163,128 @@ void testAddSplitsRegistersAndUpdatesShardMetricGroup() 
throws Exception {
         TestUtil.assertMillisBehindLatest(
                 split, TestUtil.MILLIS_BEHIND_LATEST_TEST_VALUE, 
metricListener);
     }
+
+    @Test
+    void testSnapshotStateWithFinishedSplits() throws Exception {
+        // Create and add a split
+        DynamoDbStreamsShardSplit split = getTestSplit();
+        List<DynamoDbStreamsShardSplit> splits = 
Collections.singletonList(split);
+        sourceReader.addSplits(splits);
+
+        // Set checkpoint ID by taking initial snapshot
+        List<DynamoDbStreamsShardSplit> initialSnapshot = 
sourceReader.snapshotState(1L);
+        assertThat(initialSnapshot).hasSize(1).containsExactly(split);
+
+        // Simulate split finishing
+        Map<String, DynamoDbStreamsShardSplitState> finishedSplits = new 
HashMap<>();
+        finishedSplits.put(split.splitId(), new 
DynamoDbStreamsShardSplitState(split));
+        sourceReader.onSplitFinished(finishedSplits);
+
+        // Take another snapshot
+        List<DynamoDbStreamsShardSplit> snapshotSplits = 
sourceReader.snapshotState(2L);
+        List<DynamoDbStreamsShardSplit> snapshotFinishedSplits =
+                snapshotSplits.stream()
+                        .filter(DynamoDbStreamsShardSplit::isFinished)
+                        .collect(Collectors.toList());
+        // Verify we have 2 splits - the original split and the finished split
+        assertThat(snapshotFinishedSplits)
+                .hasSize(1)
+                .allSatisfy(
+                        s -> {
+                            assertThat(s.splitId()).isEqualTo(split.splitId());
+                        });
+    }
+
+    @Test
+    void testAddSplitsWithStateRestoration() throws Exception {
+        // Create finished split with checkpoint id 1

Review Comment:
   nit: Comment describes checkpoint id 1 but checkpoint id 1 is not used



-- 
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