blob: 90ec5a6e9fa34499b8beb7c1b8e6d4f4f01fba9f [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"
Roger Meier4edac7f2014-05-02 21:07:01 +020071 # add details to the error.log
72 print_header >> log/error.log
73 printf "%-16s %-11s %-17s\n" ${client_server} ${protocol} ${transport} >> log/error.log
74 echo "=================== server message ===================" >> log/error.log
75 tail log/${testname}_server.log >> log/error.log
76 echo "=================== client message ===================" >> log/error.log
77 tail log/${testname}_client.log >> log/error.log
78 echo "======================================================" >> log/error.log
79 echo "" >> log/error.log
Roger Meier4d5157d2012-01-09 21:23:19 +000080 fi
henriqued17f1c92014-04-30 16:21:25 +020081
82 # silently kill server
83 kill ${server_pid} 2>/dev/null && wait ${server_pid} 2>/dev/null
Roger Meier4d5157d2012-01-09 21:23:19 +000084}
85
86echo "Apache Thrift - integration test suite"
87date
henriqued17f1c92014-04-30 16:21:25 +020088
89ant -f ../lib/java/build.xml compile-test 1>/dev/null
90
Roger Meier4d5157d2012-01-09 21:23:19 +000091echo "======================================================"
92
93rm -rf log
94mkdir -p log
95
96print_header
97
Roger Meier82525772012-11-16 00:38:27 +000098#TODO add enum for parameters
99#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +0000100
Roger Meier023192f2014-02-12 09:35:12 +0100101cpp_protocols="binary compact json"
102java_protocols="binary compact json"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100103cpp_transports="buffered framed http"
104java_server_transports="buffered framed fastframed"
105java_client_transports=${java_server_transports}" http"
Roger Meier4d5157d2012-01-09 21:23:19 +0000106# we need a test certificate first
Roger Meier5829a2c2014-04-08 00:28:17 +0200107cpp_sockets="ip domain ip-ssl"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100108java_sockets="ip ip-ssl"
109# TODO fastframed java transport is another implementation of framed transport
Roger Meier4d5157d2012-01-09 21:23:19 +0000110
Roger Meier8909cbd2014-01-26 11:44:27 +0100111nodejs_protocols="binary json"
112nodejs_transports="buffered framed"
Roger Meier57b354b2014-02-22 01:01:58 +0100113nodejs_sockets="ip ip-ssl"
Roger Meiereaa61d82012-01-12 21:38:29 +0000114
Jens Geyerc1d79432014-04-22 22:52:43 +0200115csharp_protocols="binary compact json"
116csharp_transports="buffered framed"
117csharp_sockets="ip ip-ssl"
118
Roger Meierf42ce2a2013-01-16 22:12:14 +0100119
120######### java client - java server #############
121for proto in $java_protocols; do
122 for trans in $java_server_transports; do
123 for sock in $java_sockets; do
124 case "$sock" in
125 "ip" ) extraparam="";;
126 "ip-ssl" ) extraparam="--ssl";;
127 esac
128 do_test "java-java" "${proto}" "${trans}-${sock}" \
henriqued5aba4c2014-04-30 18:11:11 +0200129 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testclient" \
130 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testserver" \
131 "5" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100132 done
133 done
134done
135
136######### cpp client - cpp server ###############
137for proto in $cpp_protocols; do
138 for trans in $cpp_transports; do
139 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000140 case "$sock" in
141 "ip" ) extraparam="";;
142 "ip-ssl" ) extraparam="--ssl";;
143 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
144 esac
145 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
146 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
147 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200148 "2" "0.1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100149 done
150 done
151done
152
henriqued17f1c92014-04-30 16:21:25 +0200153
Roger Meierf42ce2a2013-01-16 22:12:14 +0100154######### java client - cpp server ##############
155# warning: ssl over http is not supported in java client!
156for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
157 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
158 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
159 case "$sock" in
160 "ip" ) extraparam="";;
161 "ip-ssl" ) extraparam="--ssl";;
162 esac
Roger Meier188024e2014-04-17 21:53:45 +0200163 do_test "java-cpp" "${proto}" "${trans}-${sock}" \
henriqued5aba4c2014-04-30 18:11:11 +0200164 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testclient" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100165 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
henriqued5aba4c2014-04-30 18:11:11 +0200166 "5" "0.1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100167 done
168 done
169done
170
171######### cpp client - java server ##############
172for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
173 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
174 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
175 case "$sock" in
176 "ip" ) extraparam="";;
177 "ip-ssl" ) extraparam="--ssl";;
178 esac
Roger Meier188024e2014-04-17 21:53:45 +0200179 do_test "cpp-java" "${proto}" "${trans}-${sock}" \
180 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200181 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" run-testserver" \
182 "5" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100183 done
184 done
185done
Roger Meier4d5157d2012-01-09 21:23:19 +0000186
Roger Meier8909cbd2014-01-26 11:44:27 +0100187
henriqued17f1c92014-04-30 16:21:25 +0200188NODE_TEST_DIR=${BASEDIR}/../lib/nodejs/test
Roger Meier8909cbd2014-01-26 11:44:27 +0100189export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
henriqued5aba4c2014-04-30 18:11:11 +0200190
Roger Meier8909cbd2014-01-26 11:44:27 +0100191######### nodejs client - cpp server ##############
192##
193for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
194 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
195 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100196 case "$sock" in
197 "ip" ) extraparam="";;
198 "ip-ssl" ) extraparam="--ssl";;
199 esac
henriqued17f1c92014-04-30 16:21:25 +0200200 do_test "nodejs-cpp" "${proto}" "${trans}-${sock}" \
201 "node ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100202 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200203 "5" "0.2"
Roger Meier8909cbd2014-01-26 11:44:27 +0100204 done
205 done
206done
207
208######### cpp client - nodejs server ##############
209for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
210 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
211 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100212 case "$sock" in
213 "ip" ) extraparam="";;
214 "ip-ssl" ) extraparam="--ssl";;
215 esac
henriqued17f1c92014-04-30 16:21:25 +0200216 do_test "cpp-nodejs" "${proto}" "${trans}-${sock}" \
Roger Meier57b354b2014-02-22 01:01:58 +0100217 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued17f1c92014-04-30 16:21:25 +0200218 "node ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200219 "5" "2"
Roger Meier8909cbd2014-01-26 11:44:27 +0100220 done
221 done
222done
223
Roger Meier691ec002012-11-02 07:50:24 +0000224# delete Unix Domain Socket used by cpp tests
225rm -f /tmp/ThriftTest.thrift
226
Jens Geyerc1d79432014-04-22 22:52:43 +0200227######### csharp client - csharp server #############
228export MONO_PATH=../lib/csharp
229for proto in $csharp_protocols; do
230 for trans in $csharp_transports; do
231 for sock in $csharp_sockets; do
232 case "$sock" in
233 "ip" ) extraparam="";;
234 "ip-ssl" ) extraparam="--ssl";;
235 esac
236 do_test "csharp-csharp" "${proto}" "${trans}-${sock}" \
237 "../lib/csharp/test/ThriftTest/TestClientServer.exe client --protocol=${proto} --transport=${trans} ${extraparam}" \
238 "../lib/csharp/test/ThriftTest/TestClientServer.exe server --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued5aba4c2014-04-30 18:11:11 +0200239 "5" "1"
Jens Geyerc1d79432014-04-22 22:52:43 +0200240 done
241 done
242done
243
244
Roger Meier85fb6de2012-11-02 00:05:42 +0000245do_test "py-py" "binary" "buffered-ip" \
246 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
247 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200248 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000249do_test "py-py" "json" "buffered-ip" \
250 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
251 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200252 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000253do_test "py-cpp" "binary" "buffered-ip" \
254 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
255 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200256 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000257do_test "py-cpp" "json" "buffered-ip" \
258 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
259 "cpp/TestServer --protocol=json" \
henriqued5aba4c2014-04-30 18:11:11 +0200260 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000261do_test "cpp-py" "binary" "buffered-ip" \
262 "cpp/TestClient --protocol=binary --port=9090" \
263 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200264 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000265do_test "cpp-py" "json" "buffered-ip" \
266 "cpp/TestClient --protocol=json --port=9090" \
267 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200268 "10" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000269do_test "py-java" "binary" "buffered-ip" \
270 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
henriqued17f1c92014-04-30 16:21:25 +0200271 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" run-testserver" \
henriqued5aba4c2014-04-30 18:11:11 +0200272 "15" "2"
Roger Meier7a66f752014-03-10 12:35:41 +0100273do_test "py-java" "json" "buffered-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000274 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
henriqued17f1c92014-04-30 16:21:25 +0200275 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" run-testserver" \
henriqued5aba4c2014-04-30 18:11:11 +0200276 "15" "2"
Roger Meier85fb6de2012-11-02 00:05:42 +0000277do_test "java-py" "binary" "buffered-ip" \
henriqued17f1c92014-04-30 16:21:25 +0200278 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" run-testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000279 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
henriqued17f1c92014-04-30 16:21:25 +0200280 "10" "5"
Roger Meier4edac7f2014-05-02 21:07:01 +0200281do_test "js-java" "json" "http-ip" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000282 "" \
283 "ant -f ../lib/js/test/build.xml unittest" \
henriqued17f1c92014-04-30 16:21:25 +0200284 "2" "2"
Roger Meier4d5157d2012-01-09 21:23:19 +0000285do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000286 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000287 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200288 "10" "2"
Roger Meierb33967b2012-01-21 09:18:05 +0000289do_test "php-cpp" "binary" "buffered-ip" \
290 "make -C php/ client" \
291 "cpp/TestServer" \
henriqued5aba4c2014-04-30 18:11:11 +0200292 "10" "2"
Roger Meierc95d5df2014-01-19 21:53:02 +0100293do_test "rb-rb" "binary" "buffered-ip" \
294 "ruby rb/integration/simple_client.rb" \
295 "ruby rb/integration/simple_server.rb" \
henriqued17f1c92014-04-30 16:21:25 +0200296 "5" "5"
Roger Meier9aa08a92014-01-20 18:41:48 +0100297do_test "rb-rb" "binary-accl" "buffered-ip" \
Roger Meierc95d5df2014-01-19 21:53:02 +0100298 "ruby rb/integration/accelerated_buffered_client.rb" \
299 "ruby rb/integration/accelerated_buffered_server.rb" \
henriqued17f1c92014-04-30 16:21:25 +0200300 "5" "5"
Roger Meier4edac7f2014-05-02 21:07:01 +0200301
302echo " failed tests are logged to test/log/error.log"
303echo " full log is here test/log/client_server_protocol_transport.log"
304date
Roger Meier82525772012-11-16 00:38:27 +0000305cd -