use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class ResourceManagerJobMasterTest method testRegisterJobMasterWithUnmatchedLeaderSessionId1.
/**
* Test receive registration with unmatched leadershipId from job master
*/
@Test
public void testRegisterJobMasterWithUnmatchedLeaderSessionId1() throws Exception {
String jobMasterAddress = "/jobMasterAddress1";
JobID jobID = mockJobMaster(jobMasterAddress);
TestingLeaderElectionService resourceManagerLeaderElectionService = new TestingLeaderElectionService();
UUID jmLeaderID = UUID.randomUUID();
TestingLeaderRetrievalService jobMasterLeaderRetrievalService = new TestingLeaderRetrievalService(jobMasterAddress, jmLeaderID);
TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler();
final ResourceManager resourceManager = createAndStartResourceManager(resourceManagerLeaderElectionService, jobID, jobMasterLeaderRetrievalService, testingFatalErrorHandler);
final UUID rmLeaderSessionId = grantResourceManagerLeadership(resourceManagerLeaderElectionService);
// test throw exception when receive a registration from job master which takes unmatched leaderSessionId
UUID differentLeaderSessionID = UUID.randomUUID();
Future<RegistrationResponse> unMatchedLeaderFuture = resourceManager.registerJobManager(differentLeaderSessionID, jmLeaderID, jobMasterAddress, jobID);
assertTrue(unMatchedLeaderFuture.get(5, TimeUnit.SECONDS) instanceof RegistrationResponse.Decline);
if (testingFatalErrorHandler.hasExceptionOccurred()) {
testingFatalErrorHandler.rethrowError();
}
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class SessionDispatcherLeaderProcessTest method setup.
@BeforeEach
public void setup() {
fatalErrorHandler = new TestingFatalErrorHandler();
jobGraphStore = TestingJobGraphStore.newBuilder().build();
jobResultStore = TestingJobResultStore.builder().build();
dispatcherServiceFactory = createFactoryBasedOnGenericSupplier(() -> TestingDispatcherGatewayService.newBuilder().build());
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class ZooKeeperDefaultDispatcherRunnerTest method setup.
@Before
public void setup() throws IOException {
fatalErrorHandler = new TestingFatalErrorHandler();
configuration = new Configuration();
configuration.setString(HighAvailabilityOptions.HA_MODE, "zookeeper");
configuration.setString(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM, zooKeeperResource.getConnectString());
configuration.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getAbsolutePath());
clusterHaStorageDir = new File(HighAvailabilityServicesUtils.getClusterHighAvailableStoragePath(configuration).toString());
blobServer = new BlobServer(configuration, temporaryFolder.newFolder(), BlobUtils.createBlobStoreFromConfig(configuration));
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class DispatcherResourceManagerComponentTest method unexpectedResourceManagerTermination_failsFatally.
@Test
public void unexpectedResourceManagerTermination_failsFatally() {
final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
final TestingFatalErrorHandler fatalErrorHandler = new TestingFatalErrorHandler();
final TestingResourceManagerService resourceManagerService = TestingResourceManagerService.newBuilder().setTerminationFuture(terminationFuture).build();
createDispatcherResourceManagerComponent(fatalErrorHandler, resourceManagerService);
final FlinkException expectedException = new FlinkException("Expected test exception.");
terminationFuture.completeExceptionally(expectedException);
final Throwable error = fatalErrorHandler.getException();
assertThat(error, containsCause(expectedException));
}
use of org.apache.flink.runtime.util.TestingFatalErrorHandler in project flink by apache.
the class DispatcherResourceManagerComponentTest method unexpectedResourceManagerTermination_ifNotRunning_doesNotFailFatally.
@Test
public void unexpectedResourceManagerTermination_ifNotRunning_doesNotFailFatally() {
final TestingFatalErrorHandler fatalErrorHandler = new TestingFatalErrorHandler();
final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
final TestingResourceManagerService resourceManagerService = TestingResourceManagerService.newBuilder().setTerminationFuture(terminationFuture).withManualTerminationFutureCompletion().build();
final DispatcherResourceManagerComponent dispatcherResourceManagerComponent = createDispatcherResourceManagerComponent(fatalErrorHandler, resourceManagerService);
dispatcherResourceManagerComponent.closeAsync();
final FlinkException expectedException = new FlinkException("Expected test exception.");
terminationFuture.completeExceptionally(expectedException);
final CompletableFuture<Throwable> errorFuture = fatalErrorHandler.getErrorFuture();
assertThat(errorFuture, willNotComplete(Duration.ofMillis(10L)));
}
Aggregations