vahmed-hamdy commented on code in PR #26111:
URL: https://github.com/apache/flink/pull/26111#discussion_r1944352610


##########
flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java:
##########
@@ -1158,6 +1162,102 @@ public void 
testRequestMultipleJobDetails_returnsFinishedOverSuspendedJob() thro
                 JobStatus.FINISHED, 
dispatcherGateway.requestMultipleJobDetails(TIMEOUT).get());
     }
 
+    @Test
+    public void 
testRequestMultipleJobDetails_returnsJobsOfSameStateOrderedByStartTimeInDecOrder()
+            throws Exception {
+        final JobID secondJobID = new JobID();
+        final JobManagerRunnerFactory blockingJobMaster =
+                new QueuedJobManagerRunnerFactory(
+                        
runningJobManagerRunnerWithJobStatus(JobStatus.RUNNING, jobId, 0L),
+                        
runningJobManagerRunnerWithJobStatus(JobStatus.RUNNING, secondJobID, 10L));
+
+        dispatcher = createAndStartDispatcher(heartbeatServices, haServices, 
blockingJobMaster);
+        DispatcherGateway dispatcherGateway = 
dispatcher.getSelfGateway(DispatcherGateway.class);
+        jobMasterLeaderElection.isLeader(UUID.randomUUID());
+        JobGraph secondJobGraph = JobGraphTestUtils.streamingJobGraph();
+        secondJobGraph.setJobID(secondJobID);
+
+        dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
+        dispatcherGateway.submitJob(secondJobGraph, TIMEOUT).get();
+
+        MultipleJobsDetails multipleJobsDetails =
+                dispatcherGateway.requestMultipleJobDetails(TIMEOUT).get();
+        final Collection<JobDetails> jobDetails = 
multipleJobsDetails.getJobs();
+
+        // assert returned job details are ordered
+        assertThat(jobDetails).isInstanceOf(List.class);
+        assertThat(jobDetails).hasSize(2);
+        Iterator<JobDetails> jobDetailsIterator = jobDetails.iterator();
+        
assertThat(jobDetailsIterator.next().getJobId()).isEqualTo(secondJobID);
+        assertThat(jobDetailsIterator.next().getJobId()).isEqualTo(jobId);
+    }
+
+    @Test
+    public void
+            
testRequestMultipleJobDetails_returnsJobsOfSameStateOrderedByJobIdWhenSameStartTime()
+                    throws Exception {
+        final JobID secondJobID = new JobID();
+        final JobManagerRunnerFactory blockingJobMaster =
+                new QueuedJobManagerRunnerFactory(
+                        
runningJobManagerRunnerWithJobStatus(JobStatus.RUNNING, jobId, 10L),
+                        
runningJobManagerRunnerWithJobStatus(JobStatus.RUNNING, secondJobID, 10L));
+
+        dispatcher = createAndStartDispatcher(heartbeatServices, haServices, 
blockingJobMaster);
+        DispatcherGateway dispatcherGateway = 
dispatcher.getSelfGateway(DispatcherGateway.class);
+        jobMasterLeaderElection.isLeader(UUID.randomUUID());
+        JobGraph secondJobGraph = JobGraphTestUtils.streamingJobGraph();
+        secondJobGraph.setJobID(secondJobID);
+
+        dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
+        dispatcherGateway.submitJob(secondJobGraph, TIMEOUT).get();
+
+        MultipleJobsDetails multipleJobsDetails =
+                dispatcherGateway.requestMultipleJobDetails(TIMEOUT).get();
+        final Collection<JobDetails> jobDetails = 
multipleJobsDetails.getJobs();
+        List<JobID> orderedJobIds =
+                Stream.of(jobId, 
secondJobID).sorted().collect(Collectors.toList());
+
+        // assert returned job details are ordered
+        assertThat(jobDetails).isInstanceOf(List.class);
+        assertThat(jobDetails).hasSize(2);
+        Iterator<JobDetails> jobDetailsIterator = jobDetails.iterator();
+        
assertThat(jobDetailsIterator.next().getJobId()).isEqualTo(orderedJobIds.get(0));
+        
assertThat(jobDetailsIterator.next().getJobId()).isEqualTo(orderedJobIds.get(1));
+    }
+
+    @Test
+    public void
+            
testRequestMultipleJobDetails_returnsJobsOfSameStateOrderedByStartTimeOfInitialization()

Review Comment:
   I wanted to highlight the usage of `transitionToInitialization` as the 
ordering, but I guess we could suffice with this one.



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