Search in sources :

Example 36 with MiniCluster

use of org.apache.flink.runtime.minicluster.MiniCluster in project flink by apache.

the class FileExecutionGraphInfoStoreTest method testPutSuspendedJobOnClusterShutdown.

/**
 * Tests that a session cluster can terminate gracefully when jobs are still running.
 */
@Test
public void testPutSuspendedJobOnClusterShutdown() throws Exception {
    File rootDir = temporaryFolder.newFolder();
    try (final MiniCluster miniCluster = new ExecutionGraphInfoStoreTestUtils.PersistingMiniCluster(new MiniClusterConfiguration.Builder().build(), rootDir)) {
        miniCluster.start();
        final JobVertex vertex = new JobVertex("blockingVertex");
        // The adaptive scheduler expects that every vertex has a configured parallelism
        vertex.setParallelism(1);
        vertex.setInvokableClass(ExecutionGraphInfoStoreTestUtils.SignallingBlockingNoOpInvokable.class);
        final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(vertex);
        miniCluster.submitJob(jobGraph);
        ExecutionGraphInfoStoreTestUtils.SignallingBlockingNoOpInvokable.LATCH.await();
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) File(java.io.File) Test(org.junit.Test)

Example 37 with MiniCluster

use of org.apache.flink.runtime.minicluster.MiniCluster in project flink by apache.

the class AbstractHAJobRunITCase method testJobExecutionInHaMode.

@Test
public void testJobExecutionInHaMode(@InjectMiniCluster MiniCluster flinkCluster) throws Exception {
    final JobGraph jobGraph = JobGraphTestUtils.singleNoOpJobGraph();
    // providing a timeout helps making the test fail in case some issue occurred while
    // initializing the cluster
    flinkCluster.submitJob(jobGraph).get(30, TimeUnit.SECONDS);
    final Deadline deadline = Deadline.fromNow(Duration.ofSeconds(30));
    final JobStatus jobStatus = FutureUtils.retrySuccessfulWithDelay(() -> flinkCluster.getJobStatus(jobGraph.getJobID()), Time.milliseconds(10), deadline, status -> flinkCluster.isRunning() && status == JobStatus.FINISHED, TestingUtils.defaultScheduledExecutor()).get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS);
    assertThat(jobStatus).isEqualTo(JobStatus.FINISHED);
    runAfterJobTermination();
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) Deadline(org.apache.flink.api.common.time.Deadline) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Configuration(org.apache.flink.configuration.Configuration) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobStatus(org.apache.flink.api.common.JobStatus) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) TestingUtils(org.apache.flink.testutils.TestingUtils) TestLoggerExtension(org.apache.flink.util.TestLoggerExtension) AllCallbackWrapper(org.apache.flink.core.testutils.AllCallbackWrapper) FileSystem(org.apache.flink.core.fs.FileSystem) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) InjectMiniCluster(org.apache.flink.test.junit5.InjectMiniCluster) Duration(java.time.Duration) JobGraphTestUtils(org.apache.flink.runtime.jobgraph.JobGraphTestUtils) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Time(org.apache.flink.api.common.time.Time) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) ZooKeeperExtension(org.apache.flink.runtime.zookeeper.ZooKeeperExtension) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) Deadline(org.apache.flink.api.common.time.Deadline) Test(org.junit.jupiter.api.Test)

Example 38 with MiniCluster

use of org.apache.flink.runtime.minicluster.MiniCluster in project flink by apache.

the class ShuffleMasterTest method testShuffleMasterLifeCycle.

@Test
public void testShuffleMasterLifeCycle() throws Exception {
    try (MiniCluster cluster = new MiniCluster(createClusterConfiguration(false))) {
        cluster.start();
        cluster.executeJobBlocking(createJobGraph());
    }
    assertTrue(TestShuffleMaster.currentInstance.get().closed.get());
    String[] expectedPartitionEvents = new String[] { PARTITION_REGISTRATION_EVENT, PARTITION_REGISTRATION_EVENT, EXTERNAL_PARTITION_RELEASE_EVENT, EXTERNAL_PARTITION_RELEASE_EVENT };
    assertArrayEquals(expectedPartitionEvents, TestShuffleMaster.partitionEvents.toArray());
}
Also used : MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Test(org.junit.Test)

Example 39 with MiniCluster

use of org.apache.flink.runtime.minicluster.MiniCluster in project flink by apache.

the class MemoryExecutionGraphInfoStoreTest method testPutSuspendedJobOnClusterShutdown.

/**
 * Tests that a session cluster can terminate gracefully when jobs are still running.
 */
@Test
public void testPutSuspendedJobOnClusterShutdown() throws Exception {
    Configuration configuration = new Configuration();
    configuration.set(JobManagerOptions.JOB_STORE_TYPE, JobManagerOptions.JobStoreType.Memory);
    try (final MiniCluster miniCluster = new ExecutionGraphInfoStoreTestUtils.PersistingMiniCluster(new MiniClusterConfiguration.Builder().setConfiguration(configuration).build())) {
        miniCluster.start();
        final JobVertex vertex = new JobVertex("blockingVertex");
        // The adaptive scheduler expects that every vertex has a configured parallelism
        vertex.setParallelism(1);
        vertex.setInvokableClass(ExecutionGraphInfoStoreTestUtils.SignallingBlockingNoOpInvokable.class);
        final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(vertex);
        miniCluster.submitJob(jobGraph);
        ExecutionGraphInfoStoreTestUtils.SignallingBlockingNoOpInvokable.LATCH.await();
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) Test(org.junit.Test)

Example 40 with MiniCluster

use of org.apache.flink.runtime.minicluster.MiniCluster in project flink by apache.

the class CoordinatorEventsExactlyOnceITCase method startMiniCluster.

@BeforeClass
public static void startMiniCluster() throws Exception {
    final Configuration config = new Configuration();
    config.setString(RestOptions.BIND_PORT, "0");
    final MiniClusterConfiguration clusterCfg = new MiniClusterConfiguration.Builder().setNumTaskManagers(2).setNumSlotsPerTaskManager(1).setConfiguration(config).build();
    miniCluster = new MiniCluster(clusterCfg);
    miniCluster.start();
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) Configuration(org.apache.flink.configuration.Configuration) JobGraphBuilder(org.apache.flink.runtime.jobgraph.JobGraphBuilder) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) BeforeClass(org.junit.BeforeClass)

Aggregations

MiniCluster (org.apache.flink.runtime.minicluster.MiniCluster)44 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)21 Configuration (org.apache.flink.configuration.Configuration)20 Test (org.junit.Test)18 MiniClusterConfiguration (org.apache.flink.runtime.minicluster.MiniClusterConfiguration)17 JobID (org.apache.flink.api.common.JobID)14 JobResult (org.apache.flink.runtime.jobmaster.JobResult)13 Deadline (org.apache.flink.api.common.time.Deadline)9 Duration (java.time.Duration)6 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)6 Test (org.junit.jupiter.api.Test)6 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)5 JobStatus (org.apache.flink.api.common.JobStatus)4 JobClient (org.apache.flink.core.execution.JobClient)4 EmbeddedHaServicesWithLeadershipControl (org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedHaServicesWithLeadershipControl)4 TestingMiniCluster (org.apache.flink.runtime.minicluster.TestingMiniCluster)4 TestingMiniClusterConfiguration (org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration)4 File (java.io.File)3 TimeUnit (java.util.concurrent.TimeUnit)3 MiniClusterClient (org.apache.flink.client.program.MiniClusterClient)3