/** * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on * the given cluster with the given default parallelism. * * @param jobExecutor The executor to execute the jobs on * @param parallelism The default parallelism for the test programs. */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
@Test public void testStreamingCustomSplitJobWithCustomClassLoader() throws IOException, ProgramInvocationException { PackagedProgram streamingInputSplitTestProg = new PackagedProgram(new File(STREAMING_INPUT_SPLITS_PROG_JAR_FILE)); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(STREAMING_INPUT_SPLITS_PROG_JAR_FILE)), Collections.<URL>emptyList()); streamingInputSplitTestProg.invokeInteractiveModeForExecution(); }
@Test public void testStreamingClassloaderJobWithCustomClassLoader() throws IOException, ProgramInvocationException { // regular streaming job PackagedProgram streamingProg = new PackagedProgram(new File(STREAMING_PROG_JAR_FILE)); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(STREAMING_PROG_JAR_FILE)), Collections.<URL>emptyList()); streamingProg.invokeInteractiveModeForExecution(); }
@Override public void before() throws Exception { super.before(); clusterClient = createMiniClusterClient(); executionEnvironment = new TestEnvironment(getMiniCluster(), getNumberSlots(), false); executionEnvironment.setAsContext(); TestStreamEnvironment.setAsContext(getMiniCluster(), getNumberSlots()); }
@Test public void testCheckpointingCustomKvStateJobWithCustomClassLoader() throws IOException, ProgramInvocationException { File checkpointDir = FOLDER.newFolder(); File outputDir = FOLDER.newFolder(); final PackagedProgram program = new PackagedProgram( new File(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH), new String[] { checkpointDir.toURI().toString(), outputDir.toURI().toString() }); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)), Collections.<URL>emptyList()); expectedException.expectCause( Matchers.<Throwable>hasProperty("cause", isA(SuccessException.class))); program.invokeInteractiveModeForExecution(); }
TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism,
}); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism,
/** * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on * the given cluster with the given default parallelism. * * @param cluster The test cluster to run the test program on. * @param parallelism The default parallelism for the test programs. */ public static void setAsContext(final LocalFlinkMiniCluster cluster, final int parallelism) { setAsContext( cluster, parallelism, Collections.<Path>emptyList(), Collections.<URL>emptyList()); }
/** * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on * the given cluster with the given default parallelism. * * @param jobExecutor The executor to execute the jobs on * @param parallelism The default parallelism for the test programs. */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
/** * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on * the given cluster with the given default parallelism. * * @param jobExecutor The executor to execute the jobs on * @param parallelism The default parallelism for the test programs. */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
/** * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on * the given cluster with the given default parallelism. * * @param jobExecutor The executor to execute the jobs on * @param parallelism The default parallelism for the test programs. */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
@BeforeClass public static void setup() throws Exception { LOG.info("In StreamingMultipleProgramsTestBase: Starting FlinkMiniCluster "); cluster = TestBaseUtils.startCluster(1, DEFAULT_PARALLELISM, false, false, true); TestStreamEnvironment.setAsContext(cluster, DEFAULT_PARALLELISM); }
@Override protected void executeEnvironment() throws Throwable { TestStreamEnvironment.setAsContext(cluster, parallelism); try { execute(); } finally { TestStreamEnvironment.unsetAsContext(); } } };
@Override protected void executeEnvironment() throws Throwable { TestStreamEnvironment.setAsContext(executor, parallelism); try { execute(); } finally { TestStreamEnvironment.unsetAsContext(); } } };
TestStreamEnvironment.setAsContext(this.executor, getParallelism());
@Override public void before() throws Exception { temporaryFolder.create(); startJobExecutorService(miniClusterType); numberSlots = miniClusterResourceConfiguration.getNumberSlotsPerTaskManager() * miniClusterResourceConfiguration.getNumberTaskManagers(); executionEnvironment = new TestEnvironment(jobExecutorService, numberSlots, false); executionEnvironment.setAsContext(); TestStreamEnvironment.setAsContext(jobExecutorService, numberSlots); }
@Override public void before() throws Exception { super.before(); clusterClient = createMiniClusterClient(); executionEnvironment = new TestEnvironment(getMiniCluster(), getNumberSlots(), false); executionEnvironment.setAsContext(); TestStreamEnvironment.setAsContext(getMiniCluster(), getNumberSlots()); }
@Override public void before() throws Exception { super.before(); clusterClient = createMiniClusterClient(); executionEnvironment = new TestEnvironment(getMiniCluster(), getNumberSlots(), false); executionEnvironment.setAsContext(); TestStreamEnvironment.setAsContext(getMiniCluster(), getNumberSlots()); }
@BeforeClass public static void beforeClass() throws Exception { final int parallelism = 4; Configuration config = new Configuration(); // Avoid port collision in parallel tests config.setInteger(RestOptions.PORT, 0); config.setString(CheckpointingOptions.STATE_BACKEND, "filesystem"); // It is necessary to configure the checkpoint directory for the state backend, // even though we only create savepoints in this test. config.setString( CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file://" + tempFolder.getRoot().getAbsolutePath()); // Checkpoints will go into a subdirectory of this directory config.setString( CheckpointingOptions.SAVEPOINT_DIRECTORY, "file://" + tempFolder.getRoot().getAbsolutePath()); MiniClusterConfiguration clusterConfig = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(2) .setNumSlotsPerTaskManager(2) .build(); flinkCluster = new MiniCluster(clusterConfig); flinkCluster.start(); TestStreamEnvironment.setAsContext(flinkCluster, parallelism); }