public class TestPipeline extends Pipeline
It is recommended to tag hand-selected tests for this purpose using the
@RunnableOnService category annotation, and use a category aware
test executor such as JUnit. Each test run against the service will spin
up and tear down VMs.
In order to run tests on Google Cloud Dataflow, the following conditions must be met:
runIntegrationTestOnService must be set to true.dataflowOptions must contain a JSON delimited list
of pipeline options with all options that the Google Cloud Dataflow service requires.
For example:
[
"--project=mygcpproject",
"--stagingLocation=gs://mygcsbucket/path"
]
Note that the set of pipeline options required can also be test specific.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.