Search in sources :

Example 21 with MiniClusterWithClientResource

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

the class NettyEpollITCase method trySetUpCluster.

private MiniClusterWithClientResource trySetUpCluster() throws Exception {
    try {
        Configuration config = new Configuration();
        config.setString(NettyShuffleEnvironmentOptions.TRANSPORT_TYPE, "epoll");
        MiniClusterWithClientResource cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(NUM_TASK_MANAGERS).setNumberSlotsPerTaskManager(1).build());
        cluster.before();
        return cluster;
    } catch (UnsatisfiedLinkError ex) {
        // If we failed to init netty because we are not on Linux platform, abort the test.
        if (findThrowableWithMessage(ex, "Only supported on Linux").isPresent()) {
            throw new AssumptionViolatedException("This test is only supported on linux");
        }
        throw ex;
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) AssumptionViolatedException(org.junit.AssumptionViolatedException) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration)

Example 22 with MiniClusterWithClientResource

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

the class ChangelogCompatibilityITCase method before.

@Before
public void before() throws Exception {
    checkpointDir = TEMPORARY_FOLDER.newFolder();
    savepointDir = TEMPORARY_FOLDER.newFolder();
    Configuration config = new Configuration();
    config.setString(CHECKPOINTS_DIRECTORY, pathToString(checkpointDir));
    config.setString(SAVEPOINT_DIRECTORY, pathToString(savepointDir));
    FsStateChangelogStorageFactory.configure(config, TEMPORARY_FOLDER.newFolder());
    miniClusterResource = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(11).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 23 with MiniClusterWithClientResource

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

the class UnalignedCheckpointStressITCase method setup.

@Before
public void setup() throws Exception {
    Configuration configuration = new Configuration();
    File folder = temporaryFolder.getRoot();
    configuration.set(CHECKPOINTS_DIRECTORY, folder.toURI().toString());
    configuration.set(MAX_RETAINED_CHECKPOINTS, 1);
    // 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, changelogFolder.newFolder());
    cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(configuration).setNumberTaskManagers(NUM_TASK_MANAGERS).setNumberSlotsPerTaskManager(NUM_TASK_SLOTS).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 24 with MiniClusterWithClientResource

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

the class RegionFailoverITCase method setup.

@Before
public void setup() throws Exception {
    Configuration configuration = new Configuration();
    configuration.setString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, "region");
    configuration.setString(HighAvailabilityOptions.HA_MODE, TestingHAFactory.class.getName());
    cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(configuration).setNumberTaskManagers(2).setNumberSlotsPerTaskManager(2).build());
    cluster.before();
    jobFailedCnt.set(0);
    numCompletedCheckpoints.set(0);
}
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 25 with MiniClusterWithClientResource

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

the class SavepointFormatITCase method testTriggerSavepointAndResumeWithFileBasedCheckpointsAndRelocateBasePath.

@ParameterizedTest(name = "[{index}] {0}, {1}")
@MethodSource("parameters")
public void testTriggerSavepointAndResumeWithFileBasedCheckpointsAndRelocateBasePath(SavepointFormatType formatType, StateBackendConfig stateBackendConfig) throws Exception {
    final int numTaskManagers = 2;
    final int numSlotsPerTaskManager = 2;
    final Configuration config = stateBackendConfig.getConfiguration();
    config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointsDir.toUri().toString());
    final MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(numTaskManagers).setNumberSlotsPerTaskManager(numSlotsPerTaskManager).build());
    miniClusterResource.before();
    try {
        final String savepointPath = submitJobAndTakeSavepoint(miniClusterResource, formatType, stateBackendConfig.getCheckpointsBeforeSavepoint(), config);
        final CheckpointMetadata metadata = loadCheckpointMetadata(savepointPath);
        final OperatorState operatorState = metadata.getOperatorStates().stream().filter(hasKeyedState()).findFirst().get();
        operatorState.getStates().stream().flatMap(subtaskState -> subtaskState.getManagedKeyedState().stream()).forEach(handle -> validateState(handle, formatType, stateBackendConfig));
        relocateAndVerify(miniClusterResource, savepointPath, renamedSavepointDir, config);
    } finally {
        miniClusterResource.after();
    }
}
Also used : KeyGroupsStateHandle(org.apache.flink.runtime.state.KeyGroupsStateHandle) BiFunction(java.util.function.BiFunction) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) IncrementalRemoteKeyedStateHandle(org.apache.flink.runtime.state.IncrementalRemoteKeyedStateHandle) MemorySize(org.apache.flink.configuration.MemorySize) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) BasicTypeInfo(org.apache.flink.api.common.typeinfo.BasicTypeInfo) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) CommonTestUtils.waitForAllTaskRunning(org.apache.flink.runtime.testutils.CommonTestUtils.waitForAllTaskRunning) Arrays.asList(java.util.Arrays.asList) ChangelogStateBackendHandle(org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle) Level(org.slf4j.event.Level) Checkpoints(org.apache.flink.runtime.checkpoint.Checkpoints) Path(java.nio.file.Path) MethodSource(org.junit.jupiter.params.provider.MethodSource) LoggerAuditingExtension(org.apache.flink.testutils.logging.LoggerAuditingExtension) Predicate(java.util.function.Predicate) CompletedCheckpointStorageLocation(org.apache.flink.runtime.state.CompletedCheckpointStorageLocation) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) Arguments(org.junit.jupiter.params.provider.Arguments) CheckpointingOptions(org.apache.flink.configuration.CheckpointingOptions) CheckpointMetadata(org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata) List(java.util.List) ValueState(org.apache.flink.api.common.state.ValueState) ClusterClient(org.apache.flink.client.program.ClusterClient) TempDir(org.junit.jupiter.api.io.TempDir) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) DataInputStream(java.io.DataInputStream) SavepointFormatType(org.apache.flink.core.execution.SavepointFormatType) AbstractFsCheckpointStorageAccess(org.apache.flink.runtime.state.filesystem.AbstractFsCheckpointStorageAccess) RestoreMode(org.apache.flink.runtime.jobgraph.RestoreMode) RichMapFunction(org.apache.flink.api.common.functions.RichMapFunction) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) LinkedList(java.util.LinkedList) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) DiscardingSink(org.apache.flink.streaming.api.functions.sink.DiscardingSink) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) StateChangelogOptions(org.apache.flink.configuration.StateChangelogOptions) Configuration(org.apache.flink.configuration.Configuration) IOException(java.io.IOException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) JobID(org.apache.flink.api.common.JobID) RuntimeExecutionMode(org.apache.flink.api.common.RuntimeExecutionMode) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) SavepointKeyedStateHandle(org.apache.flink.runtime.state.SavepointKeyedStateHandle) StateBackendOptions(org.apache.flink.configuration.StateBackendOptions) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterWithClientResource(org.apache.flink.test.util.MiniClusterWithClientResource) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState) CheckpointMetadata(org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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