blob: 8a74697b4e4ad50bfacba673583a3caab7e59742 [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}
Ben Craigf41d79d2014-01-08 15:15:48 -060060 mkfifo thrift_test_communication
61 timeout $server_timeout $server_exec < thrift_test_communication > log/${testname}_server.log 2>&1 &
Roger Meier4d5157d2012-01-09 21:23:19 +000062 sleep $server_startup_time
63 $client_exec > log/${testname}_client.log 2>&1
Ben Craigf41d79d2014-01-08 15:15:48 -060064 echo "done" > thrift_test_communication
65 rm -f thrift_test_communication
66
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
Roger Meier8ebe0d92013-01-06 14:33:39 +010079 sleep ${client_delay}
Roger Meier4d5157d2012-01-09 21:23:19 +000080}
81
82echo "Apache Thrift - integration test suite"
83date
84echo "======================================================"
85
86rm -rf log
87mkdir -p log
88
89print_header
90
Roger Meier82525772012-11-16 00:38:27 +000091#TODO add enum for parameters
92#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +000093
Roger Meier023192f2014-02-12 09:35:12 +010094cpp_protocols="binary compact json"
95java_protocols="binary compact json"
Roger Meierf42ce2a2013-01-16 22:12:14 +010096cpp_transports="buffered framed http"
97java_server_transports="buffered framed fastframed"
98java_client_transports=${java_server_transports}" http"
Roger Meier4d5157d2012-01-09 21:23:19 +000099# we need a test certificate first
Roger Meierf42ce2a2013-01-16 22:12:14 +0100100cpp_sockets="ip domain"
101java_sockets="ip ip-ssl"
102# TODO fastframed java transport is another implementation of framed transport
Roger Meier4d5157d2012-01-09 21:23:19 +0000103
Roger Meier8909cbd2014-01-26 11:44:27 +0100104nodejs_protocols="binary json"
105nodejs_transports="buffered framed"
106nodejs_sockets="ip"
Roger Meiereaa61d82012-01-12 21:38:29 +0000107
Roger Meierf42ce2a2013-01-16 22:12:14 +0100108ant -f ../lib/java/build.xml compile-test 1>/dev/null
109
110######### java client - java server #############
111for proto in $java_protocols; do
112 for trans in $java_server_transports; do
113 for sock in $java_sockets; do
114 case "$sock" in
115 "ip" ) extraparam="";;
116 "ip-ssl" ) extraparam="--ssl";;
117 esac
118 do_test "java-java" "${proto}" "${trans}-${sock}" \
119 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
120 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
121 "15" "15"
122 done
123 done
124done
125
126######### cpp client - cpp server ###############
127for proto in $cpp_protocols; do
128 for trans in $cpp_transports; do
129 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000130 case "$sock" in
131 "ip" ) extraparam="";;
132 "ip-ssl" ) extraparam="--ssl";;
133 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
134 esac
135 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
136 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
137 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100138 "10" "10"
139 done
140 done
141done
142
143######### java client - cpp server ##############
144# warning: ssl over http is not supported in java client!
145for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
146 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
147 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
148 case "$sock" in
149 "ip" ) extraparam="";;
150 "ip-ssl" ) extraparam="--ssl";;
151 esac
152 do_test "java-cpp" "${proto}" "${trans}-ip" \
153 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
154 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
155 "10" "15"
156 done
157 done
158done
159
160######### cpp client - java server ##############
161for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
162 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
163 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
164 case "$sock" in
165 "ip" ) extraparam="";;
166 "ip-ssl" ) extraparam="--ssl";;
167 esac
168 do_test "cpp-java" "${proto}" "${trans}-ip" \
169 "cpp/TestClient --protocol=${proto} --transport=${trans}" \
170 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans}\" testserver" \
171 "15" "10"
172 done
173 done
174done
Roger Meier4d5157d2012-01-09 21:23:19 +0000175
Roger Meier8909cbd2014-01-26 11:44:27 +0100176
177NODE_TEST_DIR=${BASEDIR}/../bin/nodejs/tests
178export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
179######### nodejs client - cpp server ##############
180##
181for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
182 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
183 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
184 do_test "nodejs-cpp" "${proto}" "${trans}-ip" \
185 "nodejs ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans}" \
186 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
187 "10" "10"
188 done
189 done
190done
191
192######### cpp client - nodejs server ##############
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
196 do_test "cpp-nodejs" "${proto}" "${trans}-ip" \
197 "cpp/TestClient --protocol=${proto} --transport=${trans}" \
198 "nodejs ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans}" \
199 "10" "10"
200 done
201 done
202done
203
Roger Meier691ec002012-11-02 07:50:24 +0000204# delete Unix Domain Socket used by cpp tests
205rm -f /tmp/ThriftTest.thrift
206
Roger Meier85fb6de2012-11-02 00:05:42 +0000207do_test "py-py" "binary" "buffered-ip" \
208 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
209 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100210 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000211do_test "py-py" "json" "buffered-ip" \
212 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
213 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100214 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000215do_test "py-cpp" "binary" "buffered-ip" \
216 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
217 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100218 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000219do_test "py-cpp" "json" "buffered-ip" \
220 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
221 "cpp/TestServer --protocol=json" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100222 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000223do_test "cpp-py" "binary" "buffered-ip" \
224 "cpp/TestClient --protocol=binary --port=9090" \
225 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100226 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000227do_test "cpp-py" "json" "buffered-ip" \
228 "cpp/TestClient --protocol=json --port=9090" \
229 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100230 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000231do_test "py-java" "binary" "buffered-ip" \
232 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100233 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \
234 "15" "15"
235do_test "py-java" "json" "json-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000236 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100237 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \
238 "15" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000239do_test "java-py" "binary" "buffered-ip" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100240 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000241 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100242 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000243do_test "js-java" "json " "http-ip" \
244 "" \
245 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100246 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000247do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000248 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000249 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100250 "10" "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000251do_test "php-cpp" "binary" "buffered-ip" \
252 "make -C php/ client" \
253 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100254 "10" "10"
Roger Meierc95d5df2014-01-19 21:53:02 +0100255do_test "rb-rb" "binary" "buffered-ip" \
256 "ruby rb/integration/simple_client.rb" \
257 "ruby rb/integration/simple_server.rb" \
258 "1" "5"
Roger Meier9aa08a92014-01-20 18:41:48 +0100259do_test "rb-rb" "binary-accl" "buffered-ip" \
Roger Meierc95d5df2014-01-19 21:53:02 +0100260 "ruby rb/integration/accelerated_buffered_client.rb" \
261 "ruby rb/integration/accelerated_buffered_server.rb" \
262 "1" "5"
Roger Meier82525772012-11-16 00:38:27 +0000263cd -