tillrohrmann commented on a change in pull request #17693:
URL: https://github.com/apache/flink/pull/17693#discussion_r756897573



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/DefaultSchedulerTest.java
##########
@@ -1479,6 +1485,72 @@ public void testLateRegisteredPartitionsWillBeReleased() 
{
         assertThat(shuffleMaster.getExternallyReleasedPartitions(), 
hasSize(1));
     }
 
+    @Test
+    public void testCheckpointCleanerIsClosedAfterCheckpointServices() throws 
Exception {
+        final JobGraph jobGraph = singleJobVertexJobGraph(1);
+        enableCheckpointing(jobGraph);
+        final CountDownLatch checkpointServicesShutdownBlocked = new 
CountDownLatch(1);
+        final CountDownLatch cleanerClosed = new CountDownLatch(1);
+        final ScheduledExecutorService executorService =
+                Executors.newSingleThreadScheduledExecutor();
+        final CompletedCheckpointStore completedCheckpointStore =
+                new StandaloneCompletedCheckpointStore(1) {
+
+                    @Override
+                    public void shutdown(JobStatus jobStatus, 
CheckpointsCleaner checkpointsCleaner)
+                            throws Exception {
+                        checkpointServicesShutdownBlocked.await();
+                        super.shutdown(jobStatus, checkpointsCleaner);
+                    }
+                };
+        final CheckpointIDCounter checkpointIDCounter =
+                new StandaloneCheckpointIDCounter() {
+
+                    @Override
+                    public void shutdown(JobStatus jobStatus) throws Exception 
{
+                        checkpointServicesShutdownBlocked.await();
+                        super.shutdown(jobStatus);
+                    }
+                };
+        final DefaultScheduler scheduler =
+                SchedulerTestingUtils.newSchedulerBuilder(
+                                jobGraph,
+                                
ComponentMainThreadExecutorServiceAdapter.forSingleThreadExecutor(
+                                        executorService))
+                        .setCheckpointRecoveryFactory(
+                                new TestingCheckpointRecoveryFactory(
+                                        completedCheckpointStore, 
checkpointIDCounter))
+                        .setCheckpointCleaner(
+                                new CheckpointsCleaner() {
+
+                                    @Override
+                                    public synchronized 
CompletableFuture<Void> closeAsync() {
+                                        cleanerClosed.countDown();
+                                        return super.closeAsync();
+                                    }
+                                })
+                        .build();
+
+        final CompletableFuture<Void> schedulerClosed = new 
CompletableFuture<>();
+        final CountDownLatch schedulerClosing = new CountDownLatch(1);
+
+        executorService.submit(
+                () -> {
+                    scheduler.closeAsync().thenRun(() -> 
schedulerClosed.complete(null));
+                    schedulerClosing.countDown();
+                });
+
+        // Wait for scheduler to start closing.
+        schedulerClosing.await();
+        assertFalse(
+                "CheckpointCleaner should not close before checkpoint 
services.",
+                cleanerClosed.await(10, TimeUnit.MILLISECONDS));
+        checkpointServicesShutdownBlocked.countDown();

Review comment:
       True. Forget what I've said :-)




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