/** * Sets the current {@link ExecutionEnvironment} to be a {@link TestEnvironment}. The test * environment executes the given jobs on a Flink mini cluster with the given default * parallelism and the additional jar files and class paths. * * @param jobExecutor The executor to run the jobs on * @param parallelism The default parallelism */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
@Test public void testCustomSplitJobWithCustomClassLoaderPath() throws IOException, ProgramInvocationException { URL classpath = new File(INPUT_SPLITS_PROG_JAR_FILE).toURI().toURL(); PackagedProgram inputSplitTestProg2 = new PackagedProgram(new File(INPUT_SPLITS_PROG_JAR_FILE)); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.<Path>emptyList(), Collections.singleton(classpath)); inputSplitTestProg2.invokeInteractiveModeForExecution(); }
@Test public void testExternalProgram() throws Exception { TestEnvironment.setAsContext( MINI_CLUSTER, PARALLELISM, Collections.singleton(new Path(JAR_FILE)), Collections.emptyList()); String testData = getClass().getResource(TEST_DATA_FILE).toString(); PackagedProgram program = new PackagedProgram(new File(JAR_FILE), new String[]{testData}); program.invokeInteractiveModeForExecution(); } }
Assert.fail("Error while calling the test program: " + e.getMessage()); } finally { miniClusterResource.getTestEnvironment().setAsContext();
@Test public void testCustomSplitJobWithCustomClassLoaderJar() throws IOException, ProgramInvocationException { PackagedProgram inputSplitTestProg = new PackagedProgram(new File(INPUT_SPLITS_PROG_JAR_FILE)); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(INPUT_SPLITS_PROG_JAR_FILE)), Collections.<URL>emptyList()); inputSplitTestProg.invokeInteractiveModeForExecution(); }
@Test public void testUserCodeTypeJobWithCustomClassLoader() throws IOException, ProgramInvocationException { PackagedProgram userCodeTypeProg = new PackagedProgram(new File(USERCODETYPE_JAR_PATH)); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(USERCODETYPE_JAR_PATH)), Collections.<URL>emptyList()); userCodeTypeProg.invokeInteractiveModeForExecution(); }
@Before public void setupEnvironment() { TestEnvironment testEnvironment; switch(mode){ case CLUSTER: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().disableObjectReuse(); testEnvironment.setAsContext(); break; case CLUSTER_OBJECT_REUSE: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().enableObjectReuse(); testEnvironment.setAsContext(); break; case COLLECTION: new CollectionTestEnvironment().setAsContext(); break; } }
@Test public void testKMeansJobWithCustomClassLoader() throws IOException, ProgramInvocationException { PackagedProgram kMeansProg = new PackagedProgram( new File(KMEANS_JAR_PATH), new String[] { KMeansData.DATAPOINTS, KMeansData.INITIAL_CENTERS, "25" }); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(KMEANS_JAR_PATH)), Collections.<URL>emptyList()); kMeansProg.invokeInteractiveModeForExecution(); }
@Override public void before() throws Exception { super.before(); clusterClient = createMiniClusterClient(); executionEnvironment = new TestEnvironment(getMiniCluster(), getNumberSlots(), false); executionEnvironment.setAsContext(); TestStreamEnvironment.setAsContext(getMiniCluster(), getNumberSlots()); }
/** * Sets the current {@link ExecutionEnvironment} to be a {@link TestEnvironment}. The test * environment executes the given jobs on a Flink mini cluster with the given default * parallelism and the additional jar files and class paths. * * @param jobExecutor The executor to run the jobs on * @param parallelism The default parallelism */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
/** * Sets the current {@link ExecutionEnvironment} to be a {@link TestEnvironment}. The test * environment executes the given jobs on a Flink mini cluster with the given default * parallelism and the additional jar files and class paths. * * @param miniCluster The mini cluster on which to execute the jobs * @param parallelism The default parallelism */ public static void setAsContext(final LocalFlinkMiniCluster miniCluster, final int parallelism) { setAsContext( miniCluster, parallelism, Collections.<Path>emptyList(), Collections.<URL>emptyList()); }
/** * Sets the current {@link ExecutionEnvironment} to be a {@link TestEnvironment}. The test * environment executes the given jobs on a Flink mini cluster with the given default * parallelism and the additional jar files and class paths. * * @param jobExecutor The executor to run the jobs on * @param parallelism The default parallelism */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
/** * Sets the current {@link ExecutionEnvironment} to be a {@link TestEnvironment}. The test * environment executes the given jobs on a Flink mini cluster with the given default * parallelism and the additional jar files and class paths. * * @param jobExecutor The executor to run the jobs on * @param parallelism The default parallelism */ public static void setAsContext(final JobExecutor jobExecutor, final int parallelism) { setAsContext( jobExecutor, parallelism, Collections.emptyList(), Collections.emptyList()); }
@Before public void setupEnvironment() { switch(mode){ case CLUSTER: new TestEnvironment(cluster, 4, false).setAsContext(); break; case CLUSTER_OBJECT_REUSE: new TestEnvironment(cluster, 4, true).setAsContext(); break; case COLLECTION: new CollectionTestEnvironment().setAsContext(); break; } }
@Before public void setupEnvironment() { TestEnvironment testEnvironment; switch(mode){ case CLUSTER: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().disableObjectReuse(); testEnvironment.setAsContext(); break; case CLUSTER_OBJECT_REUSE: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().enableObjectReuse(); testEnvironment.setAsContext(); break; case COLLECTION: new CollectionTestEnvironment().setAsContext(); break; } }
@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); }
@Before public void setupEnvironment() { TestEnvironment testEnvironment; switch(mode){ case CLUSTER: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().disableObjectReuse(); testEnvironment.setAsContext(); break; case CLUSTER_OBJECT_REUSE: // This only works because of the quirks we built in the TestEnvironment. // We should refactor this in the future!!! testEnvironment = miniClusterResource.getTestEnvironment(); testEnvironment.getConfig().enableObjectReuse(); testEnvironment.setAsContext(); break; case COLLECTION: new CollectionTestEnvironment().setAsContext(); break; } }
/** * Creates a new instance of {@link GradoopFlinkTestBase}. */ public GradoopFlinkTestBase() { TestEnvironment testEnv = new TestEnvironment(CLUSTER, DEFAULT_PARALLELISM, false); // makes ExecutionEnvironment.getExecutionEnvironment() return this instance testEnv.setAsContext(); this.env = testEnv; this.graphLayoutFactory = new GVEGraphLayoutFactory(); this.collectionLayoutFactory = new GVECollectionLayoutFactory(); }
@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()); }