Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 1 | #!/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 Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 29 | BASEDIR=$(dirname $0) |
Roger Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 30 | cd $BASEDIR |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 31 | |
| 32 | print_header() { |
| 33 | printf "%-16s %-11s %-17s %-s\n" "client-server:" "protocol:" "transport:" "result:" |
| 34 | } |
| 35 | |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 36 | intersection() { |
| 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 Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 48 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 55 | client_delay=$7 |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 56 | |
| 57 | testname=${client_server}_${protocol}_${transport} |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 58 | server_timeout=$((${server_startup_time}+${client_delay})) |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 59 | 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 Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 73 | echo "" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 74 | print_header |
| 75 | fi |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 76 | sleep ${client_delay} |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | echo "Apache Thrift - integration test suite" |
| 80 | date |
| 81 | echo "======================================================" |
| 82 | |
| 83 | rm -rf log |
| 84 | mkdir -p log |
| 85 | |
| 86 | print_header |
| 87 | |
Roger Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 88 | #TODO add enum for parameters |
| 89 | #TODO align program arguments across languages |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 90 | |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 91 | cpp_protocols="binary json" |
| 92 | java_protocols="binary json compact" |
| 93 | cpp_transports="buffered framed http" |
| 94 | java_server_transports="buffered framed fastframed" |
| 95 | java_client_transports=${java_server_transports}" http" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 96 | # we need a test certificate first |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 97 | cpp_sockets="ip domain" |
| 98 | java_sockets="ip ip-ssl" |
| 99 | # TODO fastframed java transport is another implementation of framed transport |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 100 | |
Roger Meier | eaa61d8 | 2012-01-12 21:38:29 +0000 | [diff] [blame] | 101 | |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 102 | ant -f ../lib/java/build.xml compile-test 1>/dev/null |
| 103 | |
| 104 | ######### java client - java server ############# |
| 105 | for 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 |
| 118 | done |
| 119 | |
| 120 | ######### cpp client - cpp server ############### |
| 121 | for proto in $cpp_protocols; do |
| 122 | for trans in $cpp_transports; do |
| 123 | for sock in $cpp_sockets; do |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 124 | 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 Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 132 | "10" "10" |
| 133 | done |
| 134 | done |
| 135 | done |
| 136 | |
| 137 | ######### java client - cpp server ############## |
| 138 | # warning: ssl over http is not supported in java client! |
| 139 | for 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 |
| 152 | done |
| 153 | |
| 154 | ######### cpp client - java server ############## |
| 155 | for 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 |
| 168 | done |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 169 | |
Roger Meier | 691ec00 | 2012-11-02 07:50:24 +0000 | [diff] [blame] | 170 | # delete Unix Domain Socket used by cpp tests |
| 171 | rm -f /tmp/ThriftTest.thrift |
| 172 | |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 173 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 176 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 177 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 180 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 181 | do_test "py-cpp" "binary" "buffered-ip" \ |
| 182 | "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \ |
| 183 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 184 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 185 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 188 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 189 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 192 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 193 | do_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 Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 196 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 197 | do_test "py-java" "binary" "buffered-ip" \ |
| 198 | "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 199 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \ |
| 200 | "15" "15" |
| 201 | do_test "py-java" "json" "json-ip" \ |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 202 | "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 203 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \ |
| 204 | "15" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 205 | do_test "java-py" "binary" "buffered-ip" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 206 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \ |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 207 | "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 208 | "10" "15" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 209 | do_test "js-java" "json " "http-ip" \ |
| 210 | "" \ |
| 211 | "ant -f ../lib/js/test/build.xml unittest" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 212 | "10" "15" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 213 | do_test "perl-cpp" "binary" "buffered-ip" \ |
Roger Meier | 01b568c | 2012-01-10 21:30:02 +0000 | [diff] [blame] | 214 | "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \ |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 215 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 216 | "10" "10" |
Roger Meier | b33967b | 2012-01-21 09:18:05 +0000 | [diff] [blame] | 217 | do_test "php-cpp" "binary" "buffered-ip" \ |
| 218 | "make -C php/ client" \ |
| 219 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 220 | "10" "10" |
Roger Meier | eaa61d8 | 2012-01-12 21:38:29 +0000 | [diff] [blame] | 221 | do_test "nodejs-nodejs" "binary" "framed-ip" \ |
| 222 | "make -C nodejs/ client" \ |
| 223 | "make -C nodejs/ server" \ |
Henrique | 08c34ea | 2013-05-11 19:29:19 +0200 | [diff] [blame] | 224 | "1" "5" |
Henrique Mendonca | d407b2d | 2012-10-22 21:06:14 +0000 | [diff] [blame] | 225 | do_test "nodejs-cpp" "binary" "framed-ip" \ |
| 226 | "make -C nodejs/ client" \ |
| 227 | "cpp/TestServer --transport=framed" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 228 | "1" "10" |
Roger Meier | eaa61d8 | 2012-01-12 21:38:29 +0000 | [diff] [blame] | 229 | do_test "cpp-nodejs" "binary" "framed-ip" \ |
| 230 | "cpp/TestClient --transport=framed" \ |
| 231 | "make -C nodejs/ server" \ |
Henrique | 08c34ea | 2013-05-11 19:29:19 +0200 | [diff] [blame] | 232 | "1" "5" |
Roger Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 233 | |
| 234 | cd - |