blob: 60a381738e84d46b195c7f01c1cf931bf5f659ed [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 Meierf42ce2a2013-01-16 22:12:14 +010097cpp_sockets="ip domain"
98java_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
Roger Meierf42ce2a2013-01-16 22:12:14 +0100105ant -f ../lib/java/build.xml compile-test 1>/dev/null
106
107######### java client - java server #############
108for proto in $java_protocols; do
109 for trans in $java_server_transports; do
110 for sock in $java_sockets; do
111 case "$sock" in
112 "ip" ) extraparam="";;
113 "ip-ssl" ) extraparam="--ssl";;
114 esac
115 do_test "java-java" "${proto}" "${trans}-${sock}" \
116 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
117 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
118 "15" "15"
119 done
120 done
121done
122
123######### cpp client - cpp server ###############
124for proto in $cpp_protocols; do
125 for trans in $cpp_transports; do
126 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000127 case "$sock" in
128 "ip" ) extraparam="";;
129 "ip-ssl" ) extraparam="--ssl";;
130 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
131 esac
132 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
133 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
134 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100135 "10" "10"
136 done
137 done
138done
139
140######### java client - cpp server ##############
141# warning: ssl over http is not supported in java client!
142for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
143 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
144 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
145 case "$sock" in
146 "ip" ) extraparam="";;
147 "ip-ssl" ) extraparam="--ssl";;
148 esac
149 do_test "java-cpp" "${proto}" "${trans}-ip" \
150 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
151 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
152 "10" "15"
153 done
154 done
155done
156
157######### cpp client - java server ##############
158for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
159 for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do
160 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
161 case "$sock" in
162 "ip" ) extraparam="";;
163 "ip-ssl" ) extraparam="--ssl";;
164 esac
165 do_test "cpp-java" "${proto}" "${trans}-ip" \
166 "cpp/TestClient --protocol=${proto} --transport=${trans}" \
167 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans}\" testserver" \
168 "15" "10"
169 done
170 done
171done
Roger Meier4d5157d2012-01-09 21:23:19 +0000172
Roger Meier8909cbd2014-01-26 11:44:27 +0100173
174NODE_TEST_DIR=${BASEDIR}/../bin/nodejs/tests
175export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
176######### nodejs client - cpp server ##############
177##
178for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
179 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
180 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100181 case "$sock" in
182 "ip" ) extraparam="";;
183 "ip-ssl" ) extraparam="--ssl";;
184 esac
Roger Meier8909cbd2014-01-26 11:44:27 +0100185 do_test "nodejs-cpp" "${proto}" "${trans}-ip" \
Roger Meier57b354b2014-02-22 01:01:58 +0100186 "nodejs ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100187 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
188 "10" "10"
189 done
190 done
191done
192
193######### cpp client - nodejs server ##############
194for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
195 for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
196 for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
Roger Meier57b354b2014-02-22 01:01:58 +0100197 case "$sock" in
198 "ip" ) extraparam="";;
199 "ip-ssl" ) extraparam="--ssl";;
200 esac
Roger Meier8909cbd2014-01-26 11:44:27 +0100201 do_test "cpp-nodejs" "${proto}" "${trans}-ip" \
Roger Meier57b354b2014-02-22 01:01:58 +0100202 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
203 "nodejs ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans} ${extraparam}" \
Roger Meier8909cbd2014-01-26 11:44:27 +0100204 "10" "10"
205 done
206 done
207done
208
Roger Meier691ec002012-11-02 07:50:24 +0000209# delete Unix Domain Socket used by cpp tests
210rm -f /tmp/ThriftTest.thrift
211
Roger Meier85fb6de2012-11-02 00:05:42 +0000212do_test "py-py" "binary" "buffered-ip" \
213 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
214 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100215 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000216do_test "py-py" "json" "buffered-ip" \
217 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
218 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100219 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000220do_test "py-cpp" "binary" "buffered-ip" \
221 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
222 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100223 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000224do_test "py-cpp" "json" "buffered-ip" \
225 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
226 "cpp/TestServer --protocol=json" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100227 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000228do_test "cpp-py" "binary" "buffered-ip" \
229 "cpp/TestClient --protocol=binary --port=9090" \
230 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100231 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000232do_test "cpp-py" "json" "buffered-ip" \
233 "cpp/TestClient --protocol=json --port=9090" \
234 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100235 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000236do_test "py-java" "binary" "buffered-ip" \
237 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100238 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \
239 "15" "15"
Roger Meier7a66f752014-03-10 12:35:41 +0100240do_test "py-java" "json" "buffered-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000241 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100242 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \
243 "15" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000244do_test "java-py" "binary" "buffered-ip" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100245 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000246 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100247 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000248do_test "js-java" "json " "http-ip" \
249 "" \
250 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100251 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000252do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000253 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000254 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100255 "10" "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000256do_test "php-cpp" "binary" "buffered-ip" \
257 "make -C php/ client" \
258 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100259 "10" "10"
Roger Meierc95d5df2014-01-19 21:53:02 +0100260do_test "rb-rb" "binary" "buffered-ip" \
261 "ruby rb/integration/simple_client.rb" \
262 "ruby rb/integration/simple_server.rb" \
263 "1" "5"
Roger Meier9aa08a92014-01-20 18:41:48 +0100264do_test "rb-rb" "binary-accl" "buffered-ip" \
Roger Meierc95d5df2014-01-19 21:53:02 +0100265 "ruby rb/integration/accelerated_buffered_client.rb" \
266 "ruby rb/integration/accelerated_buffered_server.rb" \
267 "1" "5"
Roger Meier82525772012-11-16 00:38:27 +0000268cd -