Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
jfarrell | dabdf65 | 2014-10-08 23:41:47 -0400 | [diff] [blame] | 3 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 4 | # Licensed to the Apache Software Foundation (ASF) under one |
| 5 | # or more contributor license agreements. See the NOTICE file |
| 6 | # distributed with this work for additional information |
| 7 | # regarding copyright ownership. The ASF licenses this file |
| 8 | # to you under the Apache License, Version 2.0 (the |
| 9 | # "License"); you may not use this file except in compliance |
| 10 | # with the License. You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, |
| 15 | # software distributed under the License is distributed on an |
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | # KIND, either express or implied. See the License for the |
| 18 | # specific language governing permissions and limitations |
| 19 | # under the License. |
| 20 | # |
| 21 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 22 | if [ -n "${1}" ]; then |
| 23 | COVER=${1}; |
| 24 | fi |
| 25 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 26 | DIR="$( cd "$( dirname "$0" )" && pwd )" |
| 27 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 28 | ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js" |
| 29 | NODEUNIT="${DIR}/../../../node_modules/nodeunit/bin/nodeunit" |
| 30 | |
| 31 | REPORT_PREFIX="${DIR}/../coverage/report" |
| 32 | |
| 33 | COUNT=0 |
| 34 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 35 | export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}" |
| 36 | |
| 37 | testClientServer() |
| 38 | { |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 39 | echo " Testing Client/Server with protocol $1 and transport $2 $3"; |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 40 | RET=0 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 41 | if [ -n "${COVER}" ]; then |
| 42 | ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 & |
| 43 | COUNT=$((COUNT+1)) |
| 44 | else |
| 45 | node ${DIR}/server.js -p $1 -t $2 $3 & |
| 46 | fi |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 47 | SERVERPID=$! |
| 48 | sleep 1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 49 | if [ -n "${COVER}" ]; then |
| 50 | ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1 |
| 51 | COUNT=$((COUNT+1)) |
| 52 | else |
| 53 | node ${DIR}/client.js -p $1 -t $2 $3 || RET=1 |
| 54 | fi |
| 55 | kill -2 $SERVERPID || RET=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 56 | return $RET |
| 57 | } |
| 58 | |
| 59 | testMultiplexedClientServer() |
| 60 | { |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 61 | echo " Testing Multiplexed Client/Server with protocol $1 and transport $2 $3"; |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 62 | RET=0 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 63 | if [ -n "${COVER}" ]; then |
| 64 | ${ISTANBUL} cover ${DIR}/multiplex_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 & |
| 65 | COUNT=$((COUNT+1)) |
| 66 | else |
| 67 | node ${DIR}/multiplex_server.js -p $1 -t $2 $3 & |
| 68 | fi |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 69 | SERVERPID=$! |
| 70 | sleep 1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 71 | if [ -n "${COVER}" ]; then |
| 72 | ${ISTANBUL} cover ${DIR}/multiplex_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1 |
| 73 | COUNT=$((COUNT+1)) |
| 74 | else |
| 75 | node ${DIR}/multiplex_client.js -p $1 -t $2 $3 || RET=1 |
| 76 | fi |
| 77 | kill -2 $SERVERPID || RET=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 78 | return $RET |
| 79 | } |
| 80 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 81 | testHttpClientServer() |
| 82 | { |
| 83 | echo " Testing HTTP Client/Server with protocol $1 and transport $2 $3"; |
| 84 | RET=0 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 85 | if [ -n "${COVER}" ]; then |
| 86 | ${ISTANBUL} cover ${DIR}/http_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 & |
| 87 | COUNT=$((COUNT+1)) |
| 88 | else |
| 89 | node ${DIR}/http_server.js -p $1 -t $2 $3 & |
| 90 | fi |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 91 | SERVERPID=$! |
| 92 | sleep 1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 93 | if [ -n "${COVER}" ]; then |
| 94 | ${ISTANBUL} cover ${DIR}/http_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1 |
| 95 | COUNT=$((COUNT+1)) |
| 96 | else |
| 97 | node ${DIR}/http_client.js -p $1 -t $2 $3 || RET=1 |
| 98 | fi |
| 99 | |
| 100 | kill -2 $SERVERPID || RET=1 |
| 101 | sleep 1 |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 102 | return $RET |
| 103 | } |
| 104 | |
Randy Abernethy | 2e091f6 | 2014-11-15 23:05:22 -0800 | [diff] [blame] | 105 | testWSClientServer() |
| 106 | { |
| 107 | echo " Testing WebSocket Client/Server with protocol $1 and transport $2 $3"; |
| 108 | RET=0 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 109 | if [ -n "${COVER}" ]; then |
| 110 | ${ISTANBUL} cover ${DIR}/http_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 & |
| 111 | COUNT=$((COUNT+1)) |
| 112 | else |
| 113 | node ${DIR}/http_server.js -p $1 -t $2 $3 & |
| 114 | fi |
Randy Abernethy | 2e091f6 | 2014-11-15 23:05:22 -0800 | [diff] [blame] | 115 | SERVERPID=$! |
| 116 | sleep 1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 117 | if [ -n "${COVER}" ]; then |
| 118 | ${ISTANBUL} cover ${DIR}/ws_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1 |
| 119 | COUNT=$((COUNT+1)) |
| 120 | else |
| 121 | node ${DIR}/ws_client.js -p $1 -t $2 $3 || RET=1 |
| 122 | fi |
| 123 | |
| 124 | kill -2 $SERVERPID || RET=1 |
Randy Abernethy | 2e091f6 | 2014-11-15 23:05:22 -0800 | [diff] [blame] | 125 | return $RET |
| 126 | } |
| 127 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 128 | TESTOK=0 |
| 129 | |
| 130 | #generating thrift code |
| 131 | |
| 132 | ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift |
| 133 | |
| 134 | #unit tests |
| 135 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 136 | ${NODEUNIT} ${DIR}/binary.test.js || TESTOK=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 137 | |
| 138 | #integration tests |
| 139 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 140 | #TCP connection tests |
ra | 20aeba3 | 2014-05-11 00:25:01 -0700 | [diff] [blame] | 141 | testClientServer compact buffered || TESTOK=1 |
| 142 | testClientServer compact framed || TESTOK=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 143 | testClientServer binary buffered || TESTOK=1 |
| 144 | testClientServer json buffered || TESTOK=1 |
| 145 | testClientServer binary framed || TESTOK=1 |
| 146 | testClientServer json framed || TESTOK=1 |
| 147 | |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 148 | #tests for multiplexed services |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 149 | testMultiplexedClientServer binary buffered || TESTOK=1 |
| 150 | testMultiplexedClientServer json buffered || TESTOK=1 |
| 151 | testMultiplexedClientServer binary framed || TESTOK=1 |
ra | 20aeba3 | 2014-05-11 00:25:01 -0700 | [diff] [blame] | 152 | testMultiplexedClientServer compact framed || TESTOK=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 153 | |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 154 | #test ssl connection |
| 155 | testClientServer binary framed --ssl || TESTOK=1 |
| 156 | testMultiplexedClientServer binary framed --ssl || TESTOK=1 |
| 157 | |
henrique | 3123623 | 2014-02-23 20:16:44 +0100 | [diff] [blame] | 158 | #test promise style |
| 159 | testClientServer binary framed --promise || TESTOK=1 |
ra | 20aeba3 | 2014-05-11 00:25:01 -0700 | [diff] [blame] | 160 | testClientServer compact buffered --promise || TESTOK=1 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 161 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 162 | #HTTP tests |
ra | 20aeba3 | 2014-05-11 00:25:01 -0700 | [diff] [blame] | 163 | testHttpClientServer compact buffered || TESTOK=1 |
| 164 | testHttpClientServer compact framed || TESTOK=1 |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 165 | testHttpClientServer json buffered || TESTOK=1 |
| 166 | testHttpClientServer json framed || TESTOK=1 |
| 167 | testHttpClientServer binary buffered || TESTOK=1 |
| 168 | testHttpClientServer binary framed || TESTOK=1 |
ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 169 | testHttpClientServer json buffered --promise || TESTOK=1 |
| 170 | testHttpClientServer binary framed --ssl || TESTOK=1 |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 171 | |
Randy Abernethy | 2e091f6 | 2014-11-15 23:05:22 -0800 | [diff] [blame] | 172 | #WebSocket tests |
| 173 | testWSClientServer compact buffered || TESTOK=1 |
| 174 | testWSClientServer compact framed || TESTOK=1 |
| 175 | testWSClientServer json buffered || TESTOK=1 |
| 176 | testWSClientServer json framed || TESTOK=1 |
| 177 | testWSClientServer binary buffered || TESTOK=1 |
| 178 | testWSClientServer binary framed || TESTOK=1 |
| 179 | testWSClientServer json buffered --promise || TESTOK=1 |
| 180 | testWSClientServer binary framed --ssl || TESTOK=1 |
| 181 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 182 | if [ -n "${COVER}" ]; then |
| 183 | echo "${DIR}/../coverage/report*/coverage.json" |
| 184 | ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html |
| 185 | rm -r ${DIR}/../coverage/report*/* |
| 186 | rmdir ${DIR}/../coverage/report* |
| 187 | fi |
| 188 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 189 | exit $TESTOK |