| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | #!/bin/bash# Copyright 2017 gRPC authors.## Licensed 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.# Creates test cases for a language by running run_interop_test in manual mode# and save the generated output under ./testcases/<lang>__<release>.## Params:#   LANG - The language.#   SKIP_TEST - If set, skip running the test cases for sanity.#   RELEASE - Create testcase for specific release, defautl to 'master'.#   KEEP_IMAGE - Do not clean local docker image created for the test cases.set -ecd $(dirname $0)/../..GRPC_ROOT=$(pwd)CMDS_SH="${GRPC_ROOT}/interop_client_cmds.sh"TESTCASES_DIR=${GRPC_ROOT}/tools/interop_matrix/testcasesecho "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'"echo $client_lang# Invoke run_interop_test in manual mode.# TODO(adelez): Add cloud_gateways when we figure out how to skip them if not # running in GCE.${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $LANG --use_docker \  --cloud_to_prod --prod_servers default gateway_v4 --manual_run# Clean upfunction cleanup {  [ -z "$testcase" ] && testcase=$CMDS_SH  echo "testcase: $testcase"  if [ -e $testcase ]; then    # The script should generate a line with "${docker_image:=...}".    eval docker_image=$(grep -oe '${docker_image:=.*}' $testcase)    if [ -z "$KEEP_IMAGE" ]; then      echo "Clean up docker_image $docker_image"      docker rmi -f $docker_image    else      echo "Kept docker_image $docker_image"    fi  fi  [ -e "$CMDS_SH" ] && rm $CMDS_SH}trap cleanup EXIT# TODO(adelez): add test auth tests but do not run if not testing on GCE.# Running the testcases as sanity unless we are asked to skip.[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH)# Convert c++ to cxx. if [$LANG == "c++" ]; thenclient_lang="cxx"elseclient_lang=$LANGfimkdir -p $TESTCASES_DIRtestcase=$TESTCASES_DIR/${client_lang}__$RELEASEif [ -e $testcase ]; then  echo "Updating: $testcase"  diff $testcase $CMDS_SH || truefimv $CMDS_SH $testcasechmod a+x $testcaseecho "Test cases created: $testcase"
 |