Search in sources :

Example 31 with MiniClusterWithClientResource

use of org.apache.flink.test.util.MiniClusterWithClientResource in project flink by apache.

the class RescalingITCase method setup.

@Before
public void setup() throws Exception {
    // detect parameter change
    if (currentBackend != backend) {
        shutDownExistingCluster();
        currentBackend = backend;
        Configuration config = new Configuration();
        final File checkpointDir = temporaryFolder.newFolder();
        final File savepointDir = temporaryFolder.newFolder();
        config.setString(StateBackendOptions.STATE_BACKEND, currentBackend);
        config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir.toURI().toString());
        config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir.toURI().toString());
        config.setInteger(NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_PER_CHANNEL, buffersPerChannel);
        cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(numTaskManagers).setNumberSlotsPerTaskManager(numSlots).build());
        cluster.before();
    }
}
Also used : MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) File(java.io.File) Before(org.junit.Before)

Example 32 with MiniClusterWithClientResource

use of org.apache.flink.test.util.MiniClusterWithClientResource in project flink by apache.

the class StreamFaultToleranceTestBase method setup.

@Before
public void setup() throws Exception {
    Configuration configuration = new Configuration();
    switch(failoverStrategy) {
        case RestartPipelinedRegionFailoverStrategy:
            configuration.setString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, "region");
            break;
        case RestartAllFailoverStrategy:
            configuration.setString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, "full");
    }
    // Configure DFS DSTL for this test as it might produce too much GC pressure if
    // ChangelogStateBackend is used.
    // Doing it on cluster level unconditionally as randomization currently happens on the job
    // level (environment); while this factory can only be set on the cluster level.
    FsStateChangelogStorageFactory.configure(configuration, tempFolder.newFolder());
    cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(configuration).setNumberTaskManagers(NUM_TASK_MANAGERS).setNumberSlotsPerTaskManager(NUM_TASK_SLOTS).build());
    cluster.before();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) Before(org.junit.Before)

Example 33 with MiniClusterWithClientResource

use of org.apache.flink.test.util.MiniClusterWithClientResource in project flink by apache.

the class IncrementalStateReuseAfterFailureITCase method before.

@Before
public void before() throws Exception {
    Configuration configuration = new Configuration();
    FsStateChangelogStorageFactory.configure(configuration, temporaryFolder.newFolder());
    miniClusterResource = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(configuration).setNumberTaskManagers(1).setNumberSlotsPerTaskManager(1).build());
    miniClusterResource.before();
}
Also used : MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) Before(org.junit.Before)

Example 34 with MiniClusterWithClientResource

use of org.apache.flink.test.util.MiniClusterWithClientResource in project flink by apache.

the class SavepointITCase method testStopWithSavepointWithDrainCallsFinishBeforeSnapshotState.

@Test
public void testStopWithSavepointWithDrainCallsFinishBeforeSnapshotState() throws Exception {
    int sinkParallelism = 5;
    MiniClusterWithClientResource cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setNumberSlotsPerTaskManager(sinkParallelism + 1).build());
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
    env.addSource(new InfiniteTestSource()).setParallelism(1).name("Infinite Source").addSink(new FinishingSink<>()).setParallelism(sinkParallelism);
    final JobGraph jobGraph = env.getStreamGraph().getJobGraph();
    cluster.before();
    try {
        ClusterClient<?> client = cluster.getClusterClient();
        client.submitJob(jobGraph).get();
        waitUntilAllTasksAreRunning(cluster.getRestClusterClient(), jobGraph.getJobID());
        client.stopWithSavepoint(jobGraph.getJobID(), true, savepointDir.getAbsolutePath(), SavepointFormatType.CANONICAL).get();
    // there should be no exceptions and the finish should've been called in the
    // FinishingSink
    } finally {
        cluster.after();
    }
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Aggregations

MiniClusterWithClientResource (org.apache.flink.test.util.MiniClusterWithClientResource)34 MiniClusterResourceConfiguration (org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration)26 Configuration (org.apache.flink.configuration.Configuration)24 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)14 Before (org.junit.Before)13 Test (org.junit.Test)13 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)12 JobID (org.apache.flink.api.common.JobID)9 File (java.io.File)8 ExecutionException (java.util.concurrent.ExecutionException)7 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)7 IOException (java.io.IOException)6 Optional (java.util.Optional)6 RichMapFunction (org.apache.flink.api.common.functions.RichMapFunction)6 List (java.util.List)5 CheckpointingOptions (org.apache.flink.configuration.CheckpointingOptions)5 MemorySize (org.apache.flink.configuration.MemorySize)5 StateBackendOptions (org.apache.flink.configuration.StateBackendOptions)5 FlinkJobNotFoundException (org.apache.flink.runtime.messages.FlinkJobNotFoundException)5 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)5