use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class ZooKeeperLeaderElectionTest method testUnExpectedErrorForwarding.
/**
* Test that background errors in the {@link LeaderElectionDriver} are correctly forwarded to
* the {@link FatalErrorHandler}.
*/
@Test
public void testUnExpectedErrorForwarding() throws Exception {
LeaderElectionDriver leaderElectionDriver = null;
final TestingLeaderElectionEventHandler electionEventHandler = new TestingLeaderElectionEventHandler(LEADER_ADDRESS);
final TestingFatalErrorHandler fatalErrorHandler = new TestingFatalErrorHandler();
final FlinkRuntimeException testException = new FlinkRuntimeException("testUnExpectedErrorForwarding");
final CuratorFrameworkFactory.Builder curatorFrameworkBuilder = CuratorFrameworkFactory.builder().connectString(testingServer.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 0)).aclProvider(new ACLProvider() {
// trigger background exception
@Override
public List<ACL> getDefaultAcl() {
throw testException;
}
@Override
public List<ACL> getAclForPath(String s) {
throw testException;
}
}).namespace("flink");
try (CuratorFrameworkWithUnhandledErrorListener curatorFrameworkWrapper = ZooKeeperUtils.startCuratorFramework(curatorFrameworkBuilder, fatalErrorHandler)) {
CuratorFramework clientWithErrorHandler = curatorFrameworkWrapper.asCuratorFramework();
assertFalse(fatalErrorHandler.getErrorFuture().isDone());
leaderElectionDriver = createAndInitLeaderElectionDriver(clientWithErrorHandler, electionEventHandler);
assertThat(fatalErrorHandler.getErrorFuture().join(), FlinkMatchers.containsCause(testException));
} finally {
electionEventHandler.close();
if (leaderElectionDriver != null) {
leaderElectionDriver.close();
}
}
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class ResourceManagerServiceImplTest method setupClass.
@BeforeClass
public static void setupClass() {
rpcService = new TestingRpcService();
haService = new TestingHighAvailabilityServices();
fatalErrorHandler = new TestingFatalErrorHandler();
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class WebMonitorEndpointTest method cleansUpExpiredExecutionGraphs.
@Test
public void cleansUpExpiredExecutionGraphs() throws Exception {
final Configuration configuration = new Configuration();
configuration.setString(RestOptions.ADDRESS, "localhost");
configuration.setLong(WebOptions.REFRESH_INTERVAL, 5L);
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
final long timeout = 10000L;
final OneShotLatch cleanupLatch = new OneShotLatch();
final TestingExecutionGraphCache executionGraphCache = TestingExecutionGraphCache.newBuilder().setCleanupRunnable(cleanupLatch::trigger).build();
try (final WebMonitorEndpoint<RestfulGateway> webMonitorEndpoint = new WebMonitorEndpoint<>(CompletableFuture::new, configuration, RestHandlerConfiguration.fromConfiguration(configuration), CompletableFuture::new, NoOpTransientBlobService.INSTANCE, executor, VoidMetricFetcher.INSTANCE, new TestingLeaderElectionService(), executionGraphCache, new TestingFatalErrorHandler())) {
webMonitorEndpoint.start();
// check that the cleanup will be triggered
cleanupLatch.await(timeout, TimeUnit.MILLISECONDS);
} finally {
ExecutorUtils.gracefulShutdown(timeout, TimeUnit.MILLISECONDS, executor);
}
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class TaskExecutorTest method setup.
@Before
public void setup() throws IOException {
rpc = new TestingRpcService();
configuration = new Configuration();
TaskExecutorResourceUtils.adjustForLocalExecution(configuration);
unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
jobId = new JobID();
jobId2 = new JobID();
testingFatalErrorHandler = new TestingFatalErrorHandler();
haServices = new TestingHighAvailabilityServices();
resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
jobManagerLeaderRetriever2 = new SettableLeaderRetrievalService();
haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);
haServices.setJobMasterLeaderRetriever(jobId2, jobManagerLeaderRetriever2);
nettyShuffleEnvironment = new NettyShuffleEnvironmentBuilder().build();
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class JobMasterPartitionReleaseTest method testPartitionTableCleanupOnDisconnect.
@Test
public void testPartitionTableCleanupOnDisconnect() throws Exception {
final CompletableFuture<JobID> disconnectTaskExecutorFuture = new CompletableFuture<>();
final TestingTaskExecutorGateway testingTaskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setDisconnectJobManagerConsumer((jobID, throwable) -> disconnectTaskExecutorFuture.complete(jobID)).createTestingTaskExecutorGateway();
try (final TestSetup testSetup = new TestSetup(rpcService, testingFatalErrorHandler, testingTaskExecutorGateway)) {
final JobMasterGateway jobMasterGateway = testSetup.jobMaster.getSelfGateway(JobMasterGateway.class);
jobMasterGateway.disconnectTaskManager(testSetup.getTaskExecutorResourceID(), new Exception("test"));
disconnectTaskExecutorFuture.get();
assertThat(testSetup.getStopTrackingPartitionsTargetResourceId().get(), equalTo(testSetup.getTaskExecutorResourceID()));
}
}
Aggregations