blob: 0d10758c50b492bd9423ebc6d13acca648826627 [file] [log] [blame]
Roger Meier8909cbd2014-01-26 11:44:27 +01001#! /bin/sh
2
Roger Meier8909cbd2014-01-26 11:44:27 +01003# 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.
Roger Meier8909cbd2014-01-26 11:44:27 +010019
Randy Abernethy8e731372015-02-03 00:04:40 -080020if [ -n "${1}" ]; then
21 COVER=${1};
22fi
23
Roger Meier8909cbd2014-01-26 11:44:27 +010024DIR="$( cd "$( dirname "$0" )" && pwd )"
25
Randy Abernethy8e731372015-02-03 00:04:40 -080026ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js"
27NODEUNIT="${DIR}/../../../node_modules/nodeunit/bin/nodeunit"
28
29REPORT_PREFIX="${DIR}/../coverage/report"
30
31COUNT=0
32
Roger Meier8909cbd2014-01-26 11:44:27 +010033export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
34
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080035testServer()
Roger Meier8909cbd2014-01-26 11:44:27 +010036{
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080037 echo " Testing $1 Client/Server with protocol $2 and transport $3 $4";
Roger Meier8909cbd2014-01-26 11:44:27 +010038 RET=0
Randy Abernethy8e731372015-02-03 00:04:40 -080039 if [ -n "${COVER}" ]; then
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080040 ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $1 -p $2 -t $3 $4 &
Randy Abernethy8e731372015-02-03 00:04:40 -080041 COUNT=$((COUNT+1))
42 else
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080043 node ${DIR}/server.js --type $1 -p $2 -t $3 $4 &
Randy Abernethy8e731372015-02-03 00:04:40 -080044 fi
Roger Meier8909cbd2014-01-26 11:44:27 +010045 SERVERPID=$!
46 sleep 1
Randy Abernethy8e731372015-02-03 00:04:40 -080047 if [ -n "${COVER}" ]; then
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080048 ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1
Randy Abernethy8e731372015-02-03 00:04:40 -080049 COUNT=$((COUNT+1))
50 else
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080051 node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1
Randy Abernethy8e731372015-02-03 00:04:40 -080052 fi
53 kill -2 $SERVERPID || RET=1
Roger Meier8909cbd2014-01-26 11:44:27 +010054 return $RET
55}
56
Roger Meier8909cbd2014-01-26 11:44:27 +010057TESTOK=0
58
59#generating thrift code
60
61${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
62
63#unit tests
64
Randy Abernethy8e731372015-02-03 00:04:40 -080065${NODEUNIT} ${DIR}/binary.test.js || TESTOK=1
Roger Meier8909cbd2014-01-26 11:44:27 +010066
67#integration tests
68
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080069for type in tcp multiplex http websocket
70do
Roger Meier8909cbd2014-01-26 11:44:27 +010071
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080072 for protocol in compact binary json
73 do
Roger Meier8909cbd2014-01-26 11:44:27 +010074
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080075 for transport in buffered framed
76 do
77 testServer $type $protocol $transport || TESTOK=1
78 testServer $type $protocol $transport --ssl || TESTOK=1
79 testServer $type $protocol $transport --promise || TESTOK=1
80 done
81 done
82done
Randy Abernethy2e091f62014-11-15 23:05:22 -080083
Randy Abernethy8e731372015-02-03 00:04:40 -080084if [ -n "${COVER}" ]; then
Randy Abernethy8e731372015-02-03 00:04:40 -080085 ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
86 rm -r ${DIR}/../coverage/report*/*
87 rmdir ${DIR}/../coverage/report*
88fi
89
Roger Meier8909cbd2014-01-26 11:44:27 +010090exit $TESTOK