]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/nodejs/test/testAll.sh
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / nodejs / test / testAll.sh
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 if [ -n "${1}" ]; then
21 COVER=${1};
22 fi
23
24 DIR="$( cd "$( dirname "$0" )" && pwd )"
25
26 EPISODIC_DIR=${DIR}/episodic-code-generation-test
27
28 THRIFT_FILES_DIR=${DIR}/../../../test
29
30 THRIFT_COMPILER=${DIR}/../../../compiler/cpp/thrift
31
32 ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js"
33
34 REPORT_PREFIX="${DIR}/../coverage/report"
35
36 COUNT=0
37
38 export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
39
40 testServer()
41 {
42 echo " [ECMA $1] Testing $2 Client/Server with protocol $3 and transport $4 $5";
43 RET=0
44 if [ -n "${COVER}" ]; then
45 ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $2 -p $3 -t $4 $5 &
46 COUNT=$((COUNT+1))
47 else
48 node ${DIR}/server.js --${1} --type $2 -p $3 -t $4 $5 &
49 fi
50 SERVERPID=$!
51 sleep 0.1
52 if [ -n "${COVER}" ]; then
53 ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --${1} --type $2 -p $3 -t $4 $5 || RET=1
54 COUNT=$((COUNT+1))
55 else
56 node ${DIR}/client.js --${1} --type $2 -p $3 -t $4 $5 || RET=1
57 fi
58 kill -2 $SERVERPID || RET=1
59 wait $SERVERPID
60 return $RET
61 }
62
63 testEpisodicCompilation()
64 {
65 RET=0
66 if [ -n "${COVER}" ]; then
67 ${ISTANBUL} cover ${EPISODIC_DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint &
68 COUNT=$((COUNT+1))
69 else
70 node ${EPISODIC_DIR}/server.js &
71 fi
72 SERVERPID=$!
73 sleep 0.1
74 if [ -n "${COVER}" ]; then
75 ${ISTANBUL} cover ${EPISODIC_DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} || RET=1
76 COUNT=$((COUNT+1))
77 else
78 node ${EPISODIC_DIR}/client.js || RET=1
79 fi
80 kill -2 $SERVERPID || RET=1
81 wait $SERVERPID
82 return $RET
83 }
84
85
86 TESTOK=0
87
88 # generating Thrift code
89
90 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/ThriftTest.thrift
91 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
92 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/Int64Test.thrift
93 mkdir ${DIR}/gen-nodejs-es6
94 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/ThriftTest.thrift
95 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
96 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/Int64Test.thrift
97
98 # generate episodic compilation test code
99 TYPES_PACKAGE=${EPISODIC_DIR}/node_modules/types-package
100
101 # generate the first episode
102 mkdir --parents ${EPISODIC_DIR}/gen-1/first-episode
103 ${THRIFT_COMPILER} -o ${EPISODIC_DIR}/gen-1/first-episode --gen js:node,thrift_package_output_directory=first-episode ${THRIFT_FILES_DIR}/Types.thrift
104
105 # create a "package" from the first episode and "install" it, the episode file must be at the module root
106 mkdir --parents ${TYPES_PACKAGE}/first-episode
107 cp --force ${EPISODIC_DIR}/episodic_compilation.package.json ${TYPES_PACKAGE}/package.json
108 cp --force ${EPISODIC_DIR}/gen-1/first-episode/gen-nodejs/Types_types.js ${TYPES_PACKAGE}/first-episode/
109 cp --force ${EPISODIC_DIR}/gen-1/first-episode/gen-nodejs/thrift.js.episode ${TYPES_PACKAGE}
110
111 # generate the second episode
112 mkdir --parents ${EPISODIC_DIR}/gen-2/second-episode
113 ${THRIFT_COMPILER} -o ${EPISODIC_DIR}/gen-2/second-episode --gen js:node,imports=${TYPES_PACKAGE} ${THRIFT_FILES_DIR}/Service.thrift
114 if [ -f ${EPISODIC_DIR}/gen-2/second-episode/Types_types.js ]; then
115 TESTOK=1
116 fi
117
118 # unit tests
119
120 node ${DIR}/binary.test.js || TESTOK=1
121 node ${DIR}/int64.test.js || TESTOK=1
122 node ${DIR}/deep-constructor.test.js || TESTOK=1
123
124 # integration tests
125
126 for type in tcp multiplex websocket http
127 do
128 for protocol in compact binary json
129 do
130 for transport in buffered framed
131 do
132 for ecma_version in es5 es6
133 do
134 testServer $ecma_version $type $protocol $transport || TESTOK=1
135 testServer $ecma_version $type $protocol $transport --ssl || TESTOK=1
136 testServer $ecma_version $type $protocol $transport --callback || TESTOK=1
137 done
138 done
139 done
140 done
141
142 # episodic compilation test
143 testEpisodicCompilation
144
145 if [ -n "${COVER}" ]; then
146 ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
147 rm -r ${DIR}/../coverage/report*/*
148 rmdir ${DIR}/../coverage/report*
149 fi
150
151 exit $TESTOK