blob: 43ec883598fba60263bb027c72dfe6876d92053d [file] [log] [blame]
Roger Meier4d5157d2012-01-09 21:23:19 +00001#!/bin/sh
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License. You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing,
14# software distributed under the License is distributed on an
15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16# KIND, either express or implied. See the License for the
17# specific language governing permissions and limitations
18# under the License.
19#
20
21# Apache Thrift - integration test suite
22#
23# tests different client-server, protocol and transport combinations
24
25# related issues:
26# THRIFT-847 Test Framework harmonization across all languages
27# THRIFT-819 add Enumeration for protocol, transport and server types
28
henriqued17f1c92014-04-30 16:21:25 +020029cd "$( dirname "$0" )"
30BASEDIR=$(pwd)
31
Roger Meier4d5157d2012-01-09 21:23:19 +000032print_header() {
33 printf "%-16s %-11s %-17s %-s\n" "client-server:" "protocol:" "transport:" "result:"
34}
35
Roger Meierf42ce2a2013-01-16 22:12:14 +010036intersection() {
37 return_value=""
38 for one in $1; do
39 for two in $2; do
40 if [ ${one} = ${two} ]; then
41 return_value=${return_value}" "${one}
42 fi
43 done;
44 done;
45 echo ${return_value};
46}
47
Roger Meier4d5157d2012-01-09 21:23:19 +000048do_test () {
49 client_server=$1
50 protocol=$2
51 transport=$3
52 client_exec=$4
53 server_exec=$5
henriqued17f1c92014-04-30 16:21:25 +020054 client_timeout=$6
55 server_startup_time=$7
Roger Meier4d5157d2012-01-09 21:23:19 +000056
57 testname=${client_server}_${protocol}_${transport}
henriqued5aba4c2014-04-30 18:11:11 +020058 server_timeout=$(echo "(${server_startup_time}+${client_timeout})" | bc)
Roger Meier4d5157d2012-01-09 21:23:19 +000059 printf "%-16s %-11s %-17s" ${client_server} ${protocol} ${transport}
henriqued17f1c92014-04-30 16:21:25 +020060
Roger Meier284101c2014-03-11 21:20:35 +010061 timeout $server_timeout $server_exec > log/${testname}_server.log 2>&1 &
henriqued17f1c92014-04-30 16:21:25 +020062 server_pid=$!
63
Roger Meier4d5157d2012-01-09 21:23:19 +000064 sleep $server_startup_time
henriqued17f1c92014-04-30 16:21:25 +020065 timeout $client_timeout $client_exec > log/${testname}_client.log 2>&1
Ben Craigf41d79d2014-01-08 15:15:48 -060066
Roger Meier4d5157d2012-01-09 21:23:19 +000067 if [ "$?" -eq "0" ]; then
68 echo " success"
69 else
70 echo " failure"
71 echo "=================== server message ==================="
72 tail log/${testname}_server.log
73 echo "=================== client message ==================="
74 tail log/${testname}_client.log
75 echo "======================================================"
Roger Meier85fb6de2012-11-02 00:05:42 +000076 echo ""
Roger Meier4d5157d2012-01-09 21:23:19 +000077 print_header
78 fi
henriqued17f1c92014-04-30 16:21:25 +020079
80 # silently kill server
81 kill ${server_pid} 2>/dev/null && wait ${server_pid} 2>/dev/null
Roger Meier4d5157d2012-01-09 21:23:19 +000082}
83
84echo "Apache Thrift - integration test suite"
85date
henriqued17f1c92014-04-30 16:21:25 +020086
87ant -f ../lib/java/build.xml compile-test 1>/dev/null
88
Roger Meier4d5157d2012-01-09 21:23:19 +000089echo "======================================================"
90
91rm -rf log
92mkdir -p log
93
94print_header
95
Roger Meier82525772012-11-16 00:38:27 +000096#TODO add enum for parameters
97#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +000098
Roger Meier023192f2014-02-12 09:35:12 +010099cpp_protocols="binary compact json"
100java_protocols="binary compact json"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100101cpp_transports="buffered framed http"
102java_server_transports="buffered framed fastframed"
103java_client_transports=${java_server_transports}" http"
Roger Meier4d5157d2012-01-09 21:23:19 +0000104# we need a test certificate first
Roger Meier5829a2c2014-04-08 00:28:17 +0200105cpp_sockets="ip domain ip-ssl"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100106java_sockets="ip ip-ssl"
107# TODO fastframed java transport is another implementation of framed transport
Roger Meier4d5157d2012-01-09 21:23:19 +0000108
Roger Meier8909cbd2014-01-26 11:44:27 +0100109nodejs_protocols="binary json"
110nodejs_transports="buffered framed"
Roger Meier57b354b2014-02-22 01:01:58 +0100111nodejs_sockets="ip ip-ssl"
Roger Meiereaa61d82012-01-12 21:38:29 +0000112
Jens Geyerc1d79432014-04-22 22:52:43 +0200113csharp_protocols="binary compact json"
114csharp_transports="buffered framed"
115csharp_sockets="ip ip-ssl"
116
Roger Meierf42ce2a2013-01-16 22:12:14 +0100117
118######### java client - java server #############
119for proto in $java_protocols; do
120 for trans in $java_server_transports; do
121 for sock in $java_sockets; do
122 case "$sock" in
123 "ip" ) extraparam="";;
124 "ip-ssl" ) extraparam="--ssl";;
125 esac
126 do_test "java-java" "${proto}" "${trans}-${sock}" \
henriqued5aba4c2014-04-30 18:11:11 +0200127 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testclient" \
128 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testserver" \
129 "5" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100130 done
131 done
132done
133
134######### cpp client - cpp server ###############
135for proto in $cpp_protocols; do
136 for trans in $cpp_transports; do
137 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000138 case "$sock" in
139 "ip" ) extraparam="";;
140 "ip-ssl" ) extraparam="--ssl";;
141 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
142 esac
143 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
144 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
145 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200146 "2" "0.1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100147 done
148 done
149done
150
henriqued17f1c92014-04-30 16:21:25 +0200151
Roger Meierf42ce2a2013-01-16 22:12:14 +0100152######### java client - cpp server ##############
153# warning: ssl over http is not supported in java client!
154for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
155 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
156 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
157 case "$sock" in
158 "ip" ) extraparam="";;
159 "ip-ssl" ) extraparam="--ssl";;
160 esac
Roger Meier188024e2014-04-17 21:53:45 +0200161 do_test "java-cpp" "${proto}" "${trans}-${sock}" \
henriqued5aba4c2014-04-30 18:11:11 +0200162 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testclient" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100163 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
henriqued5aba4c2014-04-30 18:11:11 +0200164 "5" "0.1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100165 done
166 done
167done
168
169######### cpp client - java server ##############
170for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
171 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
172 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
173 case "$sock" in
174 "ip" ) extraparam="";;
175 "ip-ssl" ) extraparam="--ssl";;
176 esac
Roger Meier188024e2014-04-17 21:53:45 +0200177 do_test "cpp-java" "${proto}" "${trans}-${sock}" \
178 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200179 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testserver" \
180 "5" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100181 done
182 done
183done
Roger Meier4d5157d2012-01-09 21:23:19 +0000184
Roger Meier8909cbd2014-01-26 11:44:27 +0100185
henriqued17f1c92014-04-30 16:21:25 +0200186NODE_TEST_DIR=${BASEDIR}/../lib/nodejs/test
Roger Meier8909cbd2014-01-26 11:44:27 +0100187export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
henriqued5aba4c2014-04-30 18:11:11 +0200188
Roger Meier8909cbd2014-01-26 11:44:27 +0100189######### nodejs client - cpp server ##############
190##
191for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
192 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
193 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100194 case "$sock" in
195 "ip" ) extraparam="";;
196 "ip-ssl" ) extraparam="--ssl";;
197 esac
henriqued17f1c92014-04-30 16:21:25 +0200198 do_test "nodejs-cpp" "${proto}" "${trans}-${sock}" \
199 "node ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100200 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200201 "5" "0.2"
Roger Meier8909cbd2014-01-26 11:44:27 +0100202 done
203 done
204done
205
206######### cpp client - nodejs server ##############
207for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
208 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
209 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100210 case "$sock" in
211 "ip" ) extraparam="";;
212 "ip-ssl" ) extraparam="--ssl";;
213 esac
henriqued17f1c92014-04-30 16:21:25 +0200214 do_test "cpp-nodejs" "${proto}" "${trans}-${sock}" \
Roger Meier57b354b2014-02-22 01:01:58 +0100215 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued17f1c92014-04-30 16:21:25 +0200216 "node ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200217 "5" "2"
Roger Meier8909cbd2014-01-26 11:44:27 +0100218 done
219 done
220done
221
Roger Meier691ec002012-11-02 07:50:24 +0000222# delete Unix Domain Socket used by cpp tests
223rm -f /tmp/ThriftTest.thrift
224
Jens Geyerc1d79432014-04-22 22:52:43 +0200225######### csharp client - csharp server #############
226export MONO_PATH=../lib/csharp
227for proto in $csharp_protocols; do
228 for trans in $csharp_transports; do
229 for sock in $csharp_sockets; do
230 case "$sock" in
231 "ip" ) extraparam="";;
232 "ip-ssl" ) extraparam="--ssl";;
233 esac
234 do_test "csharp-csharp" "${proto}" "${trans}-${sock}" \
235 "../lib/csharp/test/ThriftTest/TestClientServer.exe client --protocol=${proto} --transport=${trans} ${extraparam}" \
236 "../lib/csharp/test/ThriftTest/TestClientServer.exe server --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200237 "5" "1"
Jens Geyerc1d79432014-04-22 22:52:43 +0200238 done
239 done
240done
241
242
Roger Meier85fb6de2012-11-02 00:05:42 +0000243do_test "py-py" "binary" "buffered-ip" \
244 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
245 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200246 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000247do_test "py-py" "json" "buffered-ip" \
248 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
249 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200250 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000251do_test "py-cpp" "binary" "buffered-ip" \
252 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
253 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200254 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000255do_test "py-cpp" "json" "buffered-ip" \
256 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
257 "cpp/TestServer --protocol=json" \
henriqued5aba4c2014-04-30 18:11:11 +0200258 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000259do_test "cpp-py" "binary" "buffered-ip" \
260 "cpp/TestClient --protocol=binary --port=9090" \
261 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200262 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000263do_test "cpp-py" "json" "buffered-ip" \
264 "cpp/TestClient --protocol=json --port=9090" \
265 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200266 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000267do_test "py-java" "binary" "buffered-ip" \
268 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
henriqued17f1c92014-04-30 16:21:25 +0200269 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" run-testserver" \
henriqued5aba4c2014-04-30 18:11:11 +0200270 "15" "2"
Roger Meier7a66f752014-03-10 12:35:41 +0100271do_test "py-java" "json" "buffered-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000272 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
henriqued17f1c92014-04-30 16:21:25 +0200273 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" run-testserver" \
henriqued5aba4c2014-04-30 18:11:11 +0200274 "15" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000275do_test "java-py" "binary" "buffered-ip" \
henriqued17f1c92014-04-30 16:21:25 +0200276 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" run-testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000277 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued17f1c92014-04-30 16:21:25 +0200278 "10" "5"
Roger Meier4d5157d2012-01-09 21:23:19 +0000279do_test "js-java" "json " "http-ip" \
280 "" \
281 "ant -f ../lib/js/test/build.xml unittest" \
henriqued17f1c92014-04-30 16:21:25 +0200282 "2" "2"
Roger Meier4d5157d2012-01-09 21:23:19 +0000283do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000284 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000285 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200286 "10" "2"
Roger Meierb33967b2012-01-21 09:18:05 +0000287do_test "php-cpp" "binary" "buffered-ip" \
288 "make -C php/ client" \
289 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200290 "10" "2"
Roger Meierc95d5df2014-01-19 21:53:02 +0100291do_test "rb-rb" "binary" "buffered-ip" \
292 "ruby rb/integration/simple_client.rb" \
293 "ruby rb/integration/simple_server.rb" \
henriqued17f1c92014-04-30 16:21:25 +0200294 "5" "5"
Roger Meier9aa08a92014-01-20 18:41:48 +0100295do_test "rb-rb" "binary-accl" "buffered-ip" \
Roger Meierc95d5df2014-01-19 21:53:02 +0100296 "ruby rb/integration/accelerated_buffered_client.rb" \
297 "ruby rb/integration/accelerated_buffered_server.rb" \
henriqued17f1c92014-04-30 16:21:25 +0200298 "5" "5"
Roger Meier82525772012-11-16 00:38:27 +0000299cd -