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} |
Ben Craig | f41d79d | 2014-01-08 15:15:48 -0600 | [diff] [blame] | 60 | mkfifo thrift_test_communication |
| 61 | timeout $server_timeout $server_exec < thrift_test_communication > log/${testname}_server.log 2>&1 & |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 62 | sleep $server_startup_time |
| 63 | $client_exec > log/${testname}_client.log 2>&1 |
Ben Craig | f41d79d | 2014-01-08 15:15:48 -0600 | [diff] [blame] | 64 | echo "done" > thrift_test_communication |
| 65 | rm -f thrift_test_communication |
| 66 | |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 67 | 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 Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 76 | echo "" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 77 | print_header |
| 78 | fi |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 79 | sleep ${client_delay} |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | echo "Apache Thrift - integration test suite" |
| 83 | date |
| 84 | echo "======================================================" |
| 85 | |
| 86 | rm -rf log |
| 87 | mkdir -p log |
| 88 | |
| 89 | print_header |
| 90 | |
Roger Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 91 | #TODO add enum for parameters |
| 92 | #TODO align program arguments across languages |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 93 | |
Roger Meier | 023192f | 2014-02-12 09:35:12 +0100 | [diff] [blame] | 94 | cpp_protocols="binary compact json" |
| 95 | java_protocols="binary compact json" |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 96 | cpp_transports="buffered framed http" |
| 97 | java_server_transports="buffered framed fastframed" |
| 98 | java_client_transports=${java_server_transports}" http" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 99 | # we need a test certificate first |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 100 | cpp_sockets="ip domain" |
| 101 | java_sockets="ip ip-ssl" |
| 102 | # TODO fastframed java transport is another implementation of framed transport |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 103 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 104 | nodejs_protocols="binary json" |
| 105 | nodejs_transports="buffered framed" |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 106 | nodejs_sockets="ip ip-ssl" |
Roger Meier | eaa61d8 | 2012-01-12 21:38:29 +0000 | [diff] [blame] | 107 | |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 108 | ant -f ../lib/java/build.xml compile-test 1>/dev/null |
| 109 | |
| 110 | ######### java client - java server ############# |
| 111 | for proto in $java_protocols; do |
| 112 | for trans in $java_server_transports; do |
| 113 | for sock in $java_sockets; do |
| 114 | case "$sock" in |
| 115 | "ip" ) extraparam="";; |
| 116 | "ip-ssl" ) extraparam="--ssl";; |
| 117 | esac |
| 118 | do_test "java-java" "${proto}" "${trans}-${sock}" \ |
| 119 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \ |
| 120 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testserver" \ |
| 121 | "15" "15" |
| 122 | done |
| 123 | done |
| 124 | done |
| 125 | |
| 126 | ######### cpp client - cpp server ############### |
| 127 | for proto in $cpp_protocols; do |
| 128 | for trans in $cpp_transports; do |
| 129 | for sock in $cpp_sockets; do |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 130 | case "$sock" in |
| 131 | "ip" ) extraparam="";; |
| 132 | "ip-ssl" ) extraparam="--ssl";; |
| 133 | "domain" ) extraparam="--domain-socket=/tmp/ThriftTest.thrift";; |
| 134 | esac |
| 135 | do_test "cpp-cpp" "${proto}" "${trans}-${sock}" \ |
| 136 | "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \ |
| 137 | "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 138 | "10" "10" |
| 139 | done |
| 140 | done |
| 141 | done |
| 142 | |
| 143 | ######### java client - cpp server ############## |
| 144 | # warning: ssl over http is not supported in java client! |
| 145 | for proto in $(intersection "${java_protocols}" "${cpp_protocols}"); do |
| 146 | for trans in $(intersection "${java_client_transports}" "${cpp_transports}"); do |
| 147 | for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do |
| 148 | case "$sock" in |
| 149 | "ip" ) extraparam="";; |
| 150 | "ip-ssl" ) extraparam="--ssl";; |
| 151 | esac |
| 152 | do_test "java-cpp" "${proto}" "${trans}-ip" \ |
| 153 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans} ${extraparam}\" testclient" \ |
| 154 | "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}"\ |
| 155 | "10" "15" |
| 156 | done |
| 157 | done |
| 158 | done |
| 159 | |
| 160 | ######### cpp client - java server ############## |
| 161 | for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do |
| 162 | for trans in $(intersection "${cpp_transports}" "${java_server_transports}"); do |
| 163 | for sock in $(intersection "${java_sockets}" "${cpp_sockets}"); do |
| 164 | case "$sock" in |
| 165 | "ip" ) extraparam="";; |
| 166 | "ip-ssl" ) extraparam="--ssl";; |
| 167 | esac |
| 168 | do_test "cpp-java" "${proto}" "${trans}-ip" \ |
| 169 | "cpp/TestClient --protocol=${proto} --transport=${trans}" \ |
| 170 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=${proto} --transport=${trans}\" testserver" \ |
| 171 | "15" "10" |
| 172 | done |
| 173 | done |
| 174 | done |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 175 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 176 | |
| 177 | NODE_TEST_DIR=${BASEDIR}/../bin/nodejs/tests |
| 178 | export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH} |
| 179 | ######### nodejs client - cpp server ############## |
| 180 | ## |
| 181 | for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do |
| 182 | for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do |
| 183 | for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 184 | case "$sock" in |
| 185 | "ip" ) extraparam="";; |
| 186 | "ip-ssl" ) extraparam="--ssl";; |
| 187 | esac |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 188 | do_test "nodejs-cpp" "${proto}" "${trans}-ip" \ |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 189 | "nodejs ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans} ${extraparam}" \ |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 190 | "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \ |
| 191 | "10" "10" |
| 192 | done |
| 193 | done |
| 194 | done |
| 195 | |
| 196 | ######### cpp client - nodejs server ############## |
| 197 | for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do |
| 198 | for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do |
| 199 | for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 200 | case "$sock" in |
| 201 | "ip" ) extraparam="";; |
| 202 | "ip-ssl" ) extraparam="--ssl";; |
| 203 | esac |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 204 | do_test "cpp-nodejs" "${proto}" "${trans}-ip" \ |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 205 | "cpp/TestClient --protocol=${proto} --transport=${trans} ${extraparam}" \ |
| 206 | "nodejs ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans} ${extraparam}" \ |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 207 | "10" "10" |
| 208 | done |
| 209 | done |
| 210 | done |
| 211 | |
Roger Meier | 691ec00 | 2012-11-02 07:50:24 +0000 | [diff] [blame] | 212 | # delete Unix Domain Socket used by cpp tests |
| 213 | rm -f /tmp/ThriftTest.thrift |
| 214 | |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 215 | do_test "py-py" "binary" "buffered-ip" \ |
| 216 | "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \ |
| 217 | "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 218 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 219 | do_test "py-py" "json" "buffered-ip" \ |
| 220 | "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \ |
| 221 | "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 222 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 223 | do_test "py-cpp" "binary" "buffered-ip" \ |
| 224 | "py/TestClient.py --proto=binary --port=9090 --host=localhost --genpydir=py/gen-py" \ |
| 225 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 226 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 227 | do_test "py-cpp" "json" "buffered-ip" \ |
| 228 | "py/TestClient.py --proto=json --port=9090 --host=localhost --genpydir=py/gen-py" \ |
| 229 | "cpp/TestServer --protocol=json" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 230 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 231 | do_test "cpp-py" "binary" "buffered-ip" \ |
| 232 | "cpp/TestClient --protocol=binary --port=9090" \ |
| 233 | "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 234 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 235 | do_test "cpp-py" "json" "buffered-ip" \ |
| 236 | "cpp/TestClient --protocol=json --port=9090" \ |
| 237 | "py/TestServer.py --proto=json --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 238 | "10" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 239 | do_test "py-java" "binary" "buffered-ip" \ |
| 240 | "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] | 241 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testserver" \ |
| 242 | "15" "15" |
| 243 | do_test "py-java" "json" "json-ip" \ |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 244 | "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] | 245 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" -Dtestargs \"--protocol=json\" testserver" \ |
| 246 | "15" "10" |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 247 | do_test "java-py" "binary" "buffered-ip" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 248 | "ant -f ../lib/java/build.xml -Dno-gen-thrift=\"\" testclient" \ |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 249 | "py/TestServer.py --proto=binary --port=9090 --genpydir=py/gen-py TSimpleServer" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 250 | "10" "15" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 251 | do_test "js-java" "json " "http-ip" \ |
| 252 | "" \ |
| 253 | "ant -f ../lib/js/test/build.xml unittest" \ |
Roger Meier | f42ce2a | 2013-01-16 22:12:14 +0100 | [diff] [blame] | 254 | "10" "15" |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 255 | do_test "perl-cpp" "binary" "buffered-ip" \ |
Roger Meier | 01b568c | 2012-01-10 21:30:02 +0000 | [diff] [blame] | 256 | "perl -I perl/gen-perl/ -I../lib/perl/lib/ perl/TestClient.pl" \ |
Roger Meier | 4d5157d | 2012-01-09 21:23:19 +0000 | [diff] [blame] | 257 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 258 | "10" "10" |
Roger Meier | b33967b | 2012-01-21 09:18:05 +0000 | [diff] [blame] | 259 | do_test "php-cpp" "binary" "buffered-ip" \ |
| 260 | "make -C php/ client" \ |
| 261 | "cpp/TestServer" \ |
Roger Meier | 8ebe0d9 | 2013-01-06 14:33:39 +0100 | [diff] [blame] | 262 | "10" "10" |
Roger Meier | c95d5df | 2014-01-19 21:53:02 +0100 | [diff] [blame] | 263 | do_test "rb-rb" "binary" "buffered-ip" \ |
| 264 | "ruby rb/integration/simple_client.rb" \ |
| 265 | "ruby rb/integration/simple_server.rb" \ |
| 266 | "1" "5" |
Roger Meier | 9aa08a9 | 2014-01-20 18:41:48 +0100 | [diff] [blame] | 267 | do_test "rb-rb" "binary-accl" "buffered-ip" \ |
Roger Meier | c95d5df | 2014-01-19 21:53:02 +0100 | [diff] [blame] | 268 | "ruby rb/integration/accelerated_buffered_client.rb" \ |
| 269 | "ruby rb/integration/accelerated_buffered_server.rb" \ |
| 270 | "1" "5" |
Roger Meier | 8252577 | 2012-11-16 00:38:27 +0000 | [diff] [blame] | 271 | cd - |