use of org.apache.flink.core.testutils.ManuallyTriggeredScheduledExecutorService in project flink by apache.
the class SourceCoordinatorContextTest method testCallableInterruptedDuringShutdownDoNotFailJob.
@Test
public void testCallableInterruptedDuringShutdownDoNotFailJob() throws InterruptedException {
AtomicReference<Throwable> expectedError = new AtomicReference<>(null);
ManuallyTriggeredScheduledExecutorService manualWorkerExecutor = new ManuallyTriggeredScheduledExecutorService();
ManuallyTriggeredScheduledExecutorService manualCoordinatorExecutor = new ManuallyTriggeredScheduledExecutorService();
SourceCoordinatorContext<MockSourceSplit> testingContext = new SourceCoordinatorContext<>(manualCoordinatorExecutor, manualWorkerExecutor, new SourceCoordinatorProvider.CoordinatorExecutorThreadFactory(TEST_OPERATOR_ID.toHexString(), getClass().getClassLoader()), operatorCoordinatorContext, new MockSourceSplitSerializer(), splitSplitAssignmentTracker);
testingContext.callAsync(() -> {
throw new InterruptedException();
}, (ignored, e) -> {
if (e != null) {
expectedError.set(e);
throw new RuntimeException(e);
}
});
manualWorkerExecutor.triggerAll();
testingContext.close();
manualCoordinatorExecutor.triggerAll();
assertTrue(expectedError.get() instanceof InterruptedException);
assertFalse(operatorCoordinatorContext.isJobFailed());
}
use of org.apache.flink.core.testutils.ManuallyTriggeredScheduledExecutorService in project flink by apache.
the class DeclarativeSlotManagerTest method testAllocationUpdatesIgnoredIfTaskExecutorUnregistered.
@Test
public void testAllocationUpdatesIgnoredIfTaskExecutorUnregistered() throws Exception {
final ManuallyTriggeredScheduledExecutorService executor = new ManuallyTriggeredScheduledExecutorService();
final ResourceTracker resourceTracker = new DefaultResourceTracker();
final TestingTaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setRequestSlotFunction(ignored -> CompletableFuture.completedFuture(Acknowledge.get())).createTestingTaskExecutorGateway();
final SystemExitTrackingSecurityManager trackingSecurityManager = new SystemExitTrackingSecurityManager();
System.setSecurityManager(trackingSecurityManager);
try (final DeclarativeSlotManager slotManager = createDeclarativeSlotManagerBuilder().setResourceTracker(resourceTracker).buildAndStart(ResourceManagerId.generate(), executor, new TestingResourceActionsBuilder().build())) {
JobID jobId = new JobID();
slotManager.processResourceRequirements(createResourceRequirements(jobId, 1));
final TaskExecutorConnection taskExecutionConnection = createTaskExecutorConnection(taskExecutorGateway);
final SlotReport slotReport = createSlotReport(taskExecutionConnection.getResourceID(), 1);
slotManager.registerTaskManager(taskExecutionConnection, slotReport, ResourceProfile.ANY, ResourceProfile.ANY);
slotManager.unregisterTaskManager(taskExecutionConnection.getInstanceID(), TEST_EXCEPTION);
executor.triggerAll();
assertThat(trackingSecurityManager.getSystemExitFuture().isDone(), is(false));
} finally {
System.setSecurityManager(null);
}
}
use of org.apache.flink.core.testutils.ManuallyTriggeredScheduledExecutorService in project flink by apache.
the class DeclarativeSlotManagerTest method testAllocationUpdatesIgnoredIfSlotMarkedAsAllocatedAfterSlotReport.
@Test
public void testAllocationUpdatesIgnoredIfSlotMarkedAsAllocatedAfterSlotReport() throws Exception {
final ManuallyTriggeredScheduledExecutorService executor = new ManuallyTriggeredScheduledExecutorService();
final ResourceTracker resourceTracker = new DefaultResourceTracker();
final TestingTaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setRequestSlotFunction(ignored -> CompletableFuture.completedFuture(Acknowledge.get())).createTestingTaskExecutorGateway();
final SystemExitTrackingSecurityManager trackingSecurityManager = new SystemExitTrackingSecurityManager();
System.setSecurityManager(trackingSecurityManager);
try (final DeclarativeSlotManager slotManager = createDeclarativeSlotManagerBuilder().setResourceTracker(resourceTracker).buildAndStart(ResourceManagerId.generate(), executor, new TestingResourceActionsBuilder().build())) {
JobID jobId = new JobID();
slotManager.processResourceRequirements(createResourceRequirements(jobId, 1));
final TaskExecutorConnection taskExecutionConnection = createTaskExecutorConnection(taskExecutorGateway);
final SlotReport slotReport = createSlotReport(taskExecutionConnection.getResourceID(), 1);
slotManager.registerTaskManager(taskExecutionConnection, slotReport, ResourceProfile.ANY, ResourceProfile.ANY);
slotManager.reportSlotStatus(taskExecutionConnection.getInstanceID(), createSlotReportWithAllocatedSlots(taskExecutionConnection.getResourceID(), jobId, 1));
executor.triggerAll();
assertThat(trackingSecurityManager.getSystemExitFuture().isDone(), is(false));
} finally {
System.setSecurityManager(null);
}
}
Aggregations