Au-Miner commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2184917402


##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/testutils/MockEnvironment.java:
##########
@@ -483,4 +491,8 @@ public void setExpectedExternalFailureCause(Class<? extends 
Throwable> expectedT
     public Optional<? extends Throwable> getActualExternalFailureCause() {
         return actualExternalFailureCause;
     }
+
+    public void setExternalFailureCauseConsumer(Consumer<Throwable> 
externalFailureCauseConsumer) {

Review Comment:
   There is expectedExternalFailureCause we can use in MockEnvironment, so we 
needn't create externalFailureCauseConsumer to consume the exception.



##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -155,12 +157,22 @@ VarCharType.STRING_TYPE, new IntType(), new BooleanType()
 
     private RowDataHarnessAssertor assertor;
 
+    private Optional<Throwable> latestException = Optional.empty();
+
     @BeforeEach
     public void beforeEach() throws Exception {
         testHarness = createDeltaJoinOperatorTestHarness();
         testHarness.setup();
         testHarness.open();
         StreamingDeltaJoinOperator operator = unwrapOperator(testHarness);
+        // set external failure cause consumer to prevent hang
+        testHarness
+                .getEnvironment()
+                .setExternalFailureCauseConsumer(

Review Comment:
   Maybe we can use setExpectedExternalFailureCause instead of 
setExternalFailureCauseConsumer.



##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -529,6 +547,33 @@ void testClearLegacyStateWhenCheckpointing() throws 
Exception {
                 "result mismatch", expectedOutput, testHarness.getOutput());
     }
 
+    @Test
+    void testMeetExceptionWhenLookup() throws Exception {
+        Throwable expectedException = new IllegalStateException("Mock to 
fail");
+        MyAsyncFunction.throwException(expectedException);
+
+        StreamRecord<RowData> record = insertRecord(100, true, "jklk1");
+        testHarness.processElement1(record);
+
+        // IllegalStateException(Failed to wait all data processed)
+        //  +- Exception(Could not complete the stream element ...)
+        //    +- RuntimeException(Failed to lookup table)
+        //      +- Actual Exception
+        assertThatThrownBy(this::waitAllDataProcessed)
+                .cause()
+                .cause()
+                .cause()
+                .isEqualTo(expectedException);
+    }
+
+    private void waitAllDataProcessed() throws Exception {
+        testHarness.endAllInputs();
+        if (latestException.isPresent()) {

Review Comment:
   Correspondingly, we can use getActualExternalFailureCause().isPresent() to 
judge if we should throw exception here.



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