use of org.apache.flink.runtime.executiongraph.ExecutionVertex in project flink by apache.
the class StackTraceSampleCoordinatorTest method testTriggerStackTraceSampleNotRunningTasks.
/** Tests triggering for non-running tasks fails the future. */
@Test
public void testTriggerStackTraceSampleNotRunningTasks() throws Exception {
ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.DEPLOYING, true) };
Future<StackTraceSample> sampleFuture = coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0);
assertTrue(sampleFuture.isDone());
try {
sampleFuture.get();
fail("Expected exception.");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof IllegalStateException);
}
}
use of org.apache.flink.runtime.executiongraph.ExecutionVertex in project flink by apache.
the class StackTraceSampleCoordinatorTest method testCollectStackTraceForCanceledSample.
/** Tests that collecting for a cancelled sample throws no Exception. */
@Test
public void testCollectStackTraceForCanceledSample() throws Exception {
ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true) };
Future<StackTraceSample> sampleFuture = coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0);
assertFalse(sampleFuture.isDone());
coord.cancelStackTraceSample(0, null);
assertTrue(sampleFuture.isDone());
// Verify no error on late collect
ExecutionAttemptID executionId = vertices[0].getCurrentExecutionAttempt().getAttemptId();
coord.collectStackTraces(0, executionId, new ArrayList<StackTraceElement[]>());
}
use of org.apache.flink.runtime.executiongraph.ExecutionVertex in project flink by apache.
the class StackTraceSampleCoordinatorTest method mockExecutionVertex.
// ------------------------------------------------------------------------
private ExecutionVertex mockExecutionVertex(ExecutionAttemptID executionId, ExecutionState state, boolean sendSuccess) {
Execution exec = mock(Execution.class);
when(exec.getAttemptId()).thenReturn(executionId);
when(exec.getState()).thenReturn(state);
when(exec.requestStackTraceSample(anyInt(), anyInt(), any(Time.class), anyInt(), any(Time.class))).thenReturn(sendSuccess ? FlinkCompletableFuture.completed(mock(StackTraceSampleResponse.class)) : FlinkCompletableFuture.<StackTraceSampleResponse>completedExceptionally(new Exception("Send failed")));
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getJobvertexId()).thenReturn(new JobVertexID());
when(vertex.getCurrentExecutionAttempt()).thenReturn(exec);
return vertex;
}
use of org.apache.flink.runtime.executiongraph.ExecutionVertex in project flink by apache.
the class StackTraceSampleCoordinatorTest method testTriggerStackTraceSampleResetRunningTasks.
/** Tests triggering for reset tasks fails the future. */
@Test(timeout = 1000L)
public void testTriggerStackTraceSampleResetRunningTasks() throws Exception {
ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true), // Fails to send the message to the execution (happens when execution is reset)
mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, false) };
Future<StackTraceSample> sampleFuture = coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0);
try {
sampleFuture.get();
fail("Expected exception.");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof RuntimeException);
}
}
use of org.apache.flink.runtime.executiongraph.ExecutionVertex in project flink by apache.
the class StackTraceSampleCoordinatorTest method testShutDown.
/** Tests that shut down fails all pending samples and future sample triggers. */
@Test
public void testShutDown() throws Exception {
ExecutionVertex[] vertices = new ExecutionVertex[] { mockExecutionVertex(new ExecutionAttemptID(), ExecutionState.RUNNING, true) };
List<Future<StackTraceSample>> sampleFutures = new ArrayList<>();
// Trigger
sampleFutures.add(coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0));
sampleFutures.add(coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0));
for (Future<StackTraceSample> future : sampleFutures) {
assertFalse(future.isDone());
}
// Shut down
coord.shutDown();
// Verify all completed
for (Future<StackTraceSample> future : sampleFutures) {
assertTrue(future.isDone());
}
// Verify new trigger returns failed future
Future<StackTraceSample> future = coord.triggerStackTraceSample(vertices, 1, Time.milliseconds(100L), 0);
assertTrue(future.isDone());
try {
future.get();
fail("Expected exception.");
} catch (ExecutionException e) {
// we expected an exception here :-)
}
}
Aggregations