blob: 351fa1c987fa1e3c01b0612ee37ede14dd243e3f [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}
60 timeout $server_timeout $server_exec > log/${testname}_server.log 2>&1 &
61 sleep $server_startup_time
62 $client_exec > log/${testname}_client.log 2>&1
63
64 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 Meierf42ce2a2013-01-16 22:12:14 +010091cpp_protocols="binary json"
92java_protocols="binary json compact"
93cpp_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 Meiereaa61d82012-01-12 21:38:29 +0000101
Roger Meierf42ce2a2013-01-16 22:12:14 +0100102ant -f ../lib/java/build.xml compile-test 1>/dev/null
103
104######### java client - java server #############
105for proto in $java_protocols; do
106 for trans in $java_server_transports; do
107 for sock in $java_sockets; do
108 case "$sock" in
109 "ip" ) extraparam="";;
110 "ip-ssl" ) extraparam="--ssl";;
111 esac
112 do_test "java-java" "${proto}" "${trans}-${sock}" \
113 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
114 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \
115 "15" "15"
116 done
117 done
118done
119
120######### cpp client - cpp server ###############
121for proto in $cpp_protocols; do
122 for trans in $cpp_transports; do
123 for sock in $cpp_sockets; do
Roger Meier4d5157d2012-01-09 21:23:19 +0000124 case "$sock" in
125 "ip" ) extraparam="";;
126 "ip-ssl" ) extraparam="--ssl";;
127 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
128 esac
129 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
130 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
131 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100132 "10" "10"
133 done
134 done
135done
136
137######### java client - cpp server ##############
138# warning: ssl over http is not supported in java client!
139for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do
140 for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do
141 for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do
142 case "$sock" in
143 "ip" ) extraparam="";;
144 "ip-ssl" ) extraparam="--ssl";;
145 esac
146 do_test "java-cpp" "${proto}" "${trans}-ip" \
147 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \
148 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\
149 "10" "15"
150 done
151 done
152done
153
154######### cpp client - java server ##############
155for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
156 for trans in $(intersection "${cpp_transports}" "${java_server_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
162 do_test "cpp-java" "${proto}" "${trans}-ip" \
163 "cpp/TestClient --protocol=${proto} --transport=${trans}" \
164 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans}\" testserver" \
165 "15" "10"
166 done
167 done
168done
Roger Meier4d5157d2012-01-09 21:23:19 +0000169
Roger Meier691ec002012-11-02 07:50:24 +0000170# delete Unix Domain Socket used by cpp tests
171rm -f /tmp/ThriftTest.thrift
172
Roger Meier85fb6de2012-11-02 00:05:42 +0000173do_test "py-py" "binary" "buffered-ip" \
174 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
175 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100176 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000177do_test "py-py" "json" "buffered-ip" \
178 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
179 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100180 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000181do_test "py-cpp" "binary" "buffered-ip" \
182 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
183 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100184 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000185do_test "py-cpp" "json" "buffered-ip" \
186 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
187 "cpp/TestServer --protocol=json" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100188 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000189do_test "cpp-py" "binary" "buffered-ip" \
190 "cpp/TestClient --protocol=binary --port=9090" \
191 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100192 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000193do_test "cpp-py" "json" "buffered-ip" \
194 "cpp/TestClient --protocol=json --port=9090" \
195 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100196 "10" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000197do_test "py-java" "binary" "buffered-ip" \
198 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100199 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \
200 "15" "15"
201do_test "py-java" "json" "json-ip" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000202 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100203 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \
204 "15" "10"
Roger Meier85fb6de2012-11-02 00:05:42 +0000205do_test "java-py" "binary" "buffered-ip" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100206 "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \
Roger Meier85fb6de2012-11-02 00:05:42 +0000207 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100208 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000209do_test "js-java" "json " "http-ip" \
210 "" \
211 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meierf42ce2a2013-01-16 22:12:14 +0100212 "10" "15"
Roger Meier4d5157d2012-01-09 21:23:19 +0000213do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000214 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000215 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100216 "10" "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000217do_test "php-cpp" "binary" "buffered-ip" \
218 "make -C php/ client" \
219 "cpp/TestServer" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100220 "10" "10"
Roger Meiereaa61d82012-01-12 21:38:29 +0000221do_test "nodejs-nodejs" "binary" "framed-ip" \
222 "make -C nodejs/ client" \
223 "make -C nodejs/ server" \
Henrique08c34ea2013-05-11 19:29:19 +0200224 "1" "5"
Henrique Mendoncad407b2d2012-10-22 21:06:14 +0000225do_test "nodejs-cpp" "binary" "framed-ip" \
226 "make -C nodejs/ client" \
227 "cpp/TestServer --transport=framed" \
Roger Meier8ebe0d92013-01-06 14:33:39 +0100228 "1" "10"
Roger Meiereaa61d82012-01-12 21:38:29 +0000229do_test "cpp-nodejs" "binary" "framed-ip" \
230 "cpp/TestClient --transport=framed" \
231 "make -C nodejs/ server" \
Henrique08c34ea2013-05-11 19:29:19 +0200232 "1" "5"
Roger Meier82525772012-11-16 00:38:27 +0000233
234cd -