forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
157 lines (136 loc) · 6.99 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.json.JsonOutput
plugins { id 'org.apache.beam.module' }
applyJavaNature( publish: false, exportJavadoc: false)
// Evaluate the given project before this one, to allow referencing
// its sourceSets.test.output directly.
evaluationDependsOn(":examples:java")
evaluationDependsOn(":runners:google-cloud-dataflow-java")
evaluationDependsOn(":runners:google-cloud-dataflow-java:worker")
evaluationDependsOn(":sdks:java:container")
configurations { dataflowRunnerPreCommit }
dependencies {
testRuntimeOnly project(path: ":examples:java", configuration: "testRuntimeMigration")
testRuntimeOnly project(":runners:google-cloud-dataflow-java")
}
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcpRegion = project.findProperty('gcpRegion') ?: 'us-central1'
def gcsTempRoot = project.findProperty('gcsTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests/'
def dockerJavaImageName = project(':runners:google-cloud-dataflow-java').ext.dockerJavaImageName
// 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"
// 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') ?: 'allows-impersonation@apache-beam-testing.iam.gserviceaccount.com'
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)
include "**/WordCountIT.class"
include "**/WindowedWordCountIT.class"
forkEvery 1
maxParallelForks 4
def preCommitBeamTestPipelineOptions = [
"--project=${gcpProject}",
"--region=${gcpRegion}",
"--tempRoot=${actualGcsTempRoot}",
"--runner=TestDataflowRunner",
"--dataflowWorkerJar=${actualDataflowWorkerJar}",
"--workerHarnessContainerImage=${actualWorkerHarnessContainerImage}"
] + additionalOptions
systemProperty "beamTestPipelineOptions", JsonOutput.toJson(preCommitBeamTestPipelineOptions)
}
}
task preCommitLegacyWorker(type: Test) {
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar"
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker").shadowJar.archivePath
with commonConfig(dataflowWorkerJar: dataflowWorkerJar)
}
task preCommitLegacyWorkerImpersonate(type: Test) {
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar"
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java: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: dataflowWorkerJar,
workerHarnessContainerImage: dockerJavaImageName,
additionalOptions: ["--experiments=${fnapiExperiments}"]
)
useJUnit {
excludeCategories 'org.apache.beam.sdk.testing.StreamingIT'
}
}
task postCommitLegacyWorkerJava11(type: Test) {
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar"
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker").shadowJar.archivePath
systemProperty "java.specification.version", "11"
with commonConfig(dataflowWorkerJar: dataflowWorkerJar)
}
task java11PostCommit() {
dependsOn postCommitLegacyWorkerJava11
}
task postCommitLegacyWorkerJava17(type: Test) {
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar"
def dataflowWorkerJar = project.findProperty('dataflowWorkerJar') ?: project(":runners:google-cloud-dataflow-java:worker").shadowJar.archivePath
systemProperty "java.specification.version", "17"
with commonConfig(dataflowWorkerJar: dataflowWorkerJar)
}
task java17PostCommit() {
dependsOn postCommitLegacyWorkerJava17
}
task preCommit() {
dependsOn preCommitLegacyWorker
dependsOn preCommitLegacyWorkerImpersonate
}
task verifyPortabilityApi() {
// TODO(BEAM-9668): Re-enable these tests once Dataflow worker container images are updated.
// dependsOn verifyFnApiWorker
}
afterEvaluate {
// Ensure all tasks which use published docker images run before they are cleaned up
tasks.each { t ->
if (t.dependsOn.contains(":runners:google-cloud-dataflow-java:buildAndPushDockerContainer")) {
t.finalizedBy ':runners:google-cloud-dataflow-java:cleanUpDockerImages'
}
}
}