forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
349 lines (322 loc) · 15.5 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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/*
* 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(
automaticModuleName: 'org.apache.beam.sdk.io.gcp',
enableSpotbugs: false,
classesTriggerCheckerBugs: [
'PubSubPayloadTranslation': 'https://github.com/typetools/checker-framework/issues/3791',
],
)
description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform"
ext.summary = "IO library to read and write Google Cloud Platform systems from Beam."
dependencies {
implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
permitUnusedDeclared enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
implementation project(path: ":model:pipeline", configuration: "shadow")
implementation project(":runners:core-java")
implementation project(path: ":sdks:java:core", configuration: "shadow")
implementation project(":sdks:java:harness")
implementation project(":sdks:java:expansion-service")
implementation project(":sdks:java:extensions:avro")
permitUnusedDeclared project(":sdks:java:expansion-service") // BEAM-11761
implementation project(":sdks:java:extensions:google-cloud-platform-core")
implementation project(":sdks:java:extensions:protobuf")
implementation project(":runners:core-construction-java")
implementation project(":sdks:java:extensions:arrow")
implementation library.java.avro
implementation library.java.bigdataoss_util
implementation library.java.error_prone_annotations
implementation library.java.flogger_system_backend // Avoids conflicts with bigdataoss_util (BEAM-11010)
permitUnusedDeclared library.java.flogger_system_backend // BEAM-11010
implementation library.java.gax
implementation(library.java.gax_grpc) {
// BEAM-13781: gax-grpc's gRPC version was older than Beam declared
exclude group: 'io.grpc', module: 'grpc-netty-shaded'
}
implementation library.java.gax_grpc_test
implementation library.java.gax_httpjson
permitUnusedDeclared library.java.gax_httpjson // BEAM-8755
implementation library.java.google_api_client
implementation library.java.google_api_common
implementation library.java.google_api_services_bigquery
implementation library.java.google_api_services_healthcare
implementation library.java.google_api_services_pubsub
implementation library.java.google_api_services_storage
implementation library.java.google_auth_library_credentials
implementation library.java.google_auth_library_oauth2_http
implementation library.java.google_cloud_bigquery_storage
implementation(library.java.google_cloud_bigtable_client_core_config)
// google_cloud_bigtable_client_core declares old google-cloud-bigtable for
// Java7 compatibility. The old google-cloud-bigtable is not compatible with
// newer version of GAX. Declaring newer google-cloud-bigtable so that Beam
// users receive newer google-cloud-bigtable. Beam doesn't directly use this
// artifact.
implementation library.java.google_cloud_bigtable
permitUnusedDeclared library.java.google_cloud_bigtable
implementation library.java.google_cloud_core
implementation(library.java.google_cloud_core_grpc) {
exclude group: 'io.grpc', module: 'grpc-core' // Use Beam's version
}
permitUnusedDeclared library.java.google_cloud_core_grpc // BEAM-11761
implementation library.java.google_cloud_datastore_v1_proto_client
implementation library.java.google_cloud_firestore
implementation library.java.google_cloud_pubsublite
// GCP PubSub client is used in TestPubSub
implementation library.java.google_cloud_pubsub
implementation library.java.google_cloud_spanner
implementation library.java.google_code_gson
implementation library.java.google_http_client
implementation library.java.google_http_client_jackson2
// bigdataoss_util declares old google_oauth_client version that does not have
// IdTokenVerifier.verifyPayload method. Let's declare the newer one.
implementation library.java.google_oauth_client
permitUnusedDeclared library.java.google_oauth_client
implementation library.java.grpc_alts
permitUnusedDeclared library.java.grpc_alts // BEAM-11761
implementation library.java.grpc_api
implementation library.java.grpc_auth
implementation library.java.grpc_core
permitUnusedDeclared library.java.grpc_core // BEAM-11761
implementation library.java.grpc_census
permitUnusedDeclared library.java.grpc_census // BEAM-11761
implementation library.java.grpc_context
permitUnusedDeclared library.java.grpc_context // BEAM-11761
implementation library.java.grpc_grpclb
permitUnusedDeclared library.java.grpc_grpclb // BEAM-11761
implementation library.java.grpc_netty
implementation library.java.grpc_netty_shaded
permitUnusedDeclared library.java.grpc_netty_shaded // BEAM-11761
implementation library.java.grpc_protobuf
implementation library.java.grpc_stub
permitUnusedDeclared library.java.grpc_stub // BEAM-11761
implementation library.java.grpc_xds
permitUnusedDeclared library.java.grpc_xds // BEAM-11761
implementation library.java.grpc_google_cloud_pubsub_v1
implementation library.java.grpc_google_cloud_pubsublite_v1
permitUnusedDeclared library.java.grpc_google_cloud_pubsublite_v1 // BEAM-11761
implementation library.java.guava
implementation library.java.http_client
provided library.java.hamcrest
permitUnusedDeclared library.java.hamcrest // BEAM-11761
implementation library.java.http_core
implementation library.java.jackson_core
implementation library.java.jackson_databind
implementation library.java.jackson_datatype_joda
implementation library.java.jackson_datatype_jsr310
implementation library.java.joda_time
provided library.java.junit
implementation library.java.netty_handler
implementation library.java.netty_tcnative_boringssl_static
permitUnusedDeclared library.java.netty_tcnative_boringssl_static // BEAM-11761
implementation library.java.proto_google_cloud_bigquery_storage_v1
implementation library.java.proto_google_cloud_bigtable_v2
implementation library.java.proto_google_cloud_datastore_v1
implementation library.java.proto_google_cloud_firestore_v1
implementation library.java.proto_google_cloud_pubsub_v1
implementation library.java.proto_google_cloud_pubsublite_v1
implementation library.java.proto_google_cloud_spanner_admin_database_v1
permitUnusedDeclared library.java.proto_google_cloud_spanner_admin_database_v1 // BEAM-11761
implementation library.java.proto_google_cloud_spanner_v1
implementation library.java.proto_google_common_protos
implementation library.java.protobuf_java
implementation library.java.protobuf_java_util
implementation library.java.slf4j_api
implementation library.java.vendored_grpc_1_54_0
implementation library.java.vendored_guava_32_1_2_jre
implementation library.java.arrow_memory_core
implementation library.java.arrow_vector
implementation 'com.google.http-client:google-http-client-gson:1.41.2'
implementation "org.threeten:threetenbp:1.4.4"
testImplementation library.java.arrow_memory_netty
testImplementation project(path: ":sdks:java:core", configuration: "shadowTest")
testImplementation project(path: ":sdks:java:extensions:avro", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:extensions:google-cloud-platform-core", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:extensions:protobuf", configuration: "testRuntimeMigration")
testImplementation project(path: ":runners:direct-java", configuration: "shadow")
testImplementation project(path: ":sdks:java:io:common", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:testing:test-utils", configuration: "testRuntimeMigration")
testImplementation library.java.mockito_core
testImplementation library.java.powermock
testImplementation library.java.powermock_mockito
testImplementation library.java.joda_time
testImplementation library.java.google_cloud_spanner_test
testImplementation library.java.google_cloud_bigtable_emulator
testRuntimeOnly library.java.slf4j_jdk14
// everit_json is needed for PubsubLite SchemaTransform tests that rely on JSON-schema translation.
permitUnusedDeclared library.java.everit_json_schema
provided library.java.everit_json_schema
}
// Don't pull in newer versions of the checker framework from dependencies.
// TODO(BEAM-11125) Remove this when Beam upgrades to newest checker framework version.
configurations.implementation {
resolutionStrategy {
force library.java.checker_qual
}
}
/**
* These are integration tests with the real Pubsub service and the DirectRunner.
*/
task integrationTest(type: Test, dependsOn: processTestResources) {
group = "Verification"
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcpTempRoot = project.findProperty('gcpTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests'
def firestoreDb = project.findProperty('firestoreDb') ?: 'firestoredb'
def host = project.findProperty('host') ?: 'batch-firestore.googleapis.com:443'
systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
"--runner=DirectRunner",
"--project=${gcpProject}",
"--tempRoot=${gcpTempRoot}",
"--firestoreDb=${firestoreDb}",
"--host=${host}",
])
// Disable Gradle cache: these ITs interact with live service that should always be considered "out of date"
outputs.upToDateWhen { false }
include '**/*IT.class'
exclude '**/BigQueryIOReadIT.class'
exclude '**/BigQueryIOStorageQueryIT.class'
exclude '**/BigQueryIOStorageReadIT.class'
exclude '**/BigQueryIOStorageWriteIT.class'
exclude '**/BigQueryToTableIT.class'
maxParallelForks 4
classpath = sourceSets.test.runtimeClasspath
testClassesDirs = sourceSets.test.output.classesDirs
useJUnit {
excludeCategories "org.apache.beam.sdk.testing.UsesKms"
}
}
task integrationTestKms(type: Test) {
group = "Verification"
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcpTempRoot = project.findProperty('gcpTempRootKms') ?: 'gs://temp-storage-for-end-to-end-tests-cmek'
def dataflowKmsKey = project.findProperty('dataflowKmsKey') ?: "projects/apache-beam-testing/locations/global/keyRings/beam-it/cryptoKeys/test"
def firestoreDb = project.findProperty('firestoreDb') ?: 'firestoredb'
def host = project.findProperty('host') ?: 'batch-firestore.googleapis.com:443'
systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
"--runner=DirectRunner",
"--project=${gcpProject}",
"--tempRoot=${gcpTempRoot}",
"--dataflowKmsKey=${dataflowKmsKey}",
"--firestoreDb=${firestoreDb}",
"--host=${host}",
])
// Disable Gradle cache: these ITs interact with live service that should always be considered "out of date"
outputs.upToDateWhen { false }
include '**/*IT.class'
maxParallelForks 4
classpath = sourceSets.test.runtimeClasspath
testClassesDirs = sourceSets.test.output.classesDirs
useJUnit {
includeCategories "org.apache.beam.sdk.testing.UsesKms"
}
}
/*
Integration tests for BigQueryIO that run on BigQuery's early rollout region (us-east7)
with the intended purpose of catching breaking changes from new BigQuery releases.
If these tests fail here but not in `Java_GCP_IO_Direct`, there may be a new BigQuery change
that is breaking the connector. If this is the case, we should verify with the appropriate
BigQuery infrastructure API team.
To test in a BigQuery location, we just need to create our datasets in that location.
*/
task bigQueryEarlyRolloutIntegrationTest(type: Test, dependsOn: processTestResources) {
group = "Verification"
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcpTempRoot = project.findProperty('gcpTempRoot') ?: 'gs://temp-storage-for-bigquery-day0-tests'
systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
"--runner=DirectRunner",
"--project=${gcpProject}",
"--tempRoot=${gcpTempRoot}",
"--bigQueryLocation=us-east7",
])
outputs.upToDateWhen { false }
// export and direct read
include '**/BigQueryToTableIT.class'
include '**/BigQueryIOJsonIT.class'
include '**/BigQueryIOStorageReadTableRowIT.class'
// storage write api
include '**/StorageApiDirectWriteProtosIT.class'
include '**/StorageApiSinkFailedRowsIT.class'
include '**/StorageApiSinkRowUpdateIT.class'
include '**/StorageApiSinkSchemaUpdateIT.class'
include '**/TableRowToStorageApiProtoIT.class'
// file loads
include '**/BigQuerySchemaUpdateOptionsIT.class'
include '**/BigQueryTimePartitioningClusteringIT.class'
include '**/FileLoadsStreamingIT.class'
maxParallelForks 4
classpath = sourceSets.test.runtimeClasspath
testClassesDirs = sourceSets.test.output.classesDirs
}
// path(s) for Cloud Spanner related classes
def spannerIncludes = [
'**/org/apache/beam/sdk/io/gcp/spanner/**',
]
// exclude auto-generated classes and integration tests
def jacocoExcludes = [
'**/AutoValue_*',
'**/*IT*',
]
task spannerCodeCoverageReport(type: JacocoReport, dependsOn: test) {
group = "Reporting"
description = "Generates code coverage report for Cloud Spanner related classes"
classDirectories.setFrom(files(files(project.sourceSets.main.output).collect {
project.fileTree(
dir: it,
includes: spannerIncludes,
excludes: jacocoExcludes)
}))
sourceDirectories.setFrom(files(project.sourceSets.main.allSource.srcDirs))
executionData.setFrom(file("${buildDir}/jacoco/test.exec"))
reports {
html.getRequired().set(true)
html.getOutputLocation().set(file("${buildDir}/reports/jacoco/spanner/"))
}
}
task spannerCodeCoverageVerification(type: JacocoCoverageVerification, dependsOn: spannerCodeCoverageReport) {
group = "Verification"
description = "Enforces code coverage verification for Cloud Spanner related classes"
classDirectories.setFrom(files(files(project.sourceSets.main.output).collect {
project.fileTree(
dir: it,
includes: spannerIncludes,
excludes: jacocoExcludes)
}))
sourceDirectories.setFrom(files(project.sourceSets.main.allSource.srcDirs))
executionData.setFrom(file("${buildDir}/jacoco/test.exec"))
violationRules {
failOnViolation = true
rule {
element = 'BUNDLE'
limit {
value = 'COVEREDRATIO'
counter = 'INSTRUCTION'
minimum = 0.60
}
}
}
}
// make the check task depend on spannerCodeCoverageVerification so that the build
// fails when the code coverage threshold is violated.
project.check.dependsOn "spannerCodeCoverageVerification"
task postCommit {
group = "Verification"
description = "Integration tests of GCP connectors using the DirectRunner."
dependsOn integrationTest
dependsOn integrationTestKms
}