Skip to content

Commit 08c96f2

Browse files
authored
Fix XVR JavaUsingPython tests using dev Beam at expansion (#36444)
* Uses test pipeline * Set custom beam requirement * Fix spotless
1 parent 6f31e56 commit 08c96f2

6 files changed

Lines changed: 14 additions & 6 deletions

File tree

runners/flink/job-server/flink_job_server.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ createCrossLanguageValidatesRunnerTask(
269269
"--environmentCacheMillis=10000",
270270
"--experiments=beam_fn_api",
271271
"--parallelism=2",
272+
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
272273
],
273274
goScriptOptions: [
274275
"--runner flink",

runners/google-cloud-dataflow-java/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ createCrossLanguageValidatesRunnerTask(
486486
"--tempRoot=${dataflowValidatesTempRoot}",
487487
"--sdkContainerImage=${dockerJavaImageContainer}:${dockerTag}",
488488
"--sdkHarnessContainerImageOverrides=.*python.*,${dockerPythonImageContainer}:${dockerTag}",
489+
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
489490
],
490491
pytestOptions: [
491492
"--capture=no",

runners/samza/job-server/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ createCrossLanguageValidatesRunnerTask(
243243
"--jobEndpoint=localhost:${jobPort}",
244244
"--environmentCacheMillis=10000",
245245
"--experiments=beam_fn_api",
246+
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
246247
],
247248
goScriptOptions: [
248249
"--runner samza",

runners/spark/job-server/spark_job_server.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ createCrossLanguageValidatesRunnerTask(
294294
"--jobEndpoint=localhost:${jobPort}",
295295
"--environmentCacheMillis=10000",
296296
"--experiments=beam_fn_api",
297+
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
297298
],
298299
goScriptOptions: [
299300
"--runner spark",

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

Lines changed: 9 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,45 @@
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
62+
.apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z")))
6063
.apply(
6164
PythonExternalTransform
6265
.<PCollection<KV<String, String>>, PCollection<KV<String, Iterable<String>>>>
6366
from("apache_beam.GroupByKey"))
6467
.apply(Keys.create());
6568
PAssert.that(output).containsInAnyOrder("A", "B");
66-
// TODO: Run this on a multi-language supporting runner.
69+
testPipeline.run();
6770
}
6871

6972
@Test
7073
@Category({ValidatesRunner.class, UsesPythonExpansionService.class})
7174
public void pythonTransformWithDependencies() {
72-
Pipeline p = Pipeline.create();
7375
PCollection<String> output =
74-
p.apply(Create.of("elephant", "mouse", "sheep"))
76+
testPipeline
77+
.apply(Create.of("elephant", "mouse", "sheep"))
7578
.apply(
7679
PythonExternalTransform.<PCollection<String>, PCollection<String>>from(
7780
"apache_beam.Map")
7881
.withArgs(PythonCallableSource.of("import inflection\ninflection.pluralize"))
7982
.withExtraPackages(ImmutableList.of("inflection"))
8083
.withOutputCoder(StringUtf8Coder.of()));
8184
PAssert.that(output).containsInAnyOrder("elephants", "mice", "sheep");
82-
// TODO: Run this on a multi-language supporting runner.
85+
testPipeline.run();
8386
}
8487

8588
@Test

sdks/python/test-suites/direct/xlang/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ createCrossLanguageValidatesRunnerTask(
6262
"--jobEndpoint=localhost:${jobPort}",
6363
"--environmentCacheMillis=10000",
6464
"--experiments=beam_fn_api",
65+
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
6566
],
6667
goScriptOptions: [
6768
"--runner portable",

0 commit comments

Comments
 (0)