blob: e3fc46d638bef23fc0bc067cba39d9a38cb53663 [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 Meierf42ce2a2013-01-16 22:12:14 +010094cpp_protocols="binary json"
95java_protocols="binary json compact"
96cpp_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 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 Meier691ec002012-11-02 07:50:24 +0000173# delete Unix Domain Socket used by cpp tests
174rm -f /tmp/ThriftTest.thrift
175
Roger Meier85fb6de2012-11-02 00:05:42 +0000176do_test "py-py" "binary" "buffered-ip" \
177 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
178 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100179 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000180do_test "py-py" "json" "buffered-ip" \
181 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
182 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100183 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000184do_test "py-cpp" "binary" "buffered-ip" \
185 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
186 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100187 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000188do_test "py-cpp" "json" "buffered-ip" \
189 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
190 "cpp/TestServer --protocol=json" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100191 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000192do_test "cpp-py" "binary" "buffered-ip" \
193 "cpp/TestClient --protocol=binary --port=9090" \
194 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100195 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000196do_test "cpp-py" "json" "buffered-ip" \
197 "cpp/TestClient --protocol=json --port=9090" \
198 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100199 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000200do_test "py-java" "binary" "buffered-ip" \
201 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100202 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \
203 "15" "15"
204do_test "py-java" "json" "json-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000205 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100206 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \
207 "15" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000208do_test "java-py" "binary" "buffered-ip" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100209 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000210 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100211 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000212do_test "js-java" "json " "http-ip" \
213 "" \
214 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100215 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000216do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000217 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000218 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100219 "10" "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000220do_test "php-cpp" "binary" "buffered-ip" \
221 "make -C php/ client" \
222 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100223 "10" "10"
Roger Meiereaa61d82012-01-12 21:38:29 +0000224do_test "nodejs-nodejs" "binary" "framed-ip" \
225 "make -C nodejs/ client" \
226 "make -C nodejs/ server" \
Henrique08c34ea2013-05-11 19:29:19 +0200227 "1" "5"
Henrique Mendoncad407b2d2012-10-22 21:06:14 +0000228do_test "nodejs-cpp" "binary" "framed-ip" \
229 "make -C nodejs/ client" \
230 "cpp/TestServer --transport=framed" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100231 "1" "10"
Roger Meiereaa61d82012-01-12 21:38:29 +0000232do_test "cpp-nodejs" "binary" "framed-ip" \
233 "cpp/TestClient --transport=framed" \
234 "make -C nodejs/ server" \
Henrique08c34ea2013-05-11 19:29:19 +0200235 "1" "5"
Roger Meierc95d5df2014-01-19 21:53:02 +0100236do_test "rb-rb" "binary" "buffered-ip" \
237 "ruby rb/integration/simple_client.rb" \
238 "ruby rb/integration/simple_server.rb" \
239 "1" "5"
240do_test "rb-rb" "binary-accel" "buffered-ip" \
241 "ruby rb/integration/accelerated_buffered_client.rb" \
242 "ruby rb/integration/accelerated_buffered_server.rb" \
243 "1" "5"
Roger Meier82525772012-11-16 00:38:27 +0000244cd -