gguptp commented on code in PR #193:
URL:
https://github.com/apache/flink-connector-aws/pull/193#discussion_r2014398236
##########
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:
lol, good catch, fixed this
##########
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:
fixed this
--
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]