github.com/apache/beam/sdks/v2@v2.48.2/python/test-suites/xlang/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 // This is a base file to set up cross language tests for different runners 19 import org.apache.beam.gradle.BeamModulePlugin 20 import static org.apache.beam.gradle.BeamModulePlugin.CrossLanguageTaskCommon 21 project.evaluationDependsOn(":sdks:python") 22 23 // Set up cross language tests 24 def envDir = project.project(":sdks:python").envdir 25 def jobPort = BeamModulePlugin.getRandomPort() 26 def tmpDir = System.getenv("TMPDIR") ?: System.getenv("WORKSPACE") ?: "/tmp" 27 def pidFile = "${tmpDir}/local_job_service_main-${jobPort}.pid" 28 29 def setupTask = project.tasks.register("fnApiJobServerSetup", Exec) { 30 dependsOn ':sdks:python:installGcpTest' 31 32 executable 'sh' 33 args '-c', ". ${envDir}/bin/activate && python -m apache_beam.runners.portability.local_job_service_main --job_port ${jobPort} --pid_file ${pidFile} --background --stdout_file ${tmpDir}/beam-fnapi-job-server.log" 34 } 35 36 def cleanupTask = project.tasks.register("fnApiJobServerCleanup", Exec) { 37 executable 'sh' 38 args '-c', ". ${envDir}/bin/activate && python -m apache_beam.runners.portability.local_job_service_main --pid_file ${pidFile} --stop" 39 } 40 41 // List of objects representing task metadata to create cross-language tasks from. 42 // Each object contains the minimum relevant metadata. 43 def xlangTasks = [] 44 45 // ******** Java GCP expansion service ******** 46 // Note: this only runs cross-language tests that use the Java GCP expansion service 47 // To run tests that use another expansion service, create a new CrossLanguageTaskCommon with the 48 // relevant fields as done here, then add it to `xlangTasks`. 49 def gcpExpansionProject = project.project(':sdks:java:io:google-cloud-platform:expansion-service') 50 // Properties that are common across runners. 51 // Used to launch the expansion service, collect the right tests, and cleanup afterwards 52 def gcpXlangCommon = new CrossLanguageTaskCommon().tap { 53 name = "gcpCrossLanguage" 54 expansionProjectPath = gcpExpansionProject.getPath() 55 collectMarker = "uses_gcp_java_expansion_service" 56 startJobServer = setupTask 57 cleanupJobServer = cleanupTask 58 } 59 xlangTasks.add(gcpXlangCommon) 60 61 62 ext.xlangTasks = xlangTasks