blob: 6deb87dfd20389cb6c641802fc244aeb68c6cd9c [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)
30echo $BASEDIR
31cd $BASEDIR
Roger Meier4d5157d2012-01-09 21:23:19 +000032
33print_header() {
34 printf "%-16s %-11s %-17s %-s\n" "client-server:" "protocol:" "transport:" "result:"
35}
36
37do_test () {
38 client_server=$1
39 protocol=$2
40 transport=$3
41 client_exec=$4
42 server_exec=$5
43 server_startup_time=$6
44
45 testname=${client_server}_${protocol}_${transport}
46 server_timeout=$((${server_startup_time}+10))
47 printf "%-16s %-11s %-17s" ${client_server} ${protocol} ${transport}
48 timeout $server_timeout $server_exec > log/${testname}_server.log 2>&1 &
49 sleep $server_startup_time
50 $client_exec > log/${testname}_client.log 2>&1
51
52 if [ "$?" -eq "0" ]; then
53 echo " success"
54 else
55 echo " failure"
56 echo "=================== server message ==================="
57 tail log/${testname}_server.log
58 echo "=================== client message ==================="
59 tail log/${testname}_client.log
60 echo "======================================================"
Roger Meier85fb6de2012-11-02 00:05:42 +000061 echo ""
Roger Meier4d5157d2012-01-09 21:23:19 +000062 print_header
63 fi
64 sleep 10
65}
66
67echo "Apache Thrift - integration test suite"
68date
69echo "======================================================"
70
71rm -rf log
72mkdir -p log
73
74print_header
75
Roger Meier82525772012-11-16 00:38:27 +000076#TODO add enum for parameters
77#TODO align program arguments across languages
Roger Meier4d5157d2012-01-09 21:23:19 +000078
79protocols="binary json"
80transports="buffered framed http"
81sockets="ip domain"
82# we need a test certificate first
83#sockets="ip ip-ssl domain"
84
Roger Meiereaa61d82012-01-12 21:38:29 +000085
Roger Meier4d5157d2012-01-09 21:23:19 +000086for proto in $protocols; do
87 for trans in $transports; do
88 for sock in $sockets; do
89 case "$sock" in
90 "ip" ) extraparam="";;
91 "ip-ssl" ) extraparam="--ssl";;
92 "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";;
93 esac
94 do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \
95 "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \
96 "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
97 "10"
98 done;
99 done;
100done;
101
Roger Meier691ec002012-11-02 07:50:24 +0000102# delete Unix Domain Socket used by cpp tests
103rm -f /tmp/ThriftTest.thrift
104
Roger Meier85fb6de2012-11-02 00:05:42 +0000105do_test "py-py" "binary" "buffered-ip" \
106 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
107 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
108 "10"
109do_test "py-py" "json" "buffered-ip" \
110 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
111 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
112 "10"
113do_test "py-cpp" "binary" "buffered-ip" \
114 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
115 "cpp/TestServer" \
116 "10"
117do_test "py-cpp" "json" "buffered-ip" \
118 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
119 "cpp/TestServer --protocol=json" \
120 "10"
121do_test "cpp-py" "binary" "buffered-ip" \
122 "cpp/TestClient --protocol=binary --port=9090" \
123 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
124 "10"
125do_test "cpp-py" "json" "buffered-ip" \
126 "cpp/TestClient --protocol=json --port=9090" \
127 "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \
128 "10"
129do_test "py-java" "binary" "buffered-ip" \
130 "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \
131 "ant -f ../lib/java/build.xml testserver" \
Roger Meier82525772012-11-16 00:38:27 +0000132 "120"
Roger Meier85fb6de2012-11-02 00:05:42 +0000133do_test "py-java" "json" "buffered-ip" \
134 "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \
135 "ant -f ../lib/java/build.xml testserver" \
Roger Meier82525772012-11-16 00:38:27 +0000136 "120"
Roger Meier85fb6de2012-11-02 00:05:42 +0000137do_test "java-py" "binary" "buffered-ip" \
138 "ant -f ../lib/java/build.xml testclient" \
139 "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \
140 "10"
Roger Meier4d5157d2012-01-09 21:23:19 +0000141do_test "java-java" "binary" "buffered-ip" \
142 "ant -f ../lib/java/build.xml testclient" \
143 "ant -f ../lib/java/build.xml testserver" \
Roger Meier82525772012-11-16 00:38:27 +0000144 "120"
Roger Meier4d5157d2012-01-09 21:23:19 +0000145do_test "cpp-java" "binary" "buffered-ip" \
146 "cpp/TestClient" \
147 "ant -f ../lib/java/build.xml testserver" \
148 "100"
149do_test "cpp-java" "json" "buffered-ip" \
150 "cpp/TestClient" \
151 "ant -f ../lib/java/build.xml testserver" \
152 "100"
153do_test "js-java" "json " "http-ip" \
154 "" \
155 "ant -f ../lib/js/test/build.xml unittest" \
Roger Meier82525772012-11-16 00:38:27 +0000156 "120"
Roger Meier4d5157d2012-01-09 21:23:19 +0000157do_test "java-cpp" "binary" "buffered-ip" \
158 "ant -f ../lib/java/build.xml testclient" \
159 "cpp/TestServer" \
160 "10"
161do_test "perl-cpp" "binary" "buffered-ip" \
Roger Meier01b568c2012-01-10 21:30:02 +0000162 "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \
Roger Meier4d5157d2012-01-09 21:23:19 +0000163 "cpp/TestServer" \
164 "10"
Roger Meierb33967b2012-01-21 09:18:05 +0000165do_test "php-cpp" "binary" "buffered-ip" \
166 "make -C php/ client" \
167 "cpp/TestServer" \
168 "10"
Roger Meiereaa61d82012-01-12 21:38:29 +0000169do_test "nodejs-nodejs" "binary" "framed-ip" \
170 "make -C nodejs/ client" \
171 "make -C nodejs/ server" \
172 "1"
Henrique Mendoncad407b2d2012-10-22 21:06:14 +0000173do_test "nodejs-cpp" "binary" "framed-ip" \
174 "make -C nodejs/ client" \
175 "cpp/TestServer --transport=framed" \
176 "1"
Roger Meiereaa61d82012-01-12 21:38:29 +0000177do_test "cpp-nodejs" "binary" "framed-ip" \
178 "cpp/TestClient --transport=framed" \
179 "make -C nodejs/ server" \
180 "1"
Roger Meier82525772012-11-16 00:38:27 +0000181
182cd -