Beutlin commented on code in PR #18123:
URL: https://github.com/apache/iceberg/pull/18123#discussion_r4146844537


##########
flink/v2.3/flink/src/test/java/org/apache/iceberg/flink/sink/TestIcebergCommitter.java:
##########
@@ -238,6 +238,57 @@ public void testCommitTxn() throws Exception {
     }
   }
 
+  @TestTemplate
+  public void testCommitTxnAfterStatelessRestart() throws Exception {
+    RowData rowFromPreviousRun = SimpleDataUtil.createRowData(0, "hello0");
+    DataFile dataFileFromPreviousRun =
+        writeDataFile("data-previous-run", 
ImmutableList.of(rowFromPreviousRun));
+
+    try (OneInputStreamOperatorTestHarness<
+            CommittableMessage<IcebergCommittable>, 
CommittableMessage<IcebergCommittable>>
+        preRestartHarness = getTestHarness()) {
+      preRestartHarness.open();
+      processElement(jobId, 5, preRestartHarness, 1, OPERATOR_ID, 
dataFileFromPreviousRun);
+      preRestartHarness.notifyOfCompletedCheckpoint(5);
+    }
+
+    assertSnapshotSize(1);
+    assertMaxCommittedCheckpointId(jobId, 5);
+
+    List<RowData> rows = Lists.newArrayList(rowFromPreviousRun);
+    // A stateless restart opens a fresh operator instance without restoring 
prior state, so
+    // IcebergSink#createCommitter must see an empty 
context.getRestoredCheckpointId().
+    try (OneInputStreamOperatorTestHarness<
+            CommittableMessage<IcebergCommittable>, 
CommittableMessage<IcebergCommittable>>
+        afterRestartHarness = getTestHarness()) {
+      afterRestartHarness.open();
+
+      for (int i = 1; i <= 3; i++) {
+        RowData row = SimpleDataUtil.createRowData(i, "hello" + i);
+        DataFile dataFile = writeDataFile("data-after-restart-" + i, 
ImmutableList.of(row));
+        processElement(jobId, i, afterRestartHarness, 1, OPERATOR_ID, 
dataFile);
+        afterRestartHarness.notifyOfCompletedCheckpoint(i);
+        rows.add(row);
+        assertSnapshotSize(i + 1);
+        assertMaxCommittedCheckpointId(jobId, i);
+        SimpleDataUtil.assertTableRows(table, ImmutableList.copyOf(rows), 
branch);
+      }

Review Comment:
   I've changed the test. Thanks.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to