/*
 * 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 org.apache.beam.gradle.IoPerformanceTestUtilities

plugins { id 'org.apache.beam.module' }
applyJavaNature(
    automaticModuleName: 'org.apache.beam.it.gcp',
    exportJavadoc: false,
)

description = "Apache Beam :: IT :: Google Cloud Platform"
ext.summary = "Integration test utilities for Google Cloud Platform."

dependencies {
    implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
    implementation project(path: ":sdks:java:core", configuration: "shadow")
    implementation project(path: ":runners:google-cloud-dataflow-java")
    implementation project(path: ":it:common")
    implementation project(path: ":it:conditions")
    implementation project(path: ":it:truthmatchers")
    implementation project(path: ":sdks:java:testing:test-utils")
    implementation library.java.failsafe
    implementation library.java.google_api_services_dataflow
    implementation library.java.junit
    implementation library.java.slf4j_api
    implementation(library.java.truth) {
        exclude group: 'com.google.guava', module: 'guava'
    }
    implementation library.java.vendored_guava_32_1_2_jre
    implementation library.java.jackson_core
    implementation library.java.jackson_databind
    implementation 'org.apache.hadoop:hadoop-common:3.3.5'
    implementation 'org.apache.avro:avro:1.11.1'
    implementation 'org.apache.parquet:parquet-avro:1.15.2'
    implementation 'org.apache.parquet:parquet-common:1.15.2'
    implementation 'org.apache.parquet:parquet-hadoop:1.15.2'
    implementation 'org.apache.commons:commons-lang3:3.9'
    implementation library.java.gax
    implementation library.java.google_api_common
    implementation library.java.google_api_client
    implementation library.java.google_api_services_bigquery
    implementation library.java.google_auth_library_credentials
    implementation library.java.google_auth_library_oauth2_http
    implementation library.java.google_http_client
    implementation library.java.guava
    implementation library.java.protobuf_java_util
    implementation library.java.protobuf_java
    implementation library.java.threetenbp
    implementation 'org.awaitility:awaitility:4.2.0'
    implementation 'joda-time:joda-time:2.10.10'
    // Google Cloud Dependencies
    implementation library.java.google_cloud_core
    implementation 'com.google.cloud:google-cloud-storage'
    implementation 'com.google.cloud:google-cloud-bigquery'
    implementation 'com.google.cloud:google-cloud-monitoring'
    provided 'com.google.api.grpc:proto-google-cloud-monitoring-v3'
    implementation 'com.google.cloud:google-cloud-bigtable'
    implementation 'com.google.cloud:google-cloud-spanner'
    implementation 'com.google.cloud:google-cloud-pubsub'
    provided 'com.google.api.grpc:proto-google-cloud-pubsub-v1'
    implementation 'com.google.cloud:google-cloud-pubsublite'
    provided 'com.google.api.grpc:proto-google-cloud-pubsublite-v1'
    implementation 'com.google.cloud:google-cloud-datastore'
    implementation 'com.google.cloud:google-cloud-datastream'
    provided 'com.google.api.grpc:proto-google-cloud-datastream-v1'
    implementation 'com.google.cloud:google-cloud-kms'
    provided 'com.google.api.grpc:proto-google-cloud-kms-v1'
    implementation 'com.google.cloud:google-cloud-dlp'
    provided 'com.google.api.grpc:proto-google-cloud-dlp-v2'
    implementation 'com.google.cloud:google-cloud-secretmanager'
    provided 'com.google.api.grpc:proto-google-cloud-secretmanager-v1'

    testImplementation project(path: ":sdks:java:io:google-cloud-platform")
    testImplementation project(path: ":sdks:java:extensions:protobuf", configuration: "testRuntimeMigration")
    testImplementation project(path: ":sdks:java:io:synthetic")
    testImplementation library.java.mockito_inline
    testImplementation project(path: ":sdks:java:extensions:google-cloud-platform-core", configuration: "testRuntimeMigration")
    testImplementation project(path: ":runners:direct-java", configuration: "shadow")
    testRuntimeOnly library.java.slf4j_simple
}

tasks.register(
        "GCSPerformanceTest", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'FileBasedIOLT',
        ['configuration':'large','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigTablePerformanceTest", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigTableIOLT',
        ['configuration':'large', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigQueryPerformanceTest", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigQueryIOLT',
        ['configuration':'medium', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigQueryStressTestMedium", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigQueryIOST',
        ['configuration':'medium', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigQueryStressTestLarge", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigQueryIOST',
        ['configuration':'large', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigQueryStorageApiStreamingPerformanceTest", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigQueryStreamingLT',
        ['configuration':'large', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "PubsubLoadTestMedium", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'PubsubIOLT',
        ['configuration':'medium', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "PubsubLoadTestLarge", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'PubsubIOLT',
        ['configuration':'large', 'project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
                + System.properties
)
tasks.register(
        "WordCountIntegrationTest", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'WordCountIT',
        ['project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigTableStressTestMedium", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigTableIOST',
        ['configuration':'medium','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "BigTableStressTestLarge", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'BigTableIOST',
        ['configuration':'large','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "SpannerStressTestMedium", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'SpannerIOST',
        ['configuration':'medium','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "SpannerStressTestLarge", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'SpannerIOST',
        ['configuration':'large','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties
)
tasks.register(
        "PubSubStressTestMedium", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'PubSubIOST',
        ['configuration':'medium','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties)
tasks.register(
        "PubSubStressTestLarge", IoPerformanceTestUtilities.IoPerformanceTest, project, 'google-cloud-platform', 'PubSubIOST',
        ['configuration':'large','project':'apache-beam-testing', 'artifactBucket':'io-performance-temp']
        + System.properties)
