Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Runs the D ThriftTest client and servers for all combinations of transport, |
| 3 | # protocol, SSL-mode and server type. |
| 4 | # Pass -k to keep going after failed tests. |
| 5 | |
| 6 | protocols="binary compact json" |
| 7 | transports="buffered framed http raw" |
| 8 | servers="simple taskpool threaded" |
| 9 | framed_only_servers="nonblocking pooledNonblocking" |
| 10 | |
| 11 | # Don't leave any server instances behind when interrupted (e.g. by Ctrl+C) |
| 12 | # or terminated. |
| 13 | trap "kill $(jobs -p) 2>/dev/null" INT TERM |
| 14 | |
| 15 | for protocol in $protocols; do |
| 16 | for ssl in "" " --ssl"; do |
| 17 | for transport in $transports; do |
| 18 | for server in $servers $framed_only_servers; do |
| 19 | case $framed_only_servers in |
| 20 | *$server*) if [ $transport != "framed" ] || [ $ssl != "" ]; then continue; fi;; |
| 21 | esac |
| 22 | |
| 23 | args="--transport=$transport --protocol=$protocol$ssl" |
| 24 | ./thrift_test_server $args --server-type=$server > /dev/null & |
| 25 | server_pid=$! |
| 26 | |
| 27 | # Give the server some time to get up and check if it runs (yes, this |
| 28 | # is a huge kludge, should add a connect timeout to test client). |
| 29 | client_rc=-1 |
| 30 | sleep 0.01 |
| 31 | kill -0 $server_pid 2>/dev/null |
| 32 | if [ $? -eq 0 ]; then |
| 33 | ./thrift_test_client $args --numTests=10 > /dev/null |
| 34 | client_rc=$? |
| 35 | |
| 36 | # Temporarily redirect stderr to null to avoid job control messages, |
| 37 | # restore it afterwards. |
| 38 | exec 3>&2 |
| 39 | exec 2>/dev/null |
| 40 | kill $server_pid |
| 41 | exec 3>&2 |
| 42 | fi |
| 43 | |
| 44 | # Get the server exit code (wait should immediately return). |
| 45 | wait $server_pid |
| 46 | server_rc=$? |
| 47 | |
| 48 | if [ $client_rc -ne 0 -o $server_rc -eq 1 ]; then |
| 49 | echo -e "\nTests failed for: $args --server-type=$server" |
| 50 | failed="true" |
| 51 | if [ "$1" != "-k" ]; then |
| 52 | exit 1 |
| 53 | fi |
| 54 | else |
| 55 | echo -n "." |
| 56 | fi |
| 57 | done |
| 58 | done |
| 59 | done |
| 60 | done |
| 61 | |
| 62 | echo |
| 63 | if [ -z "$failed" ]; then |
| 64 | echo "All tests passed." |
| 65 | fi |