Skip to content

Commit 74ac8b8

Browse files
committed
Uses test pipeline
1 parent 702d73e commit 74ac8b8

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

sdks/java/extensions/python/src/test/java/org/apache/beam/sdk/extensions/python/PythonExternalTransformTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.beam.sdk.schemas.SchemaTranslation;
3434
import org.apache.beam.sdk.schemas.logicaltypes.MicrosInstant;
3535
import org.apache.beam.sdk.testing.PAssert;
36+
import org.apache.beam.sdk.testing.TestPipeline;
3637
import org.apache.beam.sdk.testing.UsesPythonExpansionService;
3738
import org.apache.beam.sdk.testing.ValidatesRunner;
3839
import org.apache.beam.sdk.transforms.Create;
@@ -43,43 +44,43 @@
4344
import org.apache.beam.sdk.values.Row;
4445
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
4546
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap;
47+
import org.junit.Rule;
4648
import org.junit.Test;
4749
import org.junit.experimental.categories.Category;
4850
import org.junit.runner.RunWith;
4951
import org.junit.runners.JUnit4;
5052

5153
@RunWith(JUnit4.class)
5254
public class PythonExternalTransformTest implements Serializable {
55+
@Rule public transient TestPipeline testPipeline = TestPipeline.create();
5356

5457
@Test
5558
@Category({ValidatesRunner.class, UsesPythonExpansionService.class})
5659
public void trivialPythonTransform() {
57-
Pipeline p = Pipeline.create();
5860
PCollection<String> output =
59-
p.apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z")))
61+
testPipeline.apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z")))
6062
.apply(
6163
PythonExternalTransform
6264
.<PCollection<KV<String, String>>, PCollection<KV<String, Iterable<String>>>>
6365
from("apache_beam.GroupByKey"))
6466
.apply(Keys.create());
6567
PAssert.that(output).containsInAnyOrder("A", "B");
66-
// TODO: Run this on a multi-language supporting runner.
68+
testPipeline.run();
6769
}
6870

6971
@Test
7072
@Category({ValidatesRunner.class, UsesPythonExpansionService.class})
7173
public void pythonTransformWithDependencies() {
72-
Pipeline p = Pipeline.create();
7374
PCollection<String> output =
74-
p.apply(Create.of("elephant", "mouse", "sheep"))
75+
testPipeline.apply(Create.of("elephant", "mouse", "sheep"))
7576
.apply(
7677
PythonExternalTransform.<PCollection<String>, PCollection<String>>from(
7778
"apache_beam.Map")
7879
.withArgs(PythonCallableSource.of("import inflection\ninflection.pluralize"))
7980
.withExtraPackages(ImmutableList.of("inflection"))
8081
.withOutputCoder(StringUtf8Coder.of()));
8182
PAssert.that(output).containsInAnyOrder("elephants", "mice", "sheep");
82-
// TODO: Run this on a multi-language supporting runner.
83+
testPipeline.run();
8384
}
8485

8586
@Test

0 commit comments

Comments
 (0)