blob: 91ac175cccac4a3c5537893377e6c8d1b2957de4 [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
Roger Meier82525772012-11-16 00:38:27 +000029BASEDIR=$(dirname $0)
Roger Meier82525772012-11-16 00:38:27 +000030cd $BASEDIR
Roger Meier4d5157d2012-01-09 21:23:19 +000031
32print_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
54 server_startup_time=$6
Roger Meier8ebe0d92013-01-06 14:33:39 +010055 client_delay=$7
Roger Meier4d5157d2012-01-09 21:23:19 +000056
57 testname=${client_server}_${protocol}_${transport}
Roger Meier8ebe0d92013-01-06 14:33:39 +010058 server_timeout=$((${server_startup_time}+${client_delay}))
Roger Meier4d5157d2012-01-09 21:23:19 +000059 printf "%-16s %-11s %-17s" ${client_server} ${protocol} ${transport}
Roger Meier284101c2014-03-11 21:20:35 +010060 timeout $server_timeout $server_exec > log/${testname}_server.log 2>&1 &
Roger Meier4d5157d2012-01-09 21:23:19 +000061 sleep $server_startup_time
62 $client_exec > log/${testname}_client.log 2>&1
Ben Craigf41d79d2014-01-08 15:15:48 -060063
Roger Meier4d5157d2012-01-09 21:23:19 +000064 if [ "$?" -eq "0" ]; then
65 echo " success"
66 else
67 echo " failure"
68 echo "=================== server message ==================="
69 tail log/${testname}_server.log
70 echo "=================== client message ==================="
71 tail log/${testname}_client.log
72 echo "======================================================"
Roger Meier85fb6de2012-11-02 00:05:42 +000073 echo ""
Roger Meier4d5157d2012-01-09 21:23:19 +000074 print_header
75 fi
Roger Meier8ebe0d92013-01-06 14:33:39 +010076 sleep ${client_delay}
Roger Meier4d5157d2012-01-09 21:23:19 +000077}
78
79echo "Apache Thrift - integration test suite"
80date
81echo "======================================================"
82
83rm -rf log
84mkdir -p log
85
86print_header
87
Roger Meier82525772012-11-16 00:38:27 +000088#TODO add enum for parameters
89#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +000090
Roger Meier023192f2014-02-12 09:35:12 +010091cpp_protocols="binary compact json"
92java_protocols="binary compact json"
Roger Meierf42ce2a2013-01-16 22:12:14 +010093cpp_transports="buffered framed http"
94java_server_transports="buffered framed fastframed"
95java_client_transports=${java_server_transports}" http"
Roger Meier4d5157d2012-01-09 21:23:19 +000096# we need a test certificate first
Roger Meier5829a2c2014-04-08 00:28:17 +020097cpp_sockets="ip domain ip-ssl"
Roger Meierf42ce2a2013-01-16 22:12:14 +010098java_sockets="ip ip-ssl"
99# TODO fastframed java transport is another implementation of framed transport
Roger Meier4d5157d2012-01-09 21:23:19 +0000100
Roger Meier8909cbd2014-01-26 11:44:27 +0100101nodejs_protocols="binary json"
102nodejs_transports="buffered framed"
Roger Meier57b354b2014-02-22 01:01:58 +0100103nodejs_sockets="ip ip-ssl"
Roger Meiereaa61d82012-01-12 21:38:29 +0000104
Jens Geyerc1d79432014-04-22 22:52:43 +0200105csharp_protocols="binary compact json"
106csharp_transports="buffered framed"
107csharp_sockets="ip ip-ssl"
108
Roger Meierf42ce2a2013-01-16 22:12:14 +0100109ant -f ../lib/java/build.xml compile-test 1>/dev/null
110
111######### java client - java server #############
112for proto in $java_protocols; do
113 for trans in $java_server_transports; do
114 for sock in $java_sockets; do
115 case "$sock" in
116 "ip" ) extraparam="";;
117 "ip-ssl" ) extraparam="--ssl";;
118 esac
119 do_test "java-java" "${proto}" "${trans}-${sock}" \
120 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
121 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
122 "15" "15"
123 done
124 done
125done
126
127######### cpp client - cpp server ###############
128for proto in $cpp_protocols; do
129 for trans in $cpp_transports; do
130 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000131 case "$sock" in
132 "ip" ) extraparam="";;
133 "ip-ssl" ) extraparam="--ssl";;
134 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
135 esac
136 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
137 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
138 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100139 "10" "10"
140 done
141 done
142done
143
144######### java client - cpp server ##############
145# warning: ssl over http is not supported in java client!
146for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
147 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
148 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
149 case "$sock" in
150 "ip" ) extraparam="";;
151 "ip-ssl" ) extraparam="--ssl";;
152 esac
Roger Meier188024e2014-04-17 21:53:45 +0200153 do_test "java-cpp" "${proto}" "${trans}-${sock}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100154 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
155 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
156 "10" "15"
157 done
158 done
159done
160
161######### cpp client - java server ##############
162for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
163 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
164 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
165 case "$sock" in
166 "ip" ) extraparam="";;
167 "ip-ssl" ) extraparam="--ssl";;
168 esac
Roger Meier188024e2014-04-17 21:53:45 +0200169 do_test "cpp-java" "${proto}" "${trans}-${sock}" \
170 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
171 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100172 "15" "10"
173 done
174 done
175done
Roger Meier4d5157d2012-01-09 21:23:19 +0000176
Roger Meier8909cbd2014-01-26 11:44:27 +0100177
ra161ffe72014-04-04 07:14:17 -0700178NODE_TEST_DIR=${BASEDIR}/../../lib/nodejs/test
Roger Meier8909cbd2014-01-26 11:44:27 +0100179export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
180######### nodejs client - cpp server ##############
181##
182for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
183 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
184 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100185 case "$sock" in
186 "ip" ) extraparam="";;
187 "ip-ssl" ) extraparam="--ssl";;
188 esac
Roger Meier8909cbd2014-01-26 11:44:27 +0100189 do_test "nodejs-cpp" "${proto}" "${trans}-ip" \
Roger Meier57b354b2014-02-22 01:01:58 +0100190 "nodejs ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100191 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
192 "10" "10"
193 done
194 done
195done
196
197######### cpp client - nodejs server ##############
198for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
199 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
200 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100201 case "$sock" in
202 "ip" ) extraparam="";;
203 "ip-ssl" ) extraparam="--ssl";;
204 esac
Roger Meier8909cbd2014-01-26 11:44:27 +0100205 do_test "cpp-nodejs" "${proto}" "${trans}-ip" \
Roger Meier57b354b2014-02-22 01:01:58 +0100206 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
207 "nodejs ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100208 "10" "10"
209 done
210 done
211done
212
Roger Meier691ec002012-11-02 07:50:24 +0000213# delete Unix Domain Socket used by cpp tests
214rm -f /tmp/ThriftTest.thrift
215
Jens Geyerc1d79432014-04-22 22:52:43 +0200216######### csharp client - csharp server #############
217export MONO_PATH=../lib/csharp
218for proto in $csharp_protocols; do
219 for trans in $csharp_transports; do
220 for sock in $csharp_sockets; do
221 case "$sock" in
222 "ip" ) extraparam="";;
223 "ip-ssl" ) extraparam="--ssl";;
224 esac
225 do_test "csharp-csharp" "${proto}" "${trans}-${sock}" \
226 "../lib/csharp/test/ThriftTest/TestClientServer.exe client --protocol=${proto} --transport=${trans} ${extraparam}" \
227 "../lib/csharp/test/ThriftTest/TestClientServer.exe server --protocol=${proto} --transport=${trans} ${extraparam}" \
228 "10" "10"
229 done
230 done
231done
232
233
Roger Meier85fb6de2012-11-02 00:05:42 +0000234do_test "py-py" "binary" "buffered-ip" \
235 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
236 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100237 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000238do_test "py-py" "json" "buffered-ip" \
239 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
240 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100241 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000242do_test "py-cpp" "binary" "buffered-ip" \
243 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
244 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100245 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000246do_test "py-cpp" "json" "buffered-ip" \
247 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
248 "cpp/TestServer --protocol=json" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100249 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000250do_test "cpp-py" "binary" "buffered-ip" \
251 "cpp/TestClient --protocol=binary --port=9090" \
252 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100253 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000254do_test "cpp-py" "json" "buffered-ip" \
255 "cpp/TestClient --protocol=json --port=9090" \
256 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100257 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000258do_test "py-java" "binary" "buffered-ip" \
259 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100260 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \
261 "15" "15"
Roger Meier7a66f752014-03-10 12:35:41 +0100262do_test "py-java" "json" "buffered-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000263 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100264 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \
265 "15" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000266do_test "java-py" "binary" "buffered-ip" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100267 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000268 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100269 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000270do_test "js-java" "json " "http-ip" \
271 "" \
272 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100273 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000274do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000275 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000276 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100277 "10" "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000278do_test "php-cpp" "binary" "buffered-ip" \
279 "make -C php/ client" \
280 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100281 "10" "10"
Roger Meierc95d5df2014-01-19 21:53:02 +0100282do_test "rb-rb" "binary" "buffered-ip" \
283 "ruby rb/integration/simple_client.rb" \
284 "ruby rb/integration/simple_server.rb" \
285 "1" "5"
Roger Meier9aa08a92014-01-20 18:41:48 +0100286do_test "rb-rb" "binary-accl" "buffered-ip" \
Roger Meierc95d5df2014-01-19 21:53:02 +0100287 "ruby rb/integration/accelerated_buffered_client.rb" \
288 "ruby rb/integration/accelerated_buffered_server.rb" \
289 "1" "5"
Roger Meier82525772012-11-16 00:38:27 +0000290cd -