blob: fa33fa4615f266cbe5f798dc95ee590d53712e74 [file] [log] [blame]
ncteisenfe756342017-05-20 09:40:48 -07001#!/bin/bash
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002# Copyright 2017 gRPC authors.
Yong Nib2e4bfa2017-05-09 18:12:10 -07003#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
Yong Nib2e4bfa2017-05-09 18:12:10 -07007#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008# http://www.apache.org/licenses/LICENSE-2.0
Yong Nib2e4bfa2017-05-09 18:12:10 -07009#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Yong Nib2e4bfa2017-05-09 18:12:10 -070015
16# Creates test cases for a language by running run_interop_test in manual mode
17# and save the generated output under ./testcases/<lang>__<release>.
18#
19# Params:
20# LANG - The language.
21# SKIP_TEST - If set, skip running the test cases for sanity.
22# RELEASE - Create testcase for specific release, defautl to 'master'.
23# KEEP_IMAGE - Do not clean local docker image created for the test cases.
24
25set -e
26
27cd $(dirname $0)/../..
28GRPC_ROOT=$(pwd)
29CMDS_SH="${GRPC_ROOT}/interop_client_cmds.sh"
30TESTCASES_DIR=${GRPC_ROOT}/tools/interop_matrix/testcases
31
32echo "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'"
33
Yong Nib2e4bfa2017-05-09 18:12:10 -070034# Clean up
35function cleanup {
36 [ -z "$testcase" ] && testcase=$CMDS_SH
37 echo "testcase: $testcase"
38 if [ -e $testcase ]; then
39 # The script should generate a line with "${docker_image:=...}".
40 eval docker_image=$(grep -oe '${docker_image:=.*}' $testcase)
41 if [ -z "$KEEP_IMAGE" ]; then
42 echo "Clean up docker_image $docker_image"
43 docker rmi -f $docker_image
44 else
45 echo "Kept docker_image $docker_image"
46 fi
47 fi
48 [ -e "$CMDS_SH" ] && rm $CMDS_SH
49}
Adele Zhou317641d2017-11-03 17:52:14 -070050
51function createtests {
52# Invoke run_interop_test in manual mode.
53# TODO(adelez): Add cloud_gateways when we figure out how to skip them if not
54# running in GCE.
55if [ $1 == "cxx" ]; then
56client_lang="c++"
57else
58client_lang=$1
59fi
60echo $client_lang
61
62${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $client_lang --use_docker \
63 --cloud_to_prod --prod_servers default gateway_v4 --manual_run
64
Yong Nib2e4bfa2017-05-09 18:12:10 -070065trap cleanup EXIT
Adele Zhoue6b9c782017-10-04 15:53:03 -070066# TODO(adelez): add test auth tests but do not run if not testing on GCE.
Yong Nib2e4bfa2017-05-09 18:12:10 -070067# Running the testcases as sanity unless we are asked to skip.
Adele Zhoue6b9c782017-10-04 15:53:03 -070068[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH)
Yong Nib2e4bfa2017-05-09 18:12:10 -070069
70mkdir -p $TESTCASES_DIR
Adele Zhou317641d2017-11-03 17:52:14 -070071testcase=$TESTCASES_DIR/$1__$RELEASE
Yong Nib2e4bfa2017-05-09 18:12:10 -070072if [ -e $testcase ]; then
73 echo "Updating: $testcase"
74 diff $testcase $CMDS_SH || true
75fi
76mv $CMDS_SH $testcase
77chmod a+x $testcase
78echo "Test cases created: $testcase"
Adele Zhou317641d2017-11-03 17:52:14 -070079}
80
81if [ $LANG == "csharp" ]; then
82createtests "csharp"
83createtests "csharpcoreclr"
84else
85createtests $LANG
86fi