ncteisen | fe75634 | 2017-05-20 09:40:48 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | # Copyright 2017 gRPC authors. |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 3 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | # 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 Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 7 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 9 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | # 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 Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 15 | |
| 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 | |
| 25 | set -e |
| 26 | |
| 27 | cd $(dirname $0)/../.. |
| 28 | GRPC_ROOT=$(pwd) |
| 29 | CMDS_SH="${GRPC_ROOT}/interop_client_cmds.sh" |
| 30 | TESTCASES_DIR=${GRPC_ROOT}/tools/interop_matrix/testcases |
| 31 | |
| 32 | echo "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'" |
| 33 | |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 34 | # Clean up |
| 35 | function 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 Zhou | 317641d | 2017-11-03 17:52:14 -0700 | [diff] [blame] | 50 | |
| 51 | function 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. |
| 55 | if [ $1 == "cxx" ]; then |
| 56 | client_lang="c++" |
| 57 | else |
| 58 | client_lang=$1 |
| 59 | fi |
| 60 | echo $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 Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 65 | trap cleanup EXIT |
Adele Zhou | e6b9c78 | 2017-10-04 15:53:03 -0700 | [diff] [blame] | 66 | # TODO(adelez): add test auth tests but do not run if not testing on GCE. |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 67 | # Running the testcases as sanity unless we are asked to skip. |
Adele Zhou | e6b9c78 | 2017-10-04 15:53:03 -0700 | [diff] [blame] | 68 | [ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH) |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 69 | |
| 70 | mkdir -p $TESTCASES_DIR |
Adele Zhou | 317641d | 2017-11-03 17:52:14 -0700 | [diff] [blame] | 71 | testcase=$TESTCASES_DIR/$1__$RELEASE |
Yong Ni | b2e4bfa | 2017-05-09 18:12:10 -0700 | [diff] [blame] | 72 | if [ -e $testcase ]; then |
| 73 | echo "Updating: $testcase" |
| 74 | diff $testcase $CMDS_SH || true |
| 75 | fi |
| 76 | mv $CMDS_SH $testcase |
| 77 | chmod a+x $testcase |
| 78 | echo "Test cases created: $testcase" |
Adele Zhou | 317641d | 2017-11-03 17:52:14 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | if [ $LANG == "csharp" ]; then |
| 82 | createtests "csharp" |
| 83 | createtests "csharpcoreclr" |
| 84 | else |
| 85 | createtests $LANG |
| 86 | fi |