Search in sources :

Example 1 with TestingFatalErrorHandler

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();
    }
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) TestingLeaderElectionService(org.apache.flink.runtime.leaderelection.TestingLeaderElectionService) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) UUID(java.util.UUID) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 2 with TestingFatalErrorHandler

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());
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with TestingFatalErrorHandler

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));
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) Configuration(org.apache.flink.configuration.Configuration) BlobServer(org.apache.flink.runtime.blob.BlobServer) File(java.io.File) Before(org.junit.Before)

Example 4 with TestingFatalErrorHandler

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));
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) CompletableFuture(java.util.concurrent.CompletableFuture) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 5 with TestingFatalErrorHandler

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)));
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) CompletableFuture(java.util.concurrent.CompletableFuture) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Aggregations

TestingFatalErrorHandler (org.apache.flink.runtime.util.TestingFatalErrorHandler)24 Test (org.junit.Test)15 Configuration (org.apache.flink.configuration.Configuration)12 TestingHighAvailabilityServices (org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices)11 Before (org.junit.Before)10 JobID (org.apache.flink.api.common.JobID)8 HeartbeatServices (org.apache.flink.runtime.heartbeat.HeartbeatServices)8 TestingLeaderElectionService (org.apache.flink.runtime.leaderelection.TestingLeaderElectionService)7 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)6 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)6 UUID (java.util.UUID)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 Time (org.apache.flink.api.common.time.Time)5 SettableLeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService)5 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)5 StandaloneCheckpointRecoveryFactory (org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory)4 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)4 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)4 TestingLeaderRetrievalService (org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService)4