/** * Runs this {@link Pipeline} using the given {@link PipelineOptions}, using the runner specified * by the options. */ public PipelineResult run(PipelineOptions options) { PipelineRunner<? extends PipelineResult> runner = PipelineRunner.fromOptions(options); // Ensure all of the nodes are fully specified before a PipelineRunner gets access to the // pipeline. LOG.debug("Running {} via {}", this, runner); try { validate(options); return runner.run(this); } catch (UserCodeException e) { // This serves to replace the stack with one that ends here and // is caused by the caught UserCodeException, thereby splicing // out all the stack frames in between the PipelineRunner itself // and where the worker calls into the user's code. throw new PipelineExecutionException(e.getCause()); } }
@Test public void testStableUniqueNameError() { pipeline.getOptions().setStableUniqueNames(CheckEnabled.ERROR); pipeline.apply(Create.of(5, 6, 7)); thrown.expectMessage("do not have stable unique names"); pipeline.apply(Create.of(5, 6, 7)); ((Pipeline) pipeline).validate(pipeline.getOptions()); }
@Test public void testStableUniqueNameWarning() { pipeline.enableAbandonedNodeEnforcement(false); pipeline.getOptions().setStableUniqueNames(CheckEnabled.WARNING); pipeline.apply(Create.of(5, 6, 7)); pipeline.apply(Create.of(5, 6, 7)); ((Pipeline) pipeline).validate(pipeline.getOptions()); logged.verifyWarn("do not have stable unique names"); }
@Test public void testStableUniqueNameOff() { pipeline.enableAbandonedNodeEnforcement(false); pipeline.getOptions().setStableUniqueNames(CheckEnabled.OFF); pipeline.apply(Create.of(5, 6, 7)); pipeline.apply(Create.of(5, 6, 7)); ((Pipeline) pipeline).validate(pipeline.getOptions()); logged.verifyNotLogged("do not have stable unique names"); }