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 the service will spin up and tear down a single VM.
In order to run tests on the dataflow pipeline service, the following conditions must be met:
Use DataflowAssert 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 = ...
DataflowAssert.that(output)
.containsInAnyOrder(1, 2, 3, 4);
p.run();
Pipeline.PipelineExecutionException, Pipeline.PipelineVisitor| Modifier and Type | Method and Description |
|---|---|
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. |
boolean |
supportsDynamicWorkRebalancing()
Returns whether a
TestPipeline supports dynamic work rebalancing, and thus tests
of dynamic work rebalancing are expected to pass. |
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 DataflowAssert to add tests, then call
Pipeline.run() to execute the pipeline and check the tests.
public static TestPipeline fromOptions(PipelineOptions options)
public boolean supportsDynamicWorkRebalancing()
TestPipeline supports dynamic work rebalancing, and thus tests
of dynamic work rebalancing are expected to pass.public PipelineResult run()
TestPipeline, unwrapping any AssertionError
that is raised during testing.public static PipelineOptions testingPipelineOptions()
PipelineOptions for testing.