jubins commented on code in PR #28226:
URL: https://github.com/apache/flink/pull/28226#discussion_r3314519187


##########
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/application/ApplicationExceptionsHandlerTest.java:
##########
@@ -143,6 +159,116 @@ void testExceptionWithJobId() throws Exception {
         assertThat(exceptionInfo.getJobId()).isEqualTo(jobId);
     }
 
+    @Test
+    void testMaxExceptionsLimitsHistorySize() throws Exception {
+        final List<ApplicationExceptionHistoryEntry> exceptionHistory = new 
ArrayList<>();
+        for (int i = 0; i < 5; i++) {
+            exceptionHistory.add(
+                    new ApplicationExceptionHistoryEntry(
+                            new RuntimeException("exception #" + i),
+                            System.currentTimeMillis(),
+                            null));
+        }
+
+        final ArchivedApplication applicationWithExceptions =
+                new ArchivedApplication(
+                        archivedApplication.getApplicationId(),
+                        archivedApplication.getApplicationName(),
+                        ApplicationState.FAILED,
+                        new long[] {1L, 1L, 1L, 1L, 1L, 1L, 1L},
+                        Collections.emptyMap(),
+                        exceptionHistory);
+
+        testingRestfulGateway =
+                new TestingRestfulGateway.Builder()
+                        .setRequestApplicationFunction(
+                                applicationId ->
+                                        CompletableFuture.completedFuture(
+                                                applicationWithExceptions))
+                        .build();
+
+        final HandlerRequest<EmptyRequestBody> limitedRequest =
+                createRequest(archivedApplication.getApplicationId(), 2);
+
+        final ApplicationExceptionsInfoWithHistory response =
+                handler.handleRequest(limitedRequest, 
testingRestfulGateway).get();
+
+        assertThat(response.getExceptionHistory().getEntries()).hasSize(2);

Review Comment:
   agreed, updated the test to assign distinct timestamps (`baseTimestamp + i`) 
so we can assert exact order via 
extracting(`...::getTimestamp).containsExactly(baseTimestamp, baseTimestamp + 
1`), which verifies both the count and that the first two entries are returned 
in insertion order



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