@@ -273,6 +273,69 @@ def createRunnerV2ValidatesRunnerTest = { Map args ->
273273 }
274274}
275275
276+ tasks. register(' examplesJavaRunnerV2IntegrationTestDistroless' , Test . class) {
277+ group = " verification"
278+ dependsOn ' buildAndPushDistrolessContainerImage'
279+ def javaVer = project. findProperty(' testJavaVersion' )
280+ def repository = " us.gcr.io/apache-beam-testing/${ System.getenv('USER')} "
281+ def tag = project. findProperty(' dockerTag' )
282+ def imageURL = " ${ repository} /beam_${ javaVer} _sdk_distroless:${ tag} "
283+ def pipelineOptions = [
284+ " --runner=TestDataflowRunner" ,
285+ " --project=${ gcpProject} " ,
286+ " --region=${ gcpRegion} " ,
287+ " --tempRoot=${ dataflowValidatesTempRoot} " ,
288+ " --sdkContainerImage=${ imageURL} " ,
289+ " --experiments=use_unified_worker,use_runner_v2" ,
290+ " --firestoreDb=${ firestoreDb} " ,
291+ ]
292+ systemProperty " beamTestPipelineOptions" , JsonOutput . toJson(pipelineOptions)
293+
294+ include ' **/*IT.class'
295+
296+ maxParallelForks 4
297+ classpath = configurations. examplesJavaIntegrationTest
298+ testClassesDirs = files(project(" :examples:java" ). sourceSets. test. output. classesDirs)
299+ useJUnit { }
300+ }
301+
302+ tasks. register(' buildAndPushDistrolessContainerImage' , Task . class) {
303+ // Only Java 17 and 21 are supported.
304+ // See https://github.com/GoogleContainerTools/distroless/tree/main/java#image-contents.
305+ def allowed = [" java17" , " java21" ]
306+ doLast {
307+ def javaVer = project. findProperty(' testJavaVersion' )
308+ if (! allowed. contains(javaVer)) {
309+ throw new GradleException (" testJavaVersion must be one of ${ allowed} , got: ${ javaVer} " )
310+ }
311+ if (! project. hasProperty(' dockerTag' )) {
312+ throw new GradleException (" dockerTag is missing but required" )
313+ }
314+ def repository = " us.gcr.io/apache-beam-testing/${ System.getenv('USER')} "
315+ def tag = project. findProperty(' dockerTag' )
316+ def imageURL = " ${ repository} /beam_${ javaVer} _sdk_distroless:${ tag} "
317+ exec {
318+ executable ' docker'
319+ workingDir rootDir
320+ args = [
321+ ' buildx' ,
322+ ' build' ,
323+ ' -t' ,
324+ imageURL,
325+ ' -f' ,
326+ ' sdks/java/container/Dockerfile-distroless' ,
327+ " --build-arg=BEAM_BASE=gcr.io/apache-beam-testing/beam-sdk/beam_${ javaVer} _sdk" ,
328+ " --build-arg=DISTROLESS_BASE=gcr.io/distroless/${ javaVer} -debian12" ,
329+ ' .'
330+ ]
331+ }
332+ exec {
333+ executable ' docker'
334+ args = [' push' , imageURL]
335+ }
336+ }
337+ }
338+
276339// Push docker images to a container registry for use within tests.
277340// NB: Tasks which consume docker images from the registry should depend on this
278341// task directly ('dependsOn buildAndPushDockerJavaContainer'). This ensures the correct
0 commit comments