public int getParallelism() { return isCollectionExecution ? 1 : miniClusterResource.getNumberSlots(); }
private void startJobExecutorService(MiniClusterType miniClusterType) throws Exception { switch (miniClusterType) { case LEGACY: startLegacyMiniCluster(); break; case NEW: startMiniCluster(); break; default: throw new FlinkRuntimeException("Unknown MiniClusterType " + miniClusterType + '.'); } }
private List<String> runTestPipeline(int parallelism, String savepoint, Function<DataStream<String>, DataStream<String>> pipelinerBuilder) throws Exception { if (!actions.isEmpty() && actions.getLast() instanceof CancelJob && ((CancelJob) actions.getLast()).isClusterActionTriggered()) { cancelJob(); } jobGraph = createJobGraph(parallelism, pipelinerBuilder).getStreamGraph().getJobGraph(); if (savepoint != null) { jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepoint)); } jobID = jobGraph.getJobID(); MiniClusterResourceFactory clusterFactory = createCluster(1, 2); MiniClusterResource cluster = clusterFactory.get(); cluster.before(); client = cluster.getClusterClient(); try { // client.setDetached(true); client.submitJob(jobGraph, BravoTestPipeline.class.getClassLoader()); } catch (ProgramInvocationException pie) { if (!pie.getMessage().contains("Job was cancelled") && !pie.getCause().getMessage().contains("Job was cancelled")) { throw pie; } } finally { cluster.after(); } return CollectingSink.OUTPUT; }
ExecutionEnvironment env = miniClusterResource.getTestEnvironment(); env.getConfig().disableObjectReuse();
public MiniClusterResource get() { return new MiniClusterResource( new MiniClusterResourceConfiguration.Builder() .setConfiguration(config) .setNumberTaskManagers(numTaskManagers) .setNumberSlotsPerTaskManager(numSlotsPerTaskManager) .build()); } }
@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); }
TestEnvironment env = miniClusterResource.getTestEnvironment(); env.getConfig().enableObjectReuse();
Assert.fail("Error while calling the test program: " + e.getMessage()); } finally { miniClusterResource.getTestEnvironment().setAsContext();
@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; } }