XComp commented on code in PR #26111:
URL: https://github.com/apache/flink/pull/26111#discussion_r1944310004
##########
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()
Review Comment:
nit: The newly added tests have the almost the same code. We could move the
generic code out into a separate method and just define parameters for input
(the JobManagerRunners and expected JobID order). WDYT?
##########
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:
What's the difference between this test and
`testRequestMultipleJobDetails_returnsJobsOfSameStateOrderedByStartTimeInDecOrder`?
Aren't we testing the same code path? Or am I missing something here? 🤔
--
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]