diff --git a/.github/trigger_files/beam_PostCommit_XVR_Samza.json b/.github/trigger_files/beam_PostCommit_XVR_Samza.json index a9ac2f4cc406..2bf3f556083b 100644 --- a/.github/trigger_files/beam_PostCommit_XVR_Samza.json +++ b/.github/trigger_files/beam_PostCommit_XVR_Samza.json @@ -1 +1 @@ -{"modification": 1} \ No newline at end of file +{"modification": 2} \ No newline at end of file diff --git a/.github/trigger_files/beam_PostCommit_XVR_Spark3.json b/.github/trigger_files/beam_PostCommit_XVR_Spark3.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/.github/trigger_files/beam_PostCommit_XVR_Spark3.json @@ -0,0 +1 @@ +{} diff --git a/sdks/java/extensions/python/src/test/java/org/apache/beam/sdk/extensions/python/PythonExternalTransformTest.java b/sdks/java/extensions/python/src/test/java/org/apache/beam/sdk/extensions/python/PythonExternalTransformTest.java index f522a4c409f8..30fe0b90f397 100644 --- a/sdks/java/extensions/python/src/test/java/org/apache/beam/sdk/extensions/python/PythonExternalTransformTest.java +++ b/sdks/java/extensions/python/src/test/java/org/apache/beam/sdk/extensions/python/PythonExternalTransformTest.java @@ -33,18 +33,17 @@ import org.apache.beam.sdk.schemas.SchemaTranslation; import org.apache.beam.sdk.schemas.logicaltypes.MicrosInstant; import org.apache.beam.sdk.testing.PAssert; -import org.apache.beam.sdk.testing.TestPipeline; import org.apache.beam.sdk.testing.UsesPythonExpansionService; import org.apache.beam.sdk.testing.ValidatesRunner; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.Keys; import org.apache.beam.sdk.util.PythonCallableSource; +import org.apache.beam.sdk.util.construction.BaseExternalTest; import org.apache.beam.sdk.values.KV; import org.apache.beam.sdk.values.PCollection; import org.apache.beam.sdk.values.Row; import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList; import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap; -import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -52,37 +51,37 @@ @RunWith(JUnit4.class) public class PythonExternalTransformTest implements Serializable { - @Rule public transient TestPipeline testPipeline = TestPipeline.create(); - - @Test - @Category({ValidatesRunner.class, UsesPythonExpansionService.class}) - public void trivialPythonTransform() { - PCollection output = - testPipeline - .apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z"))) - .apply( - PythonExternalTransform - .>, PCollection>>> - from("apache_beam.GroupByKey")) - .apply(Keys.create()); - PAssert.that(output).containsInAnyOrder("A", "B"); - testPipeline.run(); - } - - @Test - @Category({ValidatesRunner.class, UsesPythonExpansionService.class}) - public void pythonTransformWithDependencies() { - PCollection output = - testPipeline - .apply(Create.of("elephant", "mouse", "sheep")) - .apply( - PythonExternalTransform., PCollection>from( - "apache_beam.Map") - .withArgs(PythonCallableSource.of("import inflection\ninflection.pluralize")) - .withExtraPackages(ImmutableList.of("inflection")) - .withOutputCoder(StringUtf8Coder.of())); - PAssert.that(output).containsInAnyOrder("elephants", "mice", "sheep"); - testPipeline.run(); + @RunWith(JUnit4.class) + public static class RunPipelineTest extends BaseExternalTest { + + @Test + @Category({ValidatesRunner.class, UsesPythonExpansionService.class}) + public void trivialPythonTransform() { + PCollection output = + testPipeline + .apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z"))) + .apply( + PythonExternalTransform + .>, PCollection>>> + from("apache_beam.GroupByKey")) + .apply(Keys.create()); + PAssert.that(output).containsInAnyOrder("A", "B"); + } + + @Test + @Category({ValidatesRunner.class, UsesPythonExpansionService.class}) + public void pythonTransformWithDependencies() { + PCollection output = + testPipeline + .apply(Create.of("elephant", "mouse", "sheep")) + .apply( + PythonExternalTransform., PCollection>from( + "apache_beam.Map") + .withArgs(PythonCallableSource.of("import inflection\ninflection.pluralize")) + .withExtraPackages(ImmutableList.of("inflection")) + .withOutputCoder(StringUtf8Coder.of())); + PAssert.that(output).containsInAnyOrder("elephants", "mice", "sheep"); + } } @Test