blob: 27479c99af310a4b32a6eb7d08e93a9f7672de26 [file] [log] [blame]
Jake Farrellb95b0ff2012-03-22 21:49:10 +00001#!/bin/bash
Nobuaki Sukegawa4d28b602016-02-28 13:25:54 +09002
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 Farrellb95b0ff2012-03-22 21:49:10 +000022# 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 Sukegawa4d28b602016-02-28 13:25:54 +090026CUR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27
Jake Farrellb95b0ff2012-03-22 21:49:10 +000028protocols="binary compact json"
Nobuaki Sukegawa4d28b602016-02-28 13:25:54 +090029# TODO: fix and enable http
30# transports="buffered framed raw http"
31transports="buffered framed raw"
Jake Farrellb95b0ff2012-03-22 21:49:10 +000032servers="simple taskpool threaded"
33framed_only_servers="nonblocking pooledNonblocking"
34
35# Don't leave any server instances behind when interrupted (e.g. by Ctrl+C)
36# or terminated.
37trap "kill $(jobs -p) 2>/dev/null" INT TERM
38
39for protocol in $protocols; do
40 for ssl in "" " --ssl"; do
41 for transport in $transports; do
42 for server in $servers $framed_only_servers; do
43 case $framed_only_servers in
44 *$server*) if [ $transport != "framed" ] || [ $ssl != "" ]; then continue; fi;;
45 esac
46
47 args="--transport=$transport --protocol=$protocol$ssl"
Nobuaki Sukegawa4d28b602016-02-28 13:25:54 +090048 ${CUR}/thrift_test_server $args --server-type=$server > /dev/null &
Jake Farrellb95b0ff2012-03-22 21:49:10 +000049 server_pid=$!
50
51 # Give the server some time to get up and check if it runs (yes, this
52 # is a huge kludge, should add a connect timeout to test client).
53 client_rc=-1
54 sleep 0.01
55 kill -0 $server_pid 2>/dev/null
56 if [ $? -eq 0 ]; then
Nobuaki Sukegawa4d28b602016-02-28 13:25:54 +090057 ${CUR}/thrift_test_client $args --numTests=10 > /dev/null
Jake Farrellb95b0ff2012-03-22 21:49:10 +000058 client_rc=$?
59
60 # Temporarily redirect stderr to null to avoid job control messages,
61 # restore it afterwards.
62 exec 3>&2
63 exec 2>/dev/null
64 kill $server_pid
65 exec 3>&2
66 fi
67
68 # Get the server exit code (wait should immediately return).
69 wait $server_pid
70 server_rc=$?
71
72 if [ $client_rc -ne 0 -o $server_rc -eq 1 ]; then
73 echo -e "\nTests failed for: $args --server-type=$server"
74 failed="true"
75 if [ "$1" != "-k" ]; then
76 exit 1
77 fi
78 else
79 echo -n "."
80 fi
81 done
82 done
83 done
84done
85
86echo
87if [ -z "$failed" ]; then
88 echo "All tests passed."
89fi