|
33 | 33 | import pytest |
34 | 34 |
|
35 | 35 | import apache_beam as beam |
36 | | -from apache_beam.options.pipeline_options import PipelineOptions |
| 36 | +from apache_beam.options.pipeline_options import PortableOptions |
37 | 37 | from apache_beam.options.pipeline_options import StandardOptions |
38 | 38 | from apache_beam.testing.test_pipeline import TestPipeline |
39 | 39 | from apache_beam.typehints.row_type import RowTypeConstraint |
@@ -214,12 +214,21 @@ def subscribe(): |
214 | 214 | publisher.start() |
215 | 215 | subscriber.start() |
216 | 216 |
|
217 | | - options = PipelineOptions([ |
218 | | - '--runner=PrismRunner', |
219 | | - '--environment_type=LOOPBACK', |
220 | | - '--streaming', |
221 | | - ]) |
222 | | - p = TestPipeline(options=options) |
| 217 | + # MqttIO read is unbounded, so this pipeline runs in streaming mode and |
| 218 | + # never terminates on its own. Amend the harness-provided pipeline options |
| 219 | + # rather than discarding them: enable streaming, run non-blocking so the |
| 220 | + # observe-then-cancel logic below can execute, and target the Prism portable |
| 221 | + # runner. The latter is required because SwitchingDirectRunner disables its |
| 222 | + # Prism delegation for pipelines containing external (cross-language) |
| 223 | + # transforms (see runners/direct/direct_runner.py) and falls back to the |
| 224 | + # BundleBasedDirectRunner, which cannot execute an unbounded read. |
| 225 | + # The runner is instantiated during TestPipeline construction, so it must be |
| 226 | + # passed to the constructor; the remaining harness-provided options are |
| 227 | + # preserved and only amended (streaming + LOOPBACK environment) afterwards. |
| 228 | + p = TestPipeline(runner='PrismRunner', blocking=False) |
| 229 | + p.get_pipeline_options().view_as(StandardOptions).streaming = True |
| 230 | + p.get_pipeline_options().view_as( |
| 231 | + PortableOptions).environment_type = 'LOOPBACK' |
223 | 232 | p.not_use_test_runner_api = True |
224 | 233 | _ = ( |
225 | 234 | p |
|
0 commit comments