forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-ut.sh
executable file
·243 lines (208 loc) · 7.57 KB
/
run-ut.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -eo pipefail
ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`
export STARROCKS_HOME=${ROOT}
. ${STARROCKS_HOME}/env.sh
PARALLEL=$[$(nproc)/4+1]
# Check args
usage() {
echo "
Usage: $0 <options>
Optional options:
--clean clean and build ut
--run build and run ut
--gtest_filter specify test cases
--with-aws enable to test aws
--with-bench enable to build with benchmark
--use-staros enable to build with staros
-j build parallel
Eg.
$0 build ut
$0 --run build and run ut
$0 --run --gtest_filter scan* build and run ut of specified cases
$0 --clean clean and build ut
$0 --clean --run clean, build and run ut
$0 --help display usage
"
exit 1
}
OPTS=$(getopt \
-n $0 \
-o '' \
-l 'run' \
-l 'clean' \
-l "gtest_filter:" \
-l 'with-aws' \
-l 'with-bench' \
-l 'use-staros' \
-o 'j:' \
-l 'help' \
-- "$@")
if [ $? != 0 ] ; then
usage
fi
eval set -- "$OPTS"
CLEAN=0
RUN=0
TEST_FILTER=*
HELP=0
WITH_AWS=OFF
WITH_BENCH=OFF
USE_STAROS=OFF
while true; do
case "$1" in
--clean) CLEAN=1 ; shift ;;
--run) RUN=1 ; shift ;;
--gtest_filter) TEST_FILTER=$2 ; shift 2;;
--help) HELP=1 ; shift ;;
--with-aws) WITH_AWS=ON; shift ;;
--with-bench) WITH_BENCH=ON; shift ;;
--use-staros) USE_STAROS=ON; shift ;;
-j) PARALLEL=$2; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error" ; exit 1 ;;
esac
done
if [ ${HELP} -eq 1 ]; then
usage
exit 0
fi
CMAKE_BUILD_TYPE=${BUILD_TYPE:-ASAN}
CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE^^}"
if [[ -z ${USE_SSE4_2} ]]; then
USE_SSE4_2=ON
fi
if [[ -z ${USE_AVX2} ]]; then
USE_AVX2=ON
fi
echo "Build Backend UT"
CMAKE_BUILD_DIR=${STARROCKS_HOME}/be/ut_build_${CMAKE_BUILD_TYPE}
if [ ${CLEAN} -eq 1 ]; then
rm ${CMAKE_BUILD_DIR} -rf
rm ${STARROCKS_HOME}/be/output/ -rf
fi
if [ ! -d ${CMAKE_BUILD_DIR} ]; then
mkdir -p ${CMAKE_BUILD_DIR}
fi
cd ${CMAKE_BUILD_DIR}
if [ "${USE_STAROS}" == "ON" ]; then
if [ -z "$STARLET_INSTALL_DIR" ] ; then
# assume starlet_thirdparty is installed to ${STARROCKS_THIRDPARTY}/installed/starlet/
STARLET_INSTALL_DIR=${STARROCKS_THIRDPARTY}/installed/starlet
fi
${CMAKE_CMD} -G "${CMAKE_GENERATOR}" \
-DSTARROCKS_THIRDPARTY=${STARROCKS_THIRDPARTY}\
-DSTARROCKS_HOME=${STARROCKS_HOME} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DMAKE_TEST=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DUSE_AVX2=$USE_AVX2 -DUSE_SSE4_2=$USE_SSE4_2 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_BENCH=${WITH_BENCH} \
-DUSE_STAROS=${USE_STAROS} \
-Dprotobuf_DIR=${STARLET_INSTALL_DIR}/third_party/lib/cmake/protobuf \
-Dabsl_DIR=${STARLET_INSTALL_DIR}/third_party/lib/cmake/absl \
-DgRPC_DIR=${STARLET_INSTALL_DIR}/third_party/lib/cmake/grpc \
-Dstarlet_DIR=${STARLET_INSTALL_DIR}/starlet_install/lib64/cmake ..
else
${CMAKE_CMD} -G "${CMAKE_GENERATOR}" \
-DSTARROCKS_THIRDPARTY=${STARROCKS_THIRDPARTY}\
-DSTARROCKS_HOME=${STARROCKS_HOME} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DMAKE_TEST=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DUSE_AVX2=$USE_AVX2 -DUSE_SSE4_2=$USE_SSE4_2 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_BENCH=${WITH_BENCH} ../
fi
time ${BUILD_SYSTEM} -j${PARALLEL}
if [ ${RUN} -ne 1 ]; then
echo "Finished"
exit 0
fi
echo "******************************"
echo " Running StarRocks BE Unittest "
echo "******************************"
cd ${STARROCKS_HOME}
export STARROCKS_TEST_BINARY_DIR=${CMAKE_BUILD_DIR}
export TERM=xterm
export UDF_RUNTIME_DIR=${STARROCKS_HOME}/lib/udf-runtime
export LOG_DIR=${STARROCKS_HOME}/log
for i in `sed 's/ //g' $STARROCKS_HOME/conf/be.conf | egrep "^[[:upper:]]([[:upper:]]|_|[[:digit:]])*="`; do
eval "export $i";
done
mkdir -p $LOG_DIR
mkdir -p ${UDF_RUNTIME_DIR}
rm -f ${UDF_RUNTIME_DIR}/*
if [ ${RUN} -ne 1 ]; then
echo "Finished"
exit 0
fi
echo "******************************"
echo " Running StarRocks BE Unittest "
echo "******************************"
. ${STARROCKS_HOME}/bin/common.sh
# ====================== configure JAVA/JVM ====================
# NOTE: JAVA_HOME must be configed if using hdfs scan, like hive external table
# this is only for starting be
jvm_arch="amd64"
if [[ "${MACHINE_TYPE}" == "aarch64" ]]; then
jvm_arch="aarch64"
fi
if [ "$JAVA_HOME" = "" ]; then
export LD_LIBRARY_PATH=$STARROCKS_HOME/lib/jvm/$jvm_arch/server:$STARROCKS_HOME/lib/jvm/$jvm_arch:$LD_LIBRARY_PATH
else
java_version=$(jdk_version)
if [[ $java_version -gt 8 ]]; then
export LD_LIBRARY_PATH=$JAVA_HOME/lib/server:$JAVA_HOME/lib:$LD_LIBRARY_PATH
# JAVA_HOME is jdk
elif [[ -d "$JAVA_HOME/jre" ]]; then
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$jvm_arch/server:$JAVA_HOME/jre/lib/$jvm_arch:$LD_LIBRARY_PATH
# JAVA_HOME is jre
else
export LD_LIBRARY_PATH=$JAVA_HOME/lib/$jvm_arch/server:$JAVA_HOME/lib/$jvm_arch:$LD_LIBRARY_PATH
fi
fi
export LD_LIBRARY_PATH=$STARROCKS_HOME/lib/hadoop/native:$LD_LIBRARY_PATH
# HADOOP_CLASSPATH defined in $STARROCKS_HOME/conf/hadoop_env.sh
# put $STARROCKS_HOME/conf ahead of $HADOOP_CLASSPATH so that custom config can replace the config in $HADOOP_CLASSPATH
export CLASSPATH=$STARROCKS_HOME/conf:$HADOOP_CLASSPATH:$CLASSPATH
# ===========================================================
export STARROCKS_TEST_BINARY_DIR=${STARROCKS_TEST_BINARY_DIR}/test/
if [ $WITH_AWS = "OFF" ]; then
TEST_FILTER="$TEST_FILTER:-*S3*"
fi
# prepare util test_data
if [ -d ${STARROCKS_TEST_BINARY_DIR}/util/test_data ]; then
rm -rf ${STARROCKS_TEST_BINARY_DIR}/util/test_data
fi
cp -r ${STARROCKS_HOME}/be/test/util/test_data ${STARROCKS_TEST_BINARY_DIR}/util/
test_files=`find ${STARROCKS_TEST_BINARY_DIR} -type f -perm -111 -name "*test" | grep -v starrocks_test | grep -v bench_test`
# run cases in starrocks_test in parallel if has gtest-parallel script.
# reference: https://github.com/google/gtest-parallel
if [ -x ${GTEST_PARALLEL} ]; then
${GTEST_PARALLEL} ${STARROCKS_TEST_BINARY_DIR}/starrocks_test --gtest_filter=${TEST_FILTER} --serialize_test_cases ${GTEST_PARALLEL_OPTIONS}
else
${STARROCKS_TEST_BINARY_DIR}/starrocks_test --gtest_filter=${TEST_FILTER}
fi
for test in ${test_files[@]}
do
file_name=${test##*/}
if [ -z $RUN_FILE ] || [ $file_name == $RUN_FILE ]; then
echo "=== Run $file_name ==="
$test --gtest_filter=${TEST_FILTER}
fi
done