blob: 0247e31e257c1cab156835ec02e48a613fa3abbb [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 +000032
33print_header() {
34 printf "%-16s %-11s %-17s %-s\n" "client-server:" "protocol:" "transport:" "result:"
35}
36
Roger Meierf42ce2a2013-01-16 22:12:14 +010037intersection() {
38 return_value=""
39 for one in $1; do
40 for two in $2; do
41 if [ ${one} = ${two} ]; then
42 return_value=${return_value}" "${one}
43 fi
44 done;
45 done;
46 echo ${return_value};
47}
48
Roger Meier4d5157d2012-01-09 21:23:19 +000049do_test () {
50 client_server=$1
51 protocol=$2
52 transport=$3
53 client_exec=$4
54 server_exec=$5
henriqued17f1c92014-04-30 16:21:25 +020055 client_timeout=$6
56 server_startup_time=$7
Roger Meier4d5157d2012-01-09 21:23:19 +000057
58 testname=${client_server}_${protocol}_${transport}
henriqued17f1c92014-04-30 16:21:25 +020059 server_timeout=$((${server_startup_time}+${client_timeout}))
Roger Meier4d5157d2012-01-09 21:23:19 +000060 printf "%-16s %-11s %-17s" ${client_server} ${protocol} ${transport}
henriqued17f1c92014-04-30 16:21:25 +020061
Roger Meier284101c2014-03-11 21:20:35 +010062 timeout $server_timeout $server_exec > log/${testname}_server.log 2>&1 &
henriqued17f1c92014-04-30 16:21:25 +020063 server_pid=$!
64
Roger Meier4d5157d2012-01-09 21:23:19 +000065 sleep $server_startup_time
henriqued17f1c92014-04-30 16:21:25 +020066 timeout $client_timeout $client_exec > log/${testname}_client.log 2>&1
Ben Craigf41d79d2014-01-08 15:15:48 -060067
Roger Meier4d5157d2012-01-09 21:23:19 +000068 if [ "$?" -eq "0" ]; then
69 echo " success"
70 else
71 echo " failure"
72 echo "=================== server message ==================="
73 tail log/${testname}_server.log
74 echo "=================== client message ==================="
75 tail log/${testname}_client.log
76 echo "======================================================"
Roger Meier85fb6de2012-11-02 00:05:42 +000077 echo ""
Roger Meier4d5157d2012-01-09 21:23:19 +000078 print_header
79 fi
henriqued17f1c92014-04-30 16:21:25 +020080
81 # silently kill server
82 kill ${server_pid} 2>/dev/null && wait ${server_pid} 2>/dev/null
Roger Meier4d5157d2012-01-09 21:23:19 +000083}
84
85echo "Apache Thrift - integration test suite"
86date
henriqued17f1c92014-04-30 16:21:25 +020087
88ant -f ../lib/java/build.xml compile-test 1>/dev/null
89
Roger Meier4d5157d2012-01-09 21:23:19 +000090echo "======================================================"
91
92rm -rf log
93mkdir -p log
94
95print_header
96
Roger Meier82525772012-11-16 00:38:27 +000097#TODO add enum for parameters
98#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +000099
Roger Meier023192f2014-02-12 09:35:12 +0100100cpp_protocols="binary compact json"
101java_protocols="binary compact json"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100102cpp_transports="buffered framed http"
103java_server_transports="buffered framed fastframed"
104java_client_transports=${java_server_transports}" http"
Roger Meier4d5157d2012-01-09 21:23:19 +0000105# we need a test certificate first
Roger Meier5829a2c2014-04-08 00:28:17 +0200106cpp_sockets="ip domain ip-ssl"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100107java_sockets="ip ip-ssl"
108# TODO fastframed java transport is another implementation of framed transport
Roger Meier4d5157d2012-01-09 21:23:19 +0000109
Roger Meier8909cbd2014-01-26 11:44:27 +0100110nodejs_protocols="binary json"
111nodejs_transports="buffered framed"
Roger Meier57b354b2014-02-22 01:01:58 +0100112nodejs_sockets="ip ip-ssl"
Roger Meiereaa61d82012-01-12 21:38:29 +0000113
Jens Geyerc1d79432014-04-22 22:52:43 +0200114csharp_protocols="binary compact json"
115csharp_transports="buffered framed"
116csharp_sockets="ip ip-ssl"
117
Roger Meierf42ce2a2013-01-16 22:12:14 +0100118
119######### java client - java server #############
120for proto in $java_protocols; do
121 for trans in $java_server_transports; do
122 for sock in $java_sockets; do
123 case "$sock" in
124 "ip" ) extraparam="";;
125 "ip-ssl" ) extraparam="--ssl";;
126 esac
127 do_test "java-java" "${proto}" "${trans}-${sock}" \
128 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
129 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
henriqued17f1c92014-04-30 16:21:25 +0200130 "10" "2"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100131 done
132 done
133done
134
135######### cpp client - cpp server ###############
136for proto in $cpp_protocols; do
137 for trans in $cpp_transports; do
138 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000139 case "$sock" in
140 "ip" ) extraparam="";;
141 "ip-ssl" ) extraparam="--ssl";;
142 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
143 esac
144 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
145 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
146 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
henriqued17f1c92014-04-30 16:21:25 +0200147 "2" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100148 done
149 done
150done
151
henriqued17f1c92014-04-30 16:21:25 +0200152
Roger Meierf42ce2a2013-01-16 22:12:14 +0100153######### java client - cpp server ##############
154# warning: ssl over http is not supported in java client!
155for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
156 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
157 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
158 case "$sock" in
159 "ip" ) extraparam="";;
160 "ip-ssl" ) extraparam="--ssl";;
161 esac
Roger Meier188024e2014-04-17 21:53:45 +0200162 do_test "java-cpp" "${proto}" "${trans}-${sock}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100163 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
164 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
henriqued17f1c92014-04-30 16:21:25 +0200165 "10" "1"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100166 done
167 done
168done
169
170######### cpp client - java server ##############
171for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
172 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
173 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
174 case "$sock" in
175 "ip" ) extraparam="";;
176 "ip-ssl" ) extraparam="--ssl";;
177 esac
Roger Meier188024e2014-04-17 21:53:45 +0200178 do_test "cpp-java" "${proto}" "${trans}-${sock}" \
179 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
180 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
henriqued17f1c92014-04-30 16:21:25 +0200181 "1" "2"
Roger Meierf42ce2a2013-01-16 22:12:14 +0100182 done
183 done
184done
Roger Meier4d5157d2012-01-09 21:23:19 +0000185
Roger Meier8909cbd2014-01-26 11:44:27 +0100186
henriqued17f1c92014-04-30 16:21:25 +0200187NODE_TEST_DIR=${BASEDIR}/../lib/nodejs/test
Roger Meier8909cbd2014-01-26 11:44:27 +0100188export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
189######### 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}" \
henriqued17f1c92014-04-30 16:21:25 +0200201 "2" "1"
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}" \
217 "2" "1"
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}" \
henriqued17f1c92014-04-30 16:21:25 +0200237 "5" "5"
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" \
henriqued17f1c92014-04-30 16:21:25 +0200246 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200250 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200254 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200258 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200262 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200266 "2" "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" \
270 "2" "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" \
274 "2" "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" \
henriqued17f1c92014-04-30 16:21:25 +0200286 "10" "5"
Roger Meierb33967b2012-01-21 09:18:05 +0000287do_test "php-cpp" "binary" "buffered-ip" \
288 "make -C php/ client" \
289 "cpp/TestServer" \
henriqued17f1c92014-04-30 16:21:25 +0200290 "10" "5"
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 -