-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-14014] Add parameter for service account impersonation in GCP credentials #17394
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to take a string that we parse instead of List/String[] since PipelineOptionsFactory can do this already for us. See
beam/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsFactoryTest.java
Line 1423 in 937e22f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I did not realize this. That could be a useful follow-up. We do want the format of the parameter to be the same across SDKs and across Beam and gcloud, etc. But it seems that comma-separated strings will be the same across all of them.