RocMarshal commented on code in PR #29788:
URL: https://github.com/apache/flink/pull/29788#discussion_r4495678435


##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolBridgeTest.java:
##########
@@ -224,29 +228,62 @@ void 
testNoConcurrentModificationWhenSuspendingAndReleasingSlot() throws Excepti
 
     @TestTemplate
     void testAcceptingOfferedSlotsWithoutResourceManagerConnected() throws 
Exception {
-        try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge =
-                createDeclarativeSlotPoolBridge(new 
DefaultDeclarativeSlotPoolFactory())) {
-
-            declarativeSlotPoolBridge.start(JOB_MASTER_ID, "localhost");
-
-            final CompletableFuture<PhysicalSlot> slotFuture =
-                    declarativeSlotPoolBridge.requestNewAllocatedSlot(
-                            
PhysicalSlotRequestUtils.normalRequest(ResourceProfile.UNKNOWN),
-                            RPC_TIMEOUT);
-
-            tryWaitSlotRequestIsDone(declarativeSlotPoolBridge);
-
-            final LocalTaskManagerLocation localTaskManagerLocation =
-                    new LocalTaskManagerLocation();
-            
declarativeSlotPoolBridge.registerTaskManager(localTaskManagerLocation.getResourceID());
-
-            final AllocationID allocationId = new AllocationID();
-            declarativeSlotPoolBridge.offerSlots(
-                    localTaskManagerLocation,
-                    new SimpleAckingTaskManagerGateway(),
-                    Collections.singleton(new SlotOffer(allocationId, 0, 
ResourceProfile.ANY)));
-
-            
assertThat(slotFuture.join().getAllocationId()).isSameAs(allocationId);
+        final ScheduledExecutorService scheduledExecutorService =
+                Executors.newSingleThreadScheduledExecutor();
+        try {
+            final ComponentMainThreadExecutor mainThreadExecutor =
+                    
ComponentMainThreadExecutorServiceAdapter.forSingleThreadExecutor(
+                            scheduledExecutorService);
+
+            try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge =
+                    createDeclarativeSlotPoolBridge(
+                            new DefaultDeclarativeSlotPoolFactory(), 
mainThreadExecutor)) {
+
+                CompletableFuture.runAsync(
+                                () -> {
+                                    try {
+                                        
declarativeSlotPoolBridge.start(JOB_MASTER_ID, "localhost");
+                                    } catch (Exception e) {
+                                        throw new RuntimeException(e);
+                                    }
+                                },
+                                mainThreadExecutor)
+                        .join();
+
+                final CompletableFuture<PhysicalSlot> slotFuture =
+                        CompletableFuture.supplyAsync(
+                                        () ->
+                                                
declarativeSlotPoolBridge.requestNewAllocatedSlot(
+                                                        
PhysicalSlotRequestUtils.normalRequest(
+                                                                
ResourceProfile.UNKNOWN),
+                                                        RPC_TIMEOUT),
+                                        mainThreadExecutor)
+                                .get();
+
+                tryWaitSlotRequestIsDone(declarativeSlotPoolBridge);
+
+                final LocalTaskManagerLocation localTaskManagerLocation =
+                        new LocalTaskManagerLocation();
+                final AllocationID allocationId = new AllocationID();
+
+                CompletableFuture.runAsync(
+                                () -> {
+                                    
declarativeSlotPoolBridge.registerTaskManager(
+                                            
localTaskManagerLocation.getResourceID());
+                                    declarativeSlotPoolBridge.offerSlots(
+                                            localTaskManagerLocation,
+                                            new 
SimpleAckingTaskManagerGateway(),
+                                            Collections.singleton(
+                                                    new SlotOffer(
+                                                            allocationId, 0, 
ResourceProfile.ANY)));
+                                },
+                                mainThreadExecutor)
+                        .join();
+
+                
assertThat(slotFuture.join().getAllocationId()).isSameAs(allocationId);
+            }
+        } finally {
+            scheduledExecutorService.shutdown();

Review Comment:
   What about `scheduledExecutorService.shutdownNow();`?



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