-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chery-pick pull request #17394: [BEAM-14014] Add parameter for servic…
…e account impersonation in GCP credentials (#17597) Co-authored-by: Kenn Knowles <[email protected]>
- Loading branch information
1 parent
6e2cca1
commit 1b5086c
Showing
4 changed files
with
111 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,28 @@ def dockerJavaImageName = project(':runners:google-cloud-dataflow-java').ext.doc | |
// If -PuseExecutableStage is set, the use_executable_stage_bundle_execution wil be enabled. | ||
def fnapiExperiments = project.hasProperty('useExecutableStage') ? 'beam_fn_api_use_deprecated_read,use_executable_stage_bundle_execution' : "beam_fn_api,beam_fn_api_use_deprecated_read" | ||
|
||
def commonConfig = { dataflowWorkerJar, workerHarnessContainerImage = '', additionalOptions = [] -> | ||
// For testing impersonation, we use three ingredients: | ||
// - a principal to impersonate | ||
// - a dataflow service account that only that principal is allowed to launch jobs as | ||
// - a temp root that only the above two accounts have access to | ||
// | ||
// Jenkins and Dataflow workers both run as GCE default service account. So we remove that account from all the above. | ||
def impersonateServiceAccount = project.findProperty('gcpImpersonateServiceAccount') ?: '[email protected]' | ||
def dataflowWorkerImpersonationServiceAccount = project.findProperty('dataflowWorkerImpersonationServiceAccount') ?: | ||
"impersonation-dataflow-worker@apache-beam-testing.iam.gserviceaccount.com" | ||
def impersonationTempRoot = project.findProperty('gcpImpersonationTempRoot') ?: 'gs://impersonation-test-bucket/tmproot' | ||
|
||
|
||
def commonConfig = { Map args -> | ||
if (!args.dataflowWorkerJar) { | ||
throw new GradleException("Dataflow integration test configuration requires dataflowWorkerJar parameter") | ||
} | ||
|
||
def actualDataflowWorkerJar = args.dataflowWorkerJar | ||
def actualWorkerHarnessContainerImage = args.workerHarnessContainerImage ?: '' | ||
def actualGcsTempRoot = args.gcsTempRoot ?: gcsTempRoot | ||
def additionalOptions = args.additionalOptions ?: [] | ||
|
||
// return the preevaluated configuration closure | ||
return { | ||
testClassesDirs = files(project(":examples:java").sourceSets.test.output.classesDirs) | ||
|
@@ -54,10 +75,10 @@ def commonConfig = { dataflowWorkerJar, workerHarnessContainerImage = '', additi | |
def preCommitBeamTestPipelineOptions = [ | ||
"--project=${gcpProject}", | ||
"--region=${gcpRegion}", | ||
"--tempRoot=${gcsTempRoot}", | ||
"--tempRoot=${actualGcsTempRoot}", | ||
"--runner=TestDataflowRunner", | ||
"--dataflowWorkerJar=${dataflowWorkerJar}", | ||
"--workerHarnessContainerImage=${workerHarnessContainerImage}" | ||
"--dataflowWorkerJar=${actualDataflowWorkerJar}", | ||
"--workerHarnessContainerImage=${actualWorkerHarnessContainerImage}" | ||
] + additionalOptions | ||
systemProperty "beamTestPipelineOptions", JsonOutput.toJson(preCommitBeamTestPipelineOptions) | ||
} | ||
|
@@ -66,14 +87,30 @@ def commonConfig = { dataflowWorkerJar, workerHarnessContainerImage = '', additi | |
task preCommitLegacyWorker(type: Test) { | ||
dependsOn ":runners:google-cloud-dataflow-java:worker:legacy-worker:shadowJar" | ||
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker:legacy-worker").shadowJar.archivePath | ||
with commonConfig(dataflowWorkerJar) | ||
with commonConfig(dataflowWorkerJar: dataflowWorkerJar) | ||
} | ||
|
||
task preCommitLegacyWorkerImpersonate(type: Test) { | ||
dependsOn ":runners:google-cloud-dataflow-java:worker:legacy-worker:shadowJar" | ||
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker:legacy-worker").shadowJar.archivePath | ||
with commonConfig( | ||
dataflowWorkerJar: dataflowWorkerJar, | ||
gcsTempRoot: impersonationTempRoot, | ||
additionalOptions: [ | ||
"--impersonateServiceAccount=${impersonateServiceAccount}", | ||
"--serviceAccount=${dataflowWorkerImpersonationServiceAccount}" | ||
]) | ||
} | ||
|
||
task verifyFnApiWorker(type: Test) { | ||
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar" | ||
dependsOn ":runners:google-cloud-dataflow-java:buildAndPushDockerContainer" | ||
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker").shadowJar.archivePath | ||
with commonConfig(dataflowWorkerJar, dockerJavaImageName, ["--experiments=${fnapiExperiments}"]) | ||
with commonConfig( | ||
dataflowWorkerJar: dataflowWorkerJar, | ||
workerHarnessContainerImage: dockerJavaImageName, | ||
additionalOptions: ["--experiments=${fnapiExperiments}"] | ||
) | ||
useJUnit { | ||
excludeCategories 'org.apache.beam.sdk.testing.StreamingIT' | ||
} | ||
|
@@ -83,7 +120,7 @@ task postCommitLegacyWorkerJava11(type: Test) { | |
dependsOn ":runners:google-cloud-dataflow-java:worker:legacy-worker:shadowJar" | ||
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker:legacy-worker").shadowJar.archivePath | ||
systemProperty "java.specification.version", "11" | ||
with commonConfig(dataflowWorkerJar) | ||
with commonConfig(dataflowWorkerJar: dataflowWorkerJar) | ||
} | ||
|
||
task java11PostCommit() { | ||
|
@@ -94,7 +131,7 @@ task postCommitLegacyWorkerJava17(type: Test) { | |
dependsOn ":runners:google-cloud-dataflow-java:worker:legacy-worker:shadowJar" | ||
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker:legacy-worker").shadowJar.archivePath | ||
systemProperty "java.specification.version", "17" | ||
with commonConfig(dataflowWorkerJar) | ||
with commonConfig(dataflowWorkerJar: dataflowWorkerJar) | ||
} | ||
|
||
task java17PostCommit() { | ||
|
@@ -103,6 +140,7 @@ task java17PostCommit() { | |
|
||
task preCommit() { | ||
dependsOn preCommitLegacyWorker | ||
dependsOn preCommitLegacyWorkerImpersonate | ||
} | ||
|
||
task verifyPortabilityApi() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters