dmvk commented on a change in pull request #17967:
URL: https://github.com/apache/flink/pull/17967#discussion_r760358652
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/DefaultJobMasterServiceProcessTest.java
##########
@@ -56,7 +63,8 @@
jobId, "test", JobStatus.FAILED,
throwable, null, 1337));
@Test
- public void testInitializationFailureCompletesResultFuture() {
+ public void testInitializationFailureCompletesResultFuture()
+ throws ExecutionException, InterruptedException {
Review comment:
nit: exceptions are never thrown
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/DefaultJobMasterServiceProcessTest.java
##########
@@ -70,6 +78,69 @@ public void testInitializationFailureCompletesResultFuture()
{
assertThat(initializationFailure, containsCause(originalCause));
}
+ @Test
+ public void testInitializationFailureSetsFailureInfoProperly()
+ throws ExecutionException, InterruptedException {
+ final CompletableFuture<JobMasterService> jobMasterServiceFuture =
+ new CompletableFuture<>();
+ DefaultJobMasterServiceProcess serviceProcess =
createTestInstance(jobMasterServiceFuture);
+ final RuntimeException originalCause = new RuntimeException("Expected
RuntimeException");
+
+ long beforeFailureTimestamp = System.currentTimeMillis();
+ jobMasterServiceFuture.completeExceptionally(originalCause);
+ long afterFailureTimestamp = System.currentTimeMillis();
+
+ final JobManagerRunnerResult result =
serviceProcess.getResultFuture().get();
+ final ErrorInfo executionGraphFailure =
+
result.getExecutionGraphInfo().getArchivedExecutionGraph().getFailureInfo();
+
+ assertNotNull(executionGraphFailure);
+ final Throwable actualException =
+ executionGraphFailure
+ .getException()
+
.deserializeError(Thread.currentThread().getContextClassLoader());
+ assertEquals(JobInitializationException.class,
actualException.getClass());
+ assertTrue(
+ ExceptionUtils.findThrowable(actualException, t ->
t.equals(originalCause))
+ .isPresent());
+
+ assertTrue(executionGraphFailure.getTimestamp() >=
beforeFailureTimestamp);
+ assertTrue(executionGraphFailure.getTimestamp() <=
afterFailureTimestamp);
+ }
+
+ @Test
+ public void testInitializationFailureSetsExceptionHistoryProperly()
Review comment:
These new two tests are more or less the same. Should we either merge
them or have an abstract test that we reuse?
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/DefaultJobMasterServiceProcessTest.java
##########
@@ -70,6 +78,69 @@ public void testInitializationFailureCompletesResultFuture()
{
assertThat(initializationFailure, containsCause(originalCause));
}
+ @Test
+ public void testInitializationFailureSetsFailureInfoProperly()
+ throws ExecutionException, InterruptedException {
+ final CompletableFuture<JobMasterService> jobMasterServiceFuture =
+ new CompletableFuture<>();
+ DefaultJobMasterServiceProcess serviceProcess =
createTestInstance(jobMasterServiceFuture);
+ final RuntimeException originalCause = new RuntimeException("Expected
RuntimeException");
+
+ long beforeFailureTimestamp = System.currentTimeMillis();
+ jobMasterServiceFuture.completeExceptionally(originalCause);
+ long afterFailureTimestamp = System.currentTimeMillis();
+
+ final JobManagerRunnerResult result =
serviceProcess.getResultFuture().get();
+ final ErrorInfo executionGraphFailure =
+
result.getExecutionGraphInfo().getArchivedExecutionGraph().getFailureInfo();
+
+ assertNotNull(executionGraphFailure);
+ final Throwable actualException =
+ executionGraphFailure
+ .getException()
+
.deserializeError(Thread.currentThread().getContextClassLoader());
+ assertEquals(JobInitializationException.class,
actualException.getClass());
+ assertTrue(
+ ExceptionUtils.findThrowable(actualException, t ->
t.equals(originalCause))
+ .isPresent());
+
+ assertTrue(executionGraphFailure.getTimestamp() >=
beforeFailureTimestamp);
+ assertTrue(executionGraphFailure.getTimestamp() <=
afterFailureTimestamp);
+ }
+
+ @Test
+ public void testInitializationFailureSetsExceptionHistoryProperly()
+ throws ExecutionException, InterruptedException {
+ final CompletableFuture<JobMasterService> jobMasterServiceFuture =
+ new CompletableFuture<>();
+ DefaultJobMasterServiceProcess serviceProcess =
createTestInstance(jobMasterServiceFuture);
+ final RuntimeException originalCause = new RuntimeException("Expected
RuntimeException");
+
+ long beforeFailureTimestamp = System.currentTimeMillis();
+ jobMasterServiceFuture.completeExceptionally(originalCause);
+ long afterFailureTimestamp = System.currentTimeMillis();
+
+ final JobManagerRunnerResult result =
serviceProcess.getResultFuture().get();
+ final Iterator<RootExceptionHistoryEntry>
exceptionHistoryEntryIterator =
+
result.getExecutionGraphInfo().getExceptionHistory().iterator();
+
+ assertTrue(exceptionHistoryEntryIterator.hasNext());
+ final RootExceptionHistoryEntry entry =
exceptionHistoryEntryIterator.next();
+ assertFalse(exceptionHistoryEntryIterator.hasNext());
+
+ final Throwable actualException =
+ entry.getException()
+
.deserializeError(Thread.currentThread().getContextClassLoader());
Review comment:
```suggestion
final Throwable actualException =
Iterables.getOnlyElement(result.getExecutionGraphInfo().getExceptionHistory())
.getException()
.deserializeError(Thread.currentThread().getContextClassLoader());
```
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/ExecutionGraphInfoTest.java
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.scheduler;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.JobStatus;
+import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ErrorInfo;
+import
org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/** {@code ExecutionGraphInfoTest} tests the proper initialization of {@link
ExecutionGraphInfo}. */
+public class ExecutionGraphInfoTest {
+
+ @Test
+ public void
testExecutionGraphHistoryBeingDerivedFromFailedExecutionGraph() {
+ final ArchivedExecutionGraph executionGraph =
+ ArchivedExecutionGraph.createFromInitializingJob(
+ new JobID(),
+ "test job name",
+ JobStatus.FAILED,
+ new RuntimeException("Expected RuntimeException"),
+ null,
+ System.currentTimeMillis());
+
+ final ExecutionGraphInfo executionGraphInfo = new
ExecutionGraphInfo(executionGraph);
+
+ final ErrorInfo failureInfo =
+
executionGraphInfo.getArchivedExecutionGraph().getFailureInfo();
+
+ final Iterator<RootExceptionHistoryEntry>
exceptionHistoryEntryIterator =
+ executionGraphInfo.getExceptionHistory().iterator();
+
+ assertTrue(exceptionHistoryEntryIterator.hasNext());
+ final RootExceptionHistoryEntry actualEntry =
exceptionHistoryEntryIterator.next();
+ assertFalse(exceptionHistoryEntryIterator.hasNext());
+
Review comment:
```suggestion
final RootExceptionHistoryEntry actualEntry =
Iterables.getOnlyElement(executionGraphInfo.getExceptionHistory());
```
--
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]