public class TestPipeline extends Pipeline
It is recommended to tag hand-selected tests for this purpose using the
RunnableOnService Category annotation, as each test run against a pipeline runner
will utilize resources of that pipeline runner.
In order to run tests on a pipeline runner, the following conditions must be met:
[
"--runner=org.apache.beam.runners.dataflow.testing.TestDataflowRunner",
"--project=mygcpproject",
"--stagingLocation=gs://mygcsbucket/path"
]
Note that the set of pipeline options required is pipeline runner specific.
Use PAssert for tests, as it integrates with this test harness in both direct and
remote execution modes. For example:
Pipeline p = TestPipeline.create();
PCollection<Integer> output = ...
PAssert.that(output)
.containsInAnyOrder(1, 2, 3, 4);
p.run();
For pipeline runners, it is required that they must throw an AssertionError
containing the message from the PAssert that failed.
Pipeline.PipelineExecutionException, Pipeline.PipelineVisitor| Modifier and Type | Method and Description |
|---|---|
static String[] |
convertToArgs(PipelineOptions options) |
static TestPipeline |
create()
Creates and returns a new test pipeline.
|
static TestPipeline |
fromOptions(PipelineOptions options) |
PipelineResult |
run()
Runs this
TestPipeline, unwrapping any AssertionError
that is raised during testing. |
static PipelineOptions |
testingPipelineOptions()
Creates
PipelineOptions for testing. |
String |
toString() |
addValueInternal, apply, apply, applyTransform, applyTransform, begin, create, getCoderRegistry, getFullNameForTesting, getOptions, getRunner, setCoderRegistry, traverseTopologicallypublic static TestPipeline create()
Use PAssert to add tests, then call
Pipeline.run() to execute the pipeline and check the tests.
public static TestPipeline fromOptions(PipelineOptions options)
public PipelineResult run()
TestPipeline, unwrapping any AssertionError
that is raised during testing.public static PipelineOptions testingPipelineOptions()
PipelineOptions for testing.public static String[] convertToArgs(PipelineOptions options)