wanglijie95 commented on code in PR #20169:
URL: https://github.com/apache/flink/pull/20169#discussion_r914404384


##########
flink-runtime/src/test/java/org/apache/flink/runtime/blocklist/DefaultBlocklistHandlerTest.java:
##########
@@ -77,24 +87,53 @@ void testAddNewBlockedNodes() throws Exception {
 
     @Test
     void testRemoveTimeoutNodes() throws Exception {
+        final TestingComponentMainThreadExecutor mainThreadExecutor =
+                new TestingComponentMainThreadExecutor(
+                        
ComponentMainThreadExecutorServiceAdapter.forSingleThreadExecutor(
+                                EXECUTOR_EXTENSION.getExecutor()));
+
         long currentTimestamp = System.currentTimeMillis();
         BlockedNode node1 = new BlockedNode("node1", "cause", currentTimestamp 
+ 1000L);
         BlockedNode node2 = new BlockedNode("node2", "cause", currentTimestamp 
+ 3000L);
 
         TestBlocklistContext context = new TestBlocklistContext();
-        try (DefaultBlocklistHandler handler = 
createDefaultBlocklistHandler(context)) {
-
-            handler.addNewBlockedNodes(Arrays.asList(node1, node2));
-            assertThat(handler.getAllBlockedNodeIds()).hasSize(2);
-            assertThat(context.allUnBlockedNodes).hasSize(0);
+        try (DefaultBlocklistHandler handler =
+                createDefaultBlocklistHandler(
+                        context, mainThreadExecutor.getMainThreadExecutor())) {
+            mainThreadExecutor.execute(
+                    () -> {
+                        handler.addNewBlockedNodes(Arrays.asList(node1, 
node2));
+                        assertThat(handler.getAllBlockedNodeIds()).hasSize(2);
+                        assertThat(context.allUnBlockedNodes).hasSize(0);
+                    });
 
             // wait node1 timeout
-            CommonTestUtils.waitUntilCondition(() -> 
handler.getAllBlockedNodeIds().size() == 1);
-            assertThat(context.allUnBlockedNodes).containsExactly(node1);
+            CommonTestUtils.waitUntilCondition(
+                    () ->
+                            mainThreadExecutor.execute(
+                                            () -> {
+                                                int nodes = 
handler.getAllBlockedNodeIds().size();
+                                                if (nodes == 1) {
+                                                    
assertThat(context.allUnBlockedNodes)
+                                                            
.containsExactly(node1);
+                                                }
+                                                return nodes;
+                                            })
+                                    == 1);
 
             // wait node2 timeout
-            CommonTestUtils.waitUntilCondition(() -> 
handler.getAllBlockedNodeIds().size() == 0);
-            assertThat(context.allUnBlockedNodes).containsExactly(node1, 
node2);
+            CommonTestUtils.waitUntilCondition(

Review Comment:
   You are right. I ‘ve changed it with reference to 
`TaskExecutorManagerTest#testTimeoutForUnusedTaskManager`, please have a look
   
   



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