blob: 4008eece9d6980fa4b9385d8ea85baae4544264c [file] [log] [blame]
Roger Meier8909cbd2014-01-26 11:44:27 +01001#! /bin/sh
2
jfarrelldabdf652014-10-08 23:41:47 -04003
Roger Meier8909cbd2014-01-26 11:44:27 +01004# 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
22DIR="$( cd "$( dirname "$0" )" && pwd )"
23
24export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
25
26testClientServer()
27{
Roger Meier57b354b2014-02-22 01:01:58 +010028 echo " Testing Client/Server with protocol $1 and transport $2 $3";
Roger Meier8909cbd2014-01-26 11:44:27 +010029 RET=0
Roger Meier57b354b2014-02-22 01:01:58 +010030 node ${DIR}/server.js -p $1 -t $2 $3 &
Roger Meier8909cbd2014-01-26 11:44:27 +010031 SERVERPID=$!
32 sleep 1
Roger Meier57b354b2014-02-22 01:01:58 +010033 node ${DIR}/client.js -p $1 -t $2 $3 || RET=1
Roger Meier8909cbd2014-01-26 11:44:27 +010034 kill -9 $SERVERPID || RET=1
35 return $RET
36}
37
38testMultiplexedClientServer()
39{
Roger Meier57b354b2014-02-22 01:01:58 +010040 echo " Testing Multiplexed Client/Server with protocol $1 and transport $2 $3";
Roger Meier8909cbd2014-01-26 11:44:27 +010041 RET=0
Roger Meier57b354b2014-02-22 01:01:58 +010042 node ${DIR}/multiplex_server.js -p $1 -t $2 $3 &
Roger Meier8909cbd2014-01-26 11:44:27 +010043 SERVERPID=$!
44 sleep 1
Roger Meier57b354b2014-02-22 01:01:58 +010045 node ${DIR}/multiplex_client.js -p $1 -t $2 $3 || RET=1
jfarrelldabdf652014-10-08 23:41:47 -040046 kill -9 $SERVERPID || RET=1
Roger Meier8909cbd2014-01-26 11:44:27 +010047 return $RET
48}
49
ra8f697cb2014-04-23 02:23:18 -070050testHttpClientServer()
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
Randy Abernethy2e091f62014-11-15 23:05:22 -080062testWSClientServer()
63{
64 echo " Testing WebSocket Client/Server with protocol $1 and transport $2 $3";
65 RET=0
66 node ${DIR}/http_server.js -p $1 -t $2 $3 &
67 SERVERPID=$!
68 sleep 1
69 node ${DIR}/ws_client.js -p $1 -t $2 $3 || RET=1
70 kill -9 $SERVERPID || RET=1
71 return $RET
72}
73
Roger Meier8909cbd2014-01-26 11:44:27 +010074
75TESTOK=0
76
77#generating thrift code
78
79${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
80
81#unit tests
82
83node ${DIR}/binary.test.js || TESTOK=1
84
85#integration tests
86
ra8f697cb2014-04-23 02:23:18 -070087#TCP connection tests
ra20aeba32014-05-11 00:25:01 -070088testClientServer compact buffered || TESTOK=1
89testClientServer compact framed || TESTOK=1
Roger Meier8909cbd2014-01-26 11:44:27 +010090testClientServer binary buffered || TESTOK=1
91testClientServer json buffered || TESTOK=1
92testClientServer binary framed || TESTOK=1
93testClientServer json framed || TESTOK=1
94
Roger Meier57b354b2014-02-22 01:01:58 +010095#tests for multiplexed services
Roger Meier8909cbd2014-01-26 11:44:27 +010096testMultiplexedClientServer binary buffered || TESTOK=1
97testMultiplexedClientServer json buffered || TESTOK=1
98testMultiplexedClientServer binary framed || TESTOK=1
ra20aeba32014-05-11 00:25:01 -070099testMultiplexedClientServer compact framed || TESTOK=1
Roger Meier8909cbd2014-01-26 11:44:27 +0100100
Roger Meier57b354b2014-02-22 01:01:58 +0100101#test ssl connection
102testClientServer binary framed --ssl || TESTOK=1
103testMultiplexedClientServer binary framed --ssl || TESTOK=1
104
henrique31236232014-02-23 20:16:44 +0100105#test promise style
106testClientServer binary framed --promise || TESTOK=1
ra20aeba32014-05-11 00:25:01 -0700107testClientServer compact buffered --promise || TESTOK=1
Roger Meier57b354b2014-02-22 01:01:58 +0100108
ra8f697cb2014-04-23 02:23:18 -0700109#HTTP tests
ra20aeba32014-05-11 00:25:01 -0700110testHttpClientServer compact buffered || TESTOK=1
111testHttpClientServer compact framed || TESTOK=1
ra8f697cb2014-04-23 02:23:18 -0700112testHttpClientServer json buffered || TESTOK=1
113testHttpClientServer json framed || TESTOK=1
114testHttpClientServer binary buffered || TESTOK=1
115testHttpClientServer binary framed || TESTOK=1
ra779b9ac2014-04-23 20:04:23 -0700116testHttpClientServer json buffered --promise || TESTOK=1
117testHttpClientServer binary framed --ssl || TESTOK=1
ra8f697cb2014-04-23 02:23:18 -0700118
Randy Abernethy2e091f62014-11-15 23:05:22 -0800119#WebSocket tests
120testWSClientServer compact buffered || TESTOK=1
121testWSClientServer compact framed || TESTOK=1
122testWSClientServer json buffered || TESTOK=1
123testWSClientServer json framed || TESTOK=1
124testWSClientServer binary buffered || TESTOK=1
125testWSClientServer binary framed || TESTOK=1
126testWSClientServer json buffered --promise || TESTOK=1
127testWSClientServer binary framed --ssl || TESTOK=1
128
Roger Meier8909cbd2014-01-26 11:44:27 +0100129exit $TESTOK