Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Nobuaki Sukegawa | 4d28b60 | 2016-02-28 13:25:54 +0900 | [diff] [blame] | 2 | |
| 3 | # |
| 4 | # Licensed to the Apache Software Foundation (ASF) under one |
| 5 | # or more contributor license agreements. See the NOTICE file |
| 6 | # distributed with this work for additional information |
| 7 | # regarding copyright ownership. The ASF licenses this file |
| 8 | # to you under the Apache License, Version 2.0 (the |
| 9 | # "License"); you may not use this file except in compliance |
| 10 | # with the License. You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, |
| 15 | # software distributed under the License is distributed on an |
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | # KIND, either express or implied. See the License for the |
| 18 | # specific language governing permissions and limitations |
| 19 | # under the License. |
| 20 | # |
| 21 | |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 22 | # Runs the D ThriftTest client and servers for all combinations of transport, |
| 23 | # protocol, SSL-mode and server type. |
| 24 | # Pass -k to keep going after failed tests. |
| 25 | |
Nobuaki Sukegawa | 4d28b60 | 2016-02-28 13:25:54 +0900 | [diff] [blame] | 26 | CUR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 27 | |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 28 | protocols="binary compact json" |
Nobuaki Sukegawa | 4d28b60 | 2016-02-28 13:25:54 +0900 | [diff] [blame] | 29 | # TODO: fix and enable http |
| 30 | # transports="buffered framed raw http" |
| 31 | transports="buffered framed raw" |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 32 | servers="simple taskpool threaded" |
| 33 | framed_only_servers="nonblocking pooledNonblocking" |
| 34 | |
| 35 | # Don't leave any server instances behind when interrupted (e.g. by Ctrl+C) |
| 36 | # or terminated. |
| 37 | trap "kill $(jobs -p) 2>/dev/null" INT TERM |
| 38 | |
Tdxdxoz | ec5e177 | 2022-07-18 21:52:02 +0800 | [diff] [blame^] | 39 | echo "THRIFT-4905 & THRIFT-5608: SSL tests are disabled. Fix them." |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 40 | for protocol in $protocols; do |
Tdxdxoz | ec5e177 | 2022-07-18 21:52:02 +0800 | [diff] [blame^] | 41 | # TODO: fix and enable ssl |
| 42 | # for ssl in "" " --ssl"; do |
| 43 | for ssl in ""; do |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 44 | for transport in $transports; do |
| 45 | for server in $servers $framed_only_servers; do |
| 46 | case $framed_only_servers in |
| 47 | *$server*) if [ $transport != "framed" ] || [ $ssl != "" ]; then continue; fi;; |
| 48 | esac |
| 49 | |
| 50 | args="--transport=$transport --protocol=$protocol$ssl" |
Nobuaki Sukegawa | 4d28b60 | 2016-02-28 13:25:54 +0900 | [diff] [blame] | 51 | ${CUR}/thrift_test_server $args --server-type=$server > /dev/null & |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 52 | server_pid=$! |
| 53 | |
| 54 | # Give the server some time to get up and check if it runs (yes, this |
| 55 | # is a huge kludge, should add a connect timeout to test client). |
| 56 | client_rc=-1 |
Nobuaki Sukegawa | 2cc4764 | 2016-03-05 16:07:37 +0900 | [diff] [blame] | 57 | if [ "$server" = "taskpool" ]; then |
| 58 | sleep 0.5 |
| 59 | else |
| 60 | sleep 0.02 |
| 61 | fi |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 62 | kill -0 $server_pid 2>/dev/null |
| 63 | if [ $? -eq 0 ]; then |
Nobuaki Sukegawa | 4d28b60 | 2016-02-28 13:25:54 +0900 | [diff] [blame] | 64 | ${CUR}/thrift_test_client $args --numTests=10 > /dev/null |
Jake Farrell | b95b0ff | 2012-03-22 21:49:10 +0000 | [diff] [blame] | 65 | client_rc=$? |
| 66 | |
| 67 | # Temporarily redirect stderr to null to avoid job control messages, |
| 68 | # restore it afterwards. |
| 69 | exec 3>&2 |
| 70 | exec 2>/dev/null |
| 71 | kill $server_pid |
| 72 | exec 3>&2 |
| 73 | fi |
| 74 | |
| 75 | # Get the server exit code (wait should immediately return). |
| 76 | wait $server_pid |
| 77 | server_rc=$? |
| 78 | |
| 79 | if [ $client_rc -ne 0 -o $server_rc -eq 1 ]; then |
| 80 | echo -e "\nTests failed for: $args --server-type=$server" |
| 81 | failed="true" |
| 82 | if [ "$1" != "-k" ]; then |
| 83 | exit 1 |
| 84 | fi |
| 85 | else |
| 86 | echo -n "." |
| 87 | fi |
| 88 | done |
| 89 | done |
| 90 | done |
| 91 | done |
| 92 | |
| 93 | echo |
| 94 | if [ -z "$failed" ]; then |
| 95 | echo "All tests passed." |
| 96 | fi |