forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
257 lines (228 loc) · 11.4 KB
/
Copy pathbuild.gradle
File metadata and controls
257 lines (228 loc) · 11.4 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
* 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' }
// Shade away runner execution utilities till because this causes ServiceLoader conflicts with
// TransformPayloadTranslatorRegistrar amongst other runners. This only happens in the DirectRunner
// because it is likely to appear on the classpath of another runner.
def dependOnProjects = [":runners:core-construction-java",
":runners:core-java",
":runners:local-java",
":runners:java-fn-execution",
":sdks:java:fn-execution",
":sdks:java:extensions:avro"
]
applyJavaNature(
automaticModuleName: 'org.apache.beam.runners.direct',
classesTriggerCheckerBugs: [
'ImpulseEvaluatorFactory': 'https://github.com/typetools/checker-framework/issues/3791',
],
shadowClosure: {
dependencies {
dependOnProjects.each {
include(project(path: it, configuration: "shadow"))
}
}
relocate "org.apache.beam.runners.core", getJavaRelocatedPath("runners.core")
relocate "org.apache.beam.runners.fnexecution", getJavaRelocatedPath("runners.fnexecution")
relocate "org.apache.beam.sdk.fn", getJavaRelocatedPath("sdk.fn")
relocate "org.apache.beam.runners.local", getJavaRelocatedPath("runners.local")
},
)
description = "Apache Beam :: Runners :: Direct Java"
/*
* We need to rely on manually specifying these evaluationDependsOn to ensure that
* the following projects are evaluated before we evaluate this project. This is because
* we are attempting to reference the "sourceSets.test.output" directly.
*/
evaluationDependsOn(":runners:core-construction-java")
evaluationDependsOn(":runners:core-java")
evaluationDependsOn(":sdks:java:core")
evaluationDependsOn(":examples:java")
configurations {
needsRunner
validatesRunner
examplesJavaIntegrationTest
}
dependencies {
shadow library.java.vendored_guava_26_0_jre
shadow project(path: ":model:pipeline", configuration: "shadow")
dependOnProjects.each {
implementation project(it)
}
shadow project(path: ":sdks:java:core", configuration: "shadow")
shadow library.java.vendored_grpc_1_48_1
shadow library.java.joda_time
shadow library.java.slf4j_api
shadow library.java.jackson_databind
provided library.java.hamcrest
permitUnusedDeclared library.java.hamcrest
provided library.java.junit
permitUnusedDeclared library.java.junit
shadowTest project(path: ":sdks:java:core", configuration: "shadowTest")
shadowTest project(path: ":runners:core-java", configuration: "testRuntimeMigration")
shadowTest library.java.mockito_core
needsRunner project(path: ":runners:core-construction-java", configuration: "testRuntimeMigration")
needsRunner project(path: ":runners:core-java", configuration: "testRuntimeMigration")
needsRunner project(path: ":sdks:java:core", configuration: "shadowTest")
needsRunner project(path: project.path, configuration: "shadow")
needsRunner project(path: project.path, configuration: "shadowTest")
validatesRunner project(path: ":runners:core-construction-java", configuration: "testRuntimeMigration")
validatesRunner project(path: ":runners:core-java", configuration: "testRuntimeMigration")
validatesRunner project(path: ":sdks:java:core", configuration: "shadowTest")
validatesRunner project(path: project.path, configuration: "shadow")
validatesRunner project(path: project.path, configuration: "shadowTest")
permitUnusedDeclared library.java.vendored_grpc_1_48_1
permitUnusedDeclared project(":runners:java-fn-execution")
permitUnusedDeclared project(":sdks:java:fn-execution")
permitUnusedDeclared project(":sdks:java:extensions:avro")
examplesJavaIntegrationTest project(project.path)
examplesJavaIntegrationTest project(":examples:java")
examplesJavaIntegrationTest project(path: ":examples:java", configuration: "testRuntimeMigration")
}
// windows handles quotes differently from linux,
// on linux, the pipeline option string looks like
// "--runner=DirectRunner", "--runnerDeterminedSharding=false"
// on windows, the pipeline option string needs to be
// "\"--runner=DirectRunner\"", "\"--runnerDeterminedSharding=false\""
// to achieve the same effect
static def pipelineOptionsStringCrossPlatformHandling(String[] options) {
if (System.properties['os.name'].toLowerCase().contains('windows')) {
return JsonOutput.toJson(options.collect { "\"$it\"" })
} else {
return JsonOutput.toJson(options)
}
}
def sickbayTests = [
// https://github.com/apache/beam/issues/18499
'org.apache.beam.sdk.testing.UsesLoopingTimer',
// https://github.com/apache/beam/issues/19344
'org.apache.beam.sdk.io.BoundedReadFromUnboundedSourceTest.testTimeBound',
]
task needsRunnerTests(type: Test) {
group = "Verification"
description = "Runs tests that require a runner to validate that piplines/transforms work correctly"
testLogging.showStandardStreams = true
String[] pipelineOptions = ["--runner=DirectRunner", "--runnerDeterminedSharding=false"]
systemProperty "beamTestPipelineOptions", pipelineOptionsStringCrossPlatformHandling(pipelineOptions)
classpath = configurations.needsRunner
// NOTE: We only add to the test class dirs to ensure that the direct runner
// tests (i.e., those from this subproject) get scanned.
testClassesDirs += files(project(":runners:core-construction-java").sourceSets.test.output.classesDirs)
testClassesDirs += files(project(":runners:core-java").sourceSets.test.output.classesDirs)
testClassesDirs += files(project(":sdks:java:core").sourceSets.test.output.classesDirs)
useJUnit {
filter {
for (String test : sickbayTests) {
excludeTestsMatching test
}
}
includeCategories "org.apache.beam.sdk.testing.NeedsRunner"
// Should be run only in a properly configured SDK harness environment
excludeCategories 'org.apache.beam.sdk.testing.UsesSdkHarnessEnvironment'
excludeCategories "org.apache.beam.sdk.testing.LargeKeys\$Above100MB"
// MetricsPusher isn't implemented in direct runner
excludeCategories "org.apache.beam.sdk.testing.UsesMetricsPusher"
excludeCategories "org.apache.beam.sdk.testing.UsesJavaExpansionService"
excludeCategories "org.apache.beam.sdk.testing.UsesPythonExpansionService"
excludeCategories 'org.apache.beam.sdk.testing.UsesBundleFinalizer'
}
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
// NOTE: This will also run 'NeedsRunner' tests, which are run in the :needsRunnerTests task as well.
// The intention of this task is to mirror the :validatesRunner configuration for other runners,
// such that the test suite can be validated on the in-process DirectRunner.
task validatesRunner(type: Test) {
group = "Verification"
description "Validates Direct runner"
String[] pipelineOptions = ["--runner=DirectRunner", "--runnerDeterminedSharding=false"]
systemProperty "beamTestPipelineOptions", pipelineOptionsStringCrossPlatformHandling(pipelineOptions)
classpath = configurations.validatesRunner
// NOTE: We only add to the test class dirs to ensure that the direct runner
// tests (i.e., those from this subproject) get scanned.
testClassesDirs += files(project(":runners:core-construction-java").sourceSets.test.output.classesDirs)
testClassesDirs += files(project(":runners:core-java").sourceSets.test.output.classesDirs)
testClassesDirs += files(project(":sdks:java:core").sourceSets.test.output.classesDirs)
useJUnit {
includeCategories "org.apache.beam.sdk.testing.ValidatesRunner"
// Should be run only in a properly configured SDK harness environment
excludeCategories 'org.apache.beam.sdk.testing.UsesSdkHarnessEnvironment'
excludeCategories "org.apache.beam.sdk.testing.LargeKeys\$Above100MB"
excludeCategories 'org.apache.beam.sdk.testing.UsesMetricsPusher'
excludeCategories "org.apache.beam.sdk.testing.UsesJavaExpansionService"
excludeCategories "org.apache.beam.sdk.testing.UsesPythonExpansionService"
// https://github.com/apache/beam/issues/18499
excludeCategories 'org.apache.beam.sdk.testing.UsesLoopingTimer'
}
}
tasks.register("validatesRunnerSickbay", Test) {
group = "Verification"
description "Validates Direct runner (Sickbay Tests)"
systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
"--runner=DirectRunner",
])
classpath = configurations.needsRunner
testClassesDirs = files(project(":sdks:java:core").sourceSets.test.output.classesDirs)
filter {
for (String test : sickbayTests) {
includeTestsMatching test
}
// https://github.com/apache/beam/issues/18826
includeTestsMatching 'org.apache.beam.runners.direct.WatermarkManagerTest.updateWatermarkWithDifferentWindowedValueInstances'
}
}
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcsBucket = project.findProperty('gcsBucket') ?: 'temp-storage-for-release-validation-tests/nightly-snapshot-validation'
def bqDataset = project.findProperty('bqDataset') ?: 'beam_postrelease_mobile_gaming'
def pubsubTopic = project.findProperty('pubsubTopic') ?: 'java_mobile_gaming_topic'
def tempLocation = project.findProperty('tempLocation') ?: 'gs://temp-storage-for-end-to-end-tests'
// Generates :runners:direct-java:runQuickstartJavaDirect
createJavaExamplesArchetypeValidationTask(type: 'Quickstart', runner: 'Direct')
// Generates :runners:direct-java:runMobileGamingJavaDirect
createJavaExamplesArchetypeValidationTask(type: 'MobileGaming',
runner: 'Direct',
gcpProject: gcpProject,
gcsBucket: gcsBucket,
bqDataset: bqDataset,
pubsubTopic: pubsubTopic)
task examplesIntegrationTest(type: Test) {
description = "Runs examples tests on DirectRunner"
testLogging.showStandardStreams = true
String[] pipelineOptions = [
"--runner=DirectRunner",
"--runnerDeterminedSharding=false",
"--tempLocation=${tempLocation}",
"--tempRoot=${tempLocation}",
"--project=${gcpProject}",
]
systemProperty "beamTestPipelineOptions", pipelineOptionsStringCrossPlatformHandling(pipelineOptions)
include '**/*IT.class'
maxParallelForks 4
classpath = configurations.examplesJavaIntegrationTest
testClassesDirs = files(project(":examples:java").sourceSets.test.output.classesDirs)
useJUnit {
filter{
// TODO (https://github.com/apache/beam/issues/21344) Fix integration Tests to run with DirectRunner: Timeout error
excludeTestsMatching 'org.apache.beam.examples.complete.TfIdfIT'
excludeTestsMatching 'org.apache.beam.examples.WindowedWordCountIT.testWindowedWordCountInBatchDynamicSharding'
}
}
}