github.com/apache/beam/sdks/v2@v2.48.2/python/test-suites/direct/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  
    19  // TODO(https://github.com/apache/beam/issues/20209): Move this definition into common.gradle.
    20  
    21  plugins { id 'org.apache.beam.module' }
    22  applyJavaNature(publish: false, exportJavadoc: false)
    23  
    24  import org.apache.beam.gradle.BeamModulePlugin
    25  
    26  project.evaluationDependsOn(":sdks:python")
    27  project.evaluationDependsOn(":runners:portability:java")
    28  
    29  def envDir = project.project(":sdks:python").envdir
    30  def crossLanguageTestClasspath = project.project(":runners:portability:java").sourceSets.test.runtimeClasspath
    31  def jobPort = BeamModulePlugin.getRandomPort()
    32  def tmpDir = System.getenv("TMPDIR") ?: System.getenv("WORKSPACE") ?: "/tmp"
    33  def pidFile = "${tmpDir}/local_job_service_main-${jobPort}.pid"
    34  
    35  def setupTask = project.tasks.register("fnApiJobServerSetup", Exec) {
    36    dependsOn ':sdks:python:installGcpTest'
    37  
    38    executable 'sh'
    39    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"
    40  }
    41  
    42  def cleanupTask = project.tasks.register("fnApiJobServerCleanup", Exec) {
    43    executable 'sh'
    44    args '-c', ". ${envDir}/bin/activate && python -m apache_beam.runners.portability.local_job_service_main --pid_file ${pidFile} --stop"
    45  }
    46  
    47  createCrossLanguageValidatesRunnerTask(
    48    startJobServer: setupTask,
    49    cleanupJobServer: cleanupTask,
    50    numParallelTests: 1,
    51    classpath: crossLanguageTestClasspath,
    52    pythonPipelineOptions: [
    53      "--runner=PortableRunner",
    54      "--job_endpoint=localhost:${jobPort}",
    55      "--environment_cache_millis=10000",
    56      "--experiments=beam_fn_api",
    57    ],
    58    javaPipelineOptions: [
    59      "--runner=PortableRunner",
    60      "--jobEndpoint=localhost:${jobPort}",
    61      "--environmentCacheMillis=10000",
    62      "--experiments=beam_fn_api",
    63    ],
    64    goScriptOptions: [
    65      "--runner portable",
    66      "--tests \"./test/integration/xlang ./test/integration/io/xlang/...\"",
    67      "--endpoint localhost:${jobPort}",
    68    ],
    69  )