XComp commented on code in PR #19275:
URL: https://github.com/apache/flink/pull/19275#discussion_r845189212


##########
flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherResourceCleanupTest.java:
##########
@@ -651,6 +654,91 @@ public void testFailingJobManagerRunnerCleanup() throws 
Exception {
         awaitStatus(dispatcherGateway, jobId, JobStatus.RUNNING);
     }
 
+    @Test
+    public void testArchiveSuccessfullyWithinTimeout() throws Exception {
+
+        final long archiveTimeout = 1000L;
+        final CompletableFuture<Void> archiveFuture = new 
CompletableFuture<>();
+        final TestingHistoryServerArchivist archivist =
+                new TestingHistoryServerArchivist(archiveFuture);
+
+        final TestingJobManagerRunner testingJobManagerRunner =
+                startDispatcherAndSubmitJob(archiveTimeout, archivist);
+        finishJob(testingJobManagerRunner);
+
+        // Before the archiving is finished, the cleanup is not finished and 
the job is not
+        // terminated.
+        assertThatNoCleanupWasTriggered();
+        final CompletableFuture<Void> jobTerminationFuture =
+                dispatcher.getJobTerminationFuture(jobId, 
Time.milliseconds(1000L));
+        assertFalse(jobTerminationFuture.isDone());
+
+        archiveFuture.complete(null);
+
+        // Once the archive is finished, the cleanup is finished and the job 
is terminated.
+        assertGlobalCleanupTriggered(jobId);
+        jobTerminationFuture.join();
+
+        assertTrue(archivist.isArchived());
+    }
+
+    @Test
+    public void testArchiveFailedWhenTimeoutExceeded() throws Exception {
+
+        final long archiveTimeout = 10L;
+        final CompletableFuture<Void> archiveFuture = new 
CompletableFuture<>();
+        final TestingHistoryServerArchivist archivist =
+                new TestingHistoryServerArchivist(archiveFuture);
+
+        final TestingJobManagerRunner testingJobManagerRunner =
+                startDispatcherAndSubmitJob(archiveTimeout, archivist);
+
+        finishJob(testingJobManagerRunner);
+
+        // Once the archiving is timed out, the cleanup will be finished and 
the job will be
+        // terminated.
+        assertGlobalCleanupTriggered(jobId);
+        dispatcher.getJobTerminationFuture(jobId, 
Time.milliseconds(1000L)).join();

Review Comment:
   Essentially, it's about [this dev ML 
discussion](https://lists.apache.org/thread/q11t0y3qsw07lkb811037h4mvx0r7ncn) 
and you're not alone in this. There are a few test where ran into the same 
trap. :-)



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