1#!/usr/bin/env bash 2 3set -eu 4set -o pipefail 5 6# the go client does not support passing an argument with multiple test cases 7# so we loop over this array calling the binary each time around 8TEST_CASES=( 9 "empty_unary" 10 "large_unary" 11 "client_streaming" 12 "server_streaming" 13 "ping_pong" 14 "empty_stream" 15 "status_code_and_message" 16 "special_status_message" 17 "custom_metadata" 18 "unimplemented_method" 19 "unimplemented_service" 20) 21 22# join all test cases in one comma separated string (dropping the first one) 23# so we can call the rust client only once, reducing the noise 24JOINED_TEST_CASES=$(printf ",%s" "${TEST_CASES[@]}") 25JOINED_TEST_CASES="${JOINED_TEST_CASES:1}" 26 27set -x 28 29echo "Running for OS: ${OSTYPE}" 30 31case "$OSTYPE" in 32 darwin*) OS="darwin"; EXT="" ;; 33 linux*) OS="linux"; EXT="" ;; 34 msys*) OS="windows"; EXT=".exe" ;; 35 *) exit 2 ;; 36esac 37 38ARG="${1:-""}" 39 40 41(cd interop && cargo build --bins) 42 43SERVER="interop/bin/server_${OS}_amd64${EXT}" 44 45TLS_CA="interop/data/ca.pem" 46TLS_CRT="interop/data/server1.pem" 47TLS_KEY="interop/data/server1.key" 48 49# run the test server 50./"${SERVER}" ${ARG} --tls_cert_file $TLS_CRT --tls_key_file $TLS_KEY & 51SERVER_PID=$! 52echo ":; started grpc-go test server." 53 54# trap exits to make sure we kill the server process when the script exits, 55# regardless of why (errors, SIGTERM, etc). 56trap 'echo ":; killing test server"; kill ${SERVER_PID};' EXIT 57 58sleep 1 59 60./target/debug/client --test_case="${JOINED_TEST_CASES}" ${ARG} 61 62echo ":; killing test server"; kill ${SERVER_PID}; 63 64# run the test server 65./target/debug/server ${ARG} & 66SERVER_PID=$! 67echo ":; started tonic test server." 68 69# trap exits to make sure we kill the server process when the script exits, 70# regardless of why (errors, SIGTERM, etc). 71trap 'echo ":; killing test server"; kill ${SERVER_PID};' EXIT 72 73sleep 1 74 75./target/debug/client --test_case="${JOINED_TEST_CASES}" ${ARG} 76 77TLS_ARGS="" 78 79if [ -n "${ARG}" ]; then 80 TLS_ARGS="--use_tls --use_test_ca --server_host_override=foo.test.google.fr --ca_file=${TLS_CA}" 81fi 82 83for CASE in "${TEST_CASES[@]}"; do 84 interop/bin/client_${OS}_amd64${EXT} --test_case="${CASE}" ${TLS_ARGS} 85done 86