Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # |
| 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 | |
| 22 | DIR="$( cd "$( dirname "$0" )" && pwd )" |
| 23 | |
| 24 | export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}" |
| 25 | |
| 26 | testClientServer() |
| 27 | { |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 28 | echo " Testing Client/Server with protocol $1 and transport $2 $3"; |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 29 | RET=0 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 30 | node ${DIR}/server.js -p $1 -t $2 $3 & |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 31 | SERVERPID=$! |
| 32 | sleep 1 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 33 | node ${DIR}/client.js -p $1 -t $2 $3 || RET=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 34 | kill -9 $SERVERPID || RET=1 |
| 35 | return $RET |
| 36 | } |
| 37 | |
| 38 | testMultiplexedClientServer() |
| 39 | { |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 40 | echo " Testing Multiplexed Client/Server with protocol $1 and transport $2 $3"; |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 41 | RET=0 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 42 | node ${DIR}/multiplex_server.js -p $1 -t $2 $3 & |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 43 | SERVERPID=$! |
| 44 | sleep 1 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 45 | node ${DIR}/multiplex_client.js -p $1 -t $2 $3 || RET=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 46 | kill -9 $SERVERPID || RET=1 #f |
| 47 | return $RET |
| 48 | } |
| 49 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 50 | testHttpClientServer() |
| 51 | { |
| 52 | echo " Testing HTTP Client/Server with protocol $1 and transport $2 $3"; |
| 53 | RET=0 |
| 54 | node ${DIR}/http_server.js -p $1 -t $2 $3 & |
| 55 | SERVERPID=$! |
| 56 | sleep 1 |
| 57 | node ${DIR}/http_client.js -p $1 -t $2 $3 || RET=1 |
| 58 | kill -9 $SERVERPID || RET=1 |
| 59 | return $RET |
| 60 | } |
| 61 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 62 | |
| 63 | TESTOK=0 |
| 64 | |
| 65 | #generating thrift code |
| 66 | |
| 67 | ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift |
| 68 | |
| 69 | #unit tests |
| 70 | |
| 71 | node ${DIR}/binary.test.js || TESTOK=1 |
| 72 | |
| 73 | #integration tests |
| 74 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 75 | #TCP connection tests |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 76 | testClientServer binary buffered || TESTOK=1 |
| 77 | testClientServer json buffered || TESTOK=1 |
| 78 | testClientServer binary framed || TESTOK=1 |
| 79 | testClientServer json framed || TESTOK=1 |
| 80 | |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 81 | #tests for multiplexed services |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 82 | testMultiplexedClientServer binary buffered || TESTOK=1 |
| 83 | testMultiplexedClientServer json buffered || TESTOK=1 |
| 84 | testMultiplexedClientServer binary framed || TESTOK=1 |
| 85 | testMultiplexedClientServer json framed || TESTOK=1 |
| 86 | |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 87 | #test ssl connection |
| 88 | testClientServer binary framed --ssl || TESTOK=1 |
| 89 | testMultiplexedClientServer binary framed --ssl || TESTOK=1 |
| 90 | |
henrique | 3123623 | 2014-02-23 20:16:44 +0100 | [diff] [blame] | 91 | #test promise style |
| 92 | testClientServer binary framed --promise || TESTOK=1 |
Roger Meier | 57b354b | 2014-02-22 01:01:58 +0100 | [diff] [blame] | 93 | |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 94 | #HTTP tests |
| 95 | testHttpClientServer json buffered || TESTOK=1 |
| 96 | testHttpClientServer json framed || TESTOK=1 |
| 97 | testHttpClientServer binary buffered || TESTOK=1 |
| 98 | testHttpClientServer binary framed || TESTOK=1 |
ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 99 | testHttpClientServer json buffered --promise || TESTOK=1 |
| 100 | testHttpClientServer binary framed --ssl || TESTOK=1 |
ra | 8f697cb | 2014-04-23 02:23:18 -0700 | [diff] [blame] | 101 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 102 | exit $TESTOK |