github.com/apache/beam/sdks/v2@v2.48.2/go/test/build.gradle (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * License); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 plugins { id 'org.apache.beam.module' } 20 applyGoNature() 21 applyPythonNature() 22 23 description = "Apache Beam :: SDKs :: Go :: Test" 24 25 // ValidatesRunner tests for Dataflow. Runs tests in the integration directory 26 // with Dataflow to validate that the runner behaves as expected. 27 task dataflowValidatesRunner() { 28 group = "Verification" 29 30 dependsOn ":sdks:go:test:goBuild" 31 dependsOn ":sdks:java:testing:expansion-service:buildTestExpansionServiceJar" 32 33 doLast { 34 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 35 "--expansion_jar=test:${project(":sdks:java:testing:expansion-service").buildTestExpansionServiceJar.archivePath}", 36 ] 37 def options = [ 38 "--runner dataflow", 39 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 40 ] 41 exec { 42 executable "sh" 43 args "-c", "./run_validatesrunner_tests.sh ${options.join(' ')}" 44 } 45 } 46 } 47 48 // ValidatesRunner tests for Flink. Runs tests in the integration directory 49 // with Flink to validate that the runner behaves as expected. 50 task flinkValidatesRunner { 51 group = "Verification" 52 53 dependsOn ":sdks:go:test:goBuild" 54 dependsOn ":sdks:go:container:docker" 55 dependsOn ":sdks:java:container:java8:docker" 56 dependsOn ":runners:flink:${project.ext.latestFlinkVersion}:job-server:shadowJar" 57 dependsOn ":sdks:java:testing:expansion-service:buildTestExpansionServiceJar" 58 doLast { 59 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 60 "--expansion_jar=test:${project(":sdks:java:testing:expansion-service").buildTestExpansionServiceJar.archivePath}", 61 ] 62 def options = [ 63 "--runner flink", 64 "--flink_job_server_jar ${project(":runners:flink:${project.ext.latestFlinkVersion}:job-server").shadowJar.archivePath}", 65 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 66 ] 67 exec { 68 executable "sh" 69 args "-c", "./run_validatesrunner_tests.sh ${options.join(' ')}" 70 } 71 } 72 } 73 74 // ValidatesRunner tests for Samza. Runs tests in the integration directory 75 // with Samza to validate that the runner behaves as expected. 76 task samzaValidatesRunner { 77 dependsOn ":sdks:go:test:goBuild" 78 dependsOn ":sdks:go:container:docker" 79 dependsOn ":sdks:java:container:java8:docker" 80 dependsOn ":runners:samza:job-server:shadowJar" 81 dependsOn ":sdks:java:testing:expansion-service:buildTestExpansionServiceJar" 82 doLast { 83 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 84 "--expansion_jar=test:${project(":sdks:java:testing:expansion-service").buildTestExpansionServiceJar.archivePath}", 85 ] 86 def options = [ 87 "--runner samza", 88 "--samza_job_server_jar ${project(":runners:samza:job-server").shadowJar.archivePath}", 89 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 90 ] 91 exec { 92 executable "sh" 93 args "-c", "./run_validatesrunner_tests.sh ${options.join(' ')}" 94 } 95 } 96 } 97 98 // ValidatesRunner tests for Spark. Runs tests in the integration directory 99 // with Spark to validate that the runner behaves as expected. 100 task sparkValidatesRunner { 101 group = "Verification" 102 103 dependsOn ":sdks:go:test:goBuild" 104 dependsOn ":sdks:java:container:java8:docker" 105 dependsOn ":runners:spark:3:job-server:shadowJar" 106 dependsOn ":sdks:java:testing:expansion-service:buildTestExpansionServiceJar" 107 doLast { 108 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 109 "--expansion_jar=test:${project(":sdks:java:testing:expansion-service").buildTestExpansionServiceJar.archivePath}", 110 ] 111 def options = [ 112 "--runner spark", 113 "--spark_job_server_jar ${project(":runners:spark:3:job-server").shadowJar.archivePath}", 114 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 115 ] 116 exec { 117 executable "sh" 118 args "-c", "./run_validatesrunner_tests.sh ${options.join(' ')}" 119 } 120 } 121 } 122 123 // ValidatesRunner tests for the Python Portable runner (aka. ULR). Runs tests 124 // in the integration directory with the ULR to validate that the runner behaves 125 // as expected. 126 // 127 // The ULR can exhibit strange behavior when containers are built with outdated 128 // vendored directories. For best results use the clean task, like so: 129 // ./gradlew clean :sdks:go:test:ulrValidatesRunner 130 tasks.register("ulrValidatesRunner") { 131 group = "Verification" 132 133 dependsOn ":sdks:go:test:goBuild" 134 dependsOn ":sdks:go:container:docker" 135 dependsOn ":sdks:java:container:java8:docker" 136 dependsOn "setupVirtualenv" 137 dependsOn ":sdks:python:buildPython" 138 dependsOn ":sdks:java:testing:expansion-service:buildTestExpansionServiceJar" 139 doLast { 140 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 141 "--expansion_jar=test:${project(":sdks:java:testing:expansion-service").buildTestExpansionServiceJar.archivePath}", 142 ] 143 def options = [ 144 "--runner portable", 145 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 146 ] 147 exec { 148 executable "sh" 149 workingDir "${project.rootDir}/sdks/python" 150 args "-c", ". ${envdir}/bin/activate && pip install -e ." 151 } 152 exec { 153 executable "sh" 154 args "-c", ". ${envdir}/bin/activate && ./run_validatesrunner_tests.sh ${options.join(' ')}" 155 } 156 } 157 } 158 159 // A method for configuring a cross-language validates runner test task, 160 // intended to be used in calls to createCrossLanguageValidatesRunnerTask. 161 ext.goIoValidatesRunnerTask = { proj, name, scriptOpts, pipelineOpts -> 162 return proj.tasks.register(name) { 163 group = "Verification" 164 165 dependsOn ":sdks:go:test:goBuild" 166 dependsOn ":sdks:go:container:docker" 167 dependsOn ":sdks:java:io:expansion-service:build" 168 dependsOn ":sdks:java:extensions:schemaio-expansion-service:build" 169 dependsOn ":sdks:java:io:debezium:expansion-service:build" 170 dependsOn ":sdks:java:io:google-cloud-platform:expansion-service:build" 171 dependsOn ":sdks:java:testing:kafka-service:buildTestKafkaServiceJar" 172 173 doLast { 174 def ioExpJar = project(":sdks:java:io:expansion-service").shadowJar.archivePath 175 def schemaIoExpJar = project(":sdks:java:extensions:schemaio-expansion-service").shadowJar.archivePath 176 def debeziumIoExpJar = project(":sdks:java:io:debezium:expansion-service").shadowJar.archivePath 177 def gcpIoExpJar = project(":sdks:java:io:google-cloud-platform:expansion-service").shadowJar.archivePath 178 def kafkaJar = project(":sdks:java:testing:kafka-service:").buildTestKafkaServiceJar.archivePath 179 def pipelineOptions = [ // Pipeline options piped directly to Go SDK flags. 180 "--kafka_jar=${kafkaJar}", 181 "--expansion_jar=io:${ioExpJar}", 182 "--expansion_jar=schemaio:${schemaIoExpJar}", 183 "--expansion_jar=debeziumio:${debeziumIoExpJar}", 184 "--expansion_jar=gcpio:${gcpIoExpJar}", 185 "--bq_dataset=apache-beam-testing.beam_bigquery_io_test_temp", 186 ] 187 pipelineOptions.addAll(pipelineOpts) 188 def options = [ 189 "--pipeline_opts \"${pipelineOptions.join(' ')}\"", 190 ] 191 options.addAll(scriptOpts) 192 logger.info("Running the command: sh -c ./run_validatesrunner_tests.sh ${options.join(' ')}") 193 exec { 194 executable "sh" 195 args "-c", "./run_validatesrunner_tests.sh ${options.join(' ')}" 196 } 197 } 198 } 199 }