Search in sources :

Example 1 with TestingResourceManagerFactory

use of org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory in project flink by apache.

the class ClusterEntrypointTest method testCloseAsyncShouldNotDeregisterApp.

@Test
public void testCloseAsyncShouldNotDeregisterApp() throws Exception {
    final CompletableFuture<Void> deregisterFuture = new CompletableFuture<>();
    final TestingResourceManagerFactory testingResourceManagerFactory = new TestingResourceManagerFactory.Builder().setInternalDeregisterApplicationConsumer((ignored1, ignored2, ignore3) -> deregisterFuture.complete(null)).build();
    final TestingEntryPoint testingEntryPoint = new TestingEntryPoint.Builder().setConfiguration(flinkConfig).setResourceManagerFactory(testingResourceManagerFactory).build();
    final CompletableFuture<ApplicationStatus> appStatusFuture = startClusterEntrypoint(testingEntryPoint);
    testingEntryPoint.closeAsync();
    assertThat(appStatusFuture.get(TIMEOUT_MS, TimeUnit.MILLISECONDS), is(ApplicationStatus.UNKNOWN));
    assertThat(deregisterFuture.isDone(), is(false));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PartialDispatcherServices(org.apache.flink.runtime.dispatcher.PartialDispatcherServices) JobPersistenceComponentFactory(org.apache.flink.runtime.jobmanager.JobPersistenceComponentFactory) ClusterOptions(org.apache.flink.configuration.ClusterOptions) RpcSystemUtils(org.apache.flink.runtime.rpc.RpcSystemUtils) TestingResourceManagerFactory(org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory) TestingClusterEntrypointProcess(org.apache.flink.runtime.testutils.TestingClusterEntrypointProcess) TestLogger(org.apache.flink.util.TestLogger) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) HighAvailabilityServices(org.apache.flink.runtime.highavailability.HighAvailabilityServices) ScheduledExecutor(org.apache.flink.util.concurrent.ScheduledExecutor) DispatcherRunner(org.apache.flink.runtime.dispatcher.runner.DispatcherRunner) UUID(java.util.UUID) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) Executors(java.util.concurrent.Executors) ResourceManagerFactory(org.apache.flink.runtime.resourcemanager.ResourceManagerFactory) Assert.assertFalse(org.junit.Assert.assertFalse) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestJvmProcess(org.apache.flink.runtime.testutils.TestJvmProcess) SchedulerExecutionMode(org.apache.flink.configuration.SchedulerExecutionMode) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) LeaderElectionService(org.apache.flink.runtime.leaderelection.LeaderElectionService) CompletableFuture(java.util.concurrent.CompletableFuture) DispatcherRunnerFactory(org.apache.flink.runtime.dispatcher.runner.DispatcherRunnerFactory) RpcService(org.apache.flink.runtime.rpc.RpcService) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) ExecutionGraphInfoStore(org.apache.flink.runtime.dispatcher.ExecutionGraphInfoStore) DefaultDispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DefaultDispatcherResourceManagerComponentFactory) FatalErrorHandler(org.apache.flink.runtime.rpc.FatalErrorHandler) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) Before(org.junit.Before) DispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DispatcherResourceManagerComponentFactory) TestExecutorResource(org.apache.flink.testutils.executor.TestExecutorResource) Executor(java.util.concurrent.Executor) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) TestingDispatcherRunner(org.apache.flink.runtime.dispatcher.runner.TestingDispatcherRunner) Configuration(org.apache.flink.configuration.Configuration) SessionRestEndpointFactory(org.apache.flink.runtime.rest.SessionRestEndpointFactory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) SignalHandler(org.apache.flink.runtime.util.SignalHandler) OperatingSystem(org.apache.flink.util.OperatingSystem) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) MemoryExecutionGraphInfoStore(org.apache.flink.runtime.dispatcher.MemoryExecutionGraphInfoStore) StandaloneResourceManagerFactory(org.apache.flink.runtime.resourcemanager.StandaloneResourceManagerFactory) TemporaryFolder(org.junit.rules.TemporaryFolder) CompletableFuture(java.util.concurrent.CompletableFuture) TestingResourceManagerFactory(org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) Test(org.junit.Test)

Example 2 with TestingResourceManagerFactory

use of org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory in project flink by apache.

the class ClusterEntrypointTest method testClusterFinishedNormallyShouldDeregisterAppAndCleanupHAData.

@Test
public void testClusterFinishedNormallyShouldDeregisterAppAndCleanupHAData() throws Exception {
    final CompletableFuture<Void> deregisterFuture = new CompletableFuture<>();
    final CompletableFuture<Void> closeAndCleanupAllDataFuture = new CompletableFuture<>();
    final CompletableFuture<ApplicationStatus> dispatcherShutDownFuture = new CompletableFuture<>();
    final HighAvailabilityServices testingHaService = new TestingHighAvailabilityServicesBuilder().setCloseAndCleanupAllDataFuture(closeAndCleanupAllDataFuture).build();
    final TestingResourceManagerFactory testingResourceManagerFactory = new TestingResourceManagerFactory.Builder().setInternalDeregisterApplicationConsumer((ignored1, ignored2, ignore3) -> deregisterFuture.complete(null)).setInitializeConsumer((ignore) -> dispatcherShutDownFuture.complete(ApplicationStatus.SUCCEEDED)).build();
    final TestingDispatcherRunnerFactory testingDispatcherRunnerFactory = new TestingDispatcherRunnerFactory.Builder().setShutDownFuture(dispatcherShutDownFuture).build();
    final TestingEntryPoint testingEntryPoint = new TestingEntryPoint.Builder().setConfiguration(flinkConfig).setResourceManagerFactory(testingResourceManagerFactory).setDispatcherRunnerFactory(testingDispatcherRunnerFactory).setHighAvailabilityServices(testingHaService).build();
    final CompletableFuture<ApplicationStatus> appStatusFuture = startClusterEntrypoint(testingEntryPoint);
    assertThat(appStatusFuture.get(TIMEOUT_MS, TimeUnit.MILLISECONDS), is(ApplicationStatus.SUCCEEDED));
    assertThat(deregisterFuture.isDone(), is(true));
    assertThat(closeAndCleanupAllDataFuture.isDone(), is(true));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PartialDispatcherServices(org.apache.flink.runtime.dispatcher.PartialDispatcherServices) JobPersistenceComponentFactory(org.apache.flink.runtime.jobmanager.JobPersistenceComponentFactory) ClusterOptions(org.apache.flink.configuration.ClusterOptions) RpcSystemUtils(org.apache.flink.runtime.rpc.RpcSystemUtils) TestingResourceManagerFactory(org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory) TestingClusterEntrypointProcess(org.apache.flink.runtime.testutils.TestingClusterEntrypointProcess) TestLogger(org.apache.flink.util.TestLogger) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) HighAvailabilityServices(org.apache.flink.runtime.highavailability.HighAvailabilityServices) ScheduledExecutor(org.apache.flink.util.concurrent.ScheduledExecutor) DispatcherRunner(org.apache.flink.runtime.dispatcher.runner.DispatcherRunner) UUID(java.util.UUID) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) Executors(java.util.concurrent.Executors) ResourceManagerFactory(org.apache.flink.runtime.resourcemanager.ResourceManagerFactory) Assert.assertFalse(org.junit.Assert.assertFalse) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestJvmProcess(org.apache.flink.runtime.testutils.TestJvmProcess) SchedulerExecutionMode(org.apache.flink.configuration.SchedulerExecutionMode) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) LeaderElectionService(org.apache.flink.runtime.leaderelection.LeaderElectionService) CompletableFuture(java.util.concurrent.CompletableFuture) DispatcherRunnerFactory(org.apache.flink.runtime.dispatcher.runner.DispatcherRunnerFactory) RpcService(org.apache.flink.runtime.rpc.RpcService) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) ExecutionGraphInfoStore(org.apache.flink.runtime.dispatcher.ExecutionGraphInfoStore) DefaultDispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DefaultDispatcherResourceManagerComponentFactory) FatalErrorHandler(org.apache.flink.runtime.rpc.FatalErrorHandler) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) Before(org.junit.Before) DispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DispatcherResourceManagerComponentFactory) TestExecutorResource(org.apache.flink.testutils.executor.TestExecutorResource) Executor(java.util.concurrent.Executor) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) TestingDispatcherRunner(org.apache.flink.runtime.dispatcher.runner.TestingDispatcherRunner) Configuration(org.apache.flink.configuration.Configuration) SessionRestEndpointFactory(org.apache.flink.runtime.rest.SessionRestEndpointFactory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) SignalHandler(org.apache.flink.runtime.util.SignalHandler) OperatingSystem(org.apache.flink.util.OperatingSystem) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) MemoryExecutionGraphInfoStore(org.apache.flink.runtime.dispatcher.MemoryExecutionGraphInfoStore) StandaloneResourceManagerFactory(org.apache.flink.runtime.resourcemanager.StandaloneResourceManagerFactory) TemporaryFolder(org.junit.rules.TemporaryFolder) TestingResourceManagerFactory(org.apache.flink.runtime.resourcemanager.TestingResourceManagerFactory) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) HighAvailabilityServices(org.apache.flink.runtime.highavailability.HighAvailabilityServices) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) Test(org.junit.Test)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 UUID (java.util.UUID)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Executor (java.util.concurrent.Executor)2 Executors (java.util.concurrent.Executors)2 TimeUnit (java.util.concurrent.TimeUnit)2 ClusterOptions (org.apache.flink.configuration.ClusterOptions)2 Configuration (org.apache.flink.configuration.Configuration)2 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)2 JobManagerOptions (org.apache.flink.configuration.JobManagerOptions)2 SchedulerExecutionMode (org.apache.flink.configuration.SchedulerExecutionMode)2 ApplicationStatus (org.apache.flink.runtime.clusterframework.ApplicationStatus)2 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)2 ExecutionGraphInfoStore (org.apache.flink.runtime.dispatcher.ExecutionGraphInfoStore)2 MemoryExecutionGraphInfoStore (org.apache.flink.runtime.dispatcher.MemoryExecutionGraphInfoStore)2 PartialDispatcherServices (org.apache.flink.runtime.dispatcher.PartialDispatcherServices)2 DispatcherRunner (org.apache.flink.runtime.dispatcher.runner.DispatcherRunner)2 DispatcherRunnerFactory (org.apache.flink.runtime.dispatcher.runner.DispatcherRunnerFactory)2 TestingDispatcherRunner (org.apache.flink.runtime.dispatcher.runner.TestingDispatcherRunner)2