@@ -1201,45 +1201,32 @@ public void testNoStagingLocationAndNoTempLocationFails() {
12011201 DataflowRunner .fromOptions (options );
12021202 }
12031203
1204+ private static RunnerApi .Pipeline containerUrlToPipeline (String url ) {
1205+ return RunnerApi .Pipeline .newBuilder ()
1206+ .setComponents (
1207+ RunnerApi .Components .newBuilder ()
1208+ .putEnvironments (
1209+ "env" ,
1210+ RunnerApi .Environment .newBuilder ()
1211+ .setUrn (BeamUrns .getUrn (RunnerApi .StandardEnvironments .Environments .DOCKER ))
1212+ .setPayload (
1213+ RunnerApi .DockerPayload .newBuilder ()
1214+ .setContainerImage (url )
1215+ .build ()
1216+ .toByteString ())
1217+ .build ()))
1218+ .build ();
1219+ }
1220+
12041221 @ Test
12051222 public void testApplySdkEnvironmentOverrides () throws IOException {
12061223 DataflowPipelineOptions options = buildPipelineOptions ();
12071224 String dockerHubPythonContainerUrl = "apache/beam_python3.9_sdk:latest" ;
12081225 String gcrPythonContainerUrl = "gcr.io/apache-beam-testing/beam-sdk/beam_python3.9_sdk:latest" ;
12091226 options .setSdkHarnessContainerImageOverrides (".*python.*," + gcrPythonContainerUrl );
12101227 DataflowRunner runner = DataflowRunner .fromOptions (options );
1211- RunnerApi .Pipeline pipeline =
1212- RunnerApi .Pipeline .newBuilder ()
1213- .setComponents (
1214- RunnerApi .Components .newBuilder ()
1215- .putEnvironments (
1216- "env" ,
1217- RunnerApi .Environment .newBuilder ()
1218- .setUrn (
1219- BeamUrns .getUrn (RunnerApi .StandardEnvironments .Environments .DOCKER ))
1220- .setPayload (
1221- RunnerApi .DockerPayload .newBuilder ()
1222- .setContainerImage (dockerHubPythonContainerUrl )
1223- .build ()
1224- .toByteString ())
1225- .build ()))
1226- .build ();
1227- RunnerApi .Pipeline expectedPipeline =
1228- RunnerApi .Pipeline .newBuilder ()
1229- .setComponents (
1230- RunnerApi .Components .newBuilder ()
1231- .putEnvironments (
1232- "env" ,
1233- RunnerApi .Environment .newBuilder ()
1234- .setUrn (
1235- BeamUrns .getUrn (RunnerApi .StandardEnvironments .Environments .DOCKER ))
1236- .setPayload (
1237- RunnerApi .DockerPayload .newBuilder ()
1238- .setContainerImage (gcrPythonContainerUrl )
1239- .build ()
1240- .toByteString ())
1241- .build ()))
1242- .build ();
1228+ RunnerApi .Pipeline pipeline = containerUrlToPipeline (dockerHubPythonContainerUrl );
1229+ RunnerApi .Pipeline expectedPipeline = containerUrlToPipeline (gcrPythonContainerUrl );
12431230 assertThat (runner .applySdkEnvironmentOverrides (pipeline , options ), equalTo (expectedPipeline ));
12441231 }
12451232
@@ -1249,38 +1236,19 @@ public void testApplySdkEnvironmentOverridesByDefault() throws IOException {
12491236 String dockerHubPythonContainerUrl = "apache/beam_python3.9_sdk:latest" ;
12501237 String gcrPythonContainerUrl = "gcr.io/cloud-dataflow/v1beta3/beam_python3.9_sdk:latest" ;
12511238 DataflowRunner runner = DataflowRunner .fromOptions (options );
1252- RunnerApi .Pipeline pipeline =
1253- RunnerApi .Pipeline .newBuilder ()
1254- .setComponents (
1255- RunnerApi .Components .newBuilder ()
1256- .putEnvironments (
1257- "env" ,
1258- RunnerApi .Environment .newBuilder ()
1259- .setUrn (
1260- BeamUrns .getUrn (RunnerApi .StandardEnvironments .Environments .DOCKER ))
1261- .setPayload (
1262- RunnerApi .DockerPayload .newBuilder ()
1263- .setContainerImage (dockerHubPythonContainerUrl )
1264- .build ()
1265- .toByteString ())
1266- .build ()))
1267- .build ();
1268- RunnerApi .Pipeline expectedPipeline =
1269- RunnerApi .Pipeline .newBuilder ()
1270- .setComponents (
1271- RunnerApi .Components .newBuilder ()
1272- .putEnvironments (
1273- "env" ,
1274- RunnerApi .Environment .newBuilder ()
1275- .setUrn (
1276- BeamUrns .getUrn (RunnerApi .StandardEnvironments .Environments .DOCKER ))
1277- .setPayload (
1278- RunnerApi .DockerPayload .newBuilder ()
1279- .setContainerImage (gcrPythonContainerUrl )
1280- .build ()
1281- .toByteString ())
1282- .build ()))
1283- .build ();
1239+ RunnerApi .Pipeline pipeline = containerUrlToPipeline (dockerHubPythonContainerUrl );
1240+ RunnerApi .Pipeline expectedPipeline = containerUrlToPipeline (gcrPythonContainerUrl );
1241+ assertThat (runner .applySdkEnvironmentOverrides (pipeline , options ), equalTo (expectedPipeline ));
1242+ }
1243+
1244+ @ Test
1245+ public void testApplySdkEnvironmentOverridesRcByDefault () throws IOException {
1246+ DataflowPipelineOptions options = buildPipelineOptions ();
1247+ String dockerHubPythonContainerUrl = "apache/beam_python3.9_sdk:2.68.0rc2" ;
1248+ String gcrPythonContainerUrl = "gcr.io/cloud-dataflow/v1beta3/beam_python3.9_sdk:2.68.0" ;
1249+ DataflowRunner runner = DataflowRunner .fromOptions (options );
1250+ RunnerApi .Pipeline pipeline = containerUrlToPipeline (dockerHubPythonContainerUrl );
1251+ RunnerApi .Pipeline expectedPipeline = containerUrlToPipeline (gcrPythonContainerUrl );
12841252 assertThat (runner .applySdkEnvironmentOverrides (pipeline , options ), equalTo (expectedPipeline ));
12851253 }
12861254
0 commit comments