forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-cloud-ut.sh
executable file
·202 lines (176 loc) · 6.18 KB
/
run-cloud-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
#!/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.
#####################################################################
# This script is used to run unit test of Doris Backend
# Usage: $0 <options>
# Optional options:
# --clean clean and build ut
# --run build and run all ut
# --run --filter=xx build and run specified ut
# -j build parallel
# -h print this help message
#
# All BE tests must use "_test" as the file suffix, and add the file
# to cloud/test/CMakeLists.txt.
#
# GTest result xml files will be in "cloud/ut_build_ASAN/gtest_output/"
#####################################################################
ROOT=$(dirname "$0")
ROOT=$(
cd "${ROOT}"
pwd
)
export DORIS_HOME="${ROOT}"
# Check args
usage() {
echo "
Usage: $0 <options>
Optional options:
--clean clean and build ut
--run build and run all ut
--coverage coverage after run ut
--run --filter=xx build and run specified ut
-j build parallel
-h print this help message
Eg.
$0 build tests
$0 --run build and run all tests
$0 --run --filter=* also runs everything
$0 --run --filter=FooTest.* runs everything in test suite FooTest
$0 --run --filter=*Null*:*Constructor* runs any test whose full name contains either 'Null' or 'Constructor'
$0 --run --filter=-*DeathTest.* runs all non-death tests
$0 --run --filter=FooTest.*-FooTest.Bar runs everything in test suite FooTest except FooTest.Bar
$0 --run --filter=FooTest.*:BarTest.*-FooTest.Bar:BarTest.Foo runs everything in test suite FooTest except FooTest.Bar and everything in test suite BarTest except BarTest.Foo
$0 --clean clean and build tests
$0 --clean --run clean, build and run all tests
"
exit 1
}
if ! OPTS=$(getopt -n "$0" -o vhj:f: -l run,clean,filter:,fdb:,coverage -- "$@"); then
usage
fi
set -eo pipefail
eval set -- "${OPTS}"
PARALLEL=$(($(nproc) / 5 + 1))
CLEAN=0
RUN=0
FILTER=""
FDB=""
ENABLE_CLANG_COVERAGE=OFF
echo "===================== filter: ${FILTER}"
if [[ $# != 1 ]]; then
while true; do
case "$1" in
--clean)
CLEAN=1
shift
;;
--run)
RUN=1
shift
;;
--coverage)
ENABLE_CLANG_COVERAGE="ON"
shift
;;
--fdb)
FDB="$2"
shift 2
;;
-f | --filter)
FILTER="$2"
shift 2
;;
-j)
PARALLEL=$2
shift 2
;;
--)
shift
break
;;
*)
usage
;;
esac
done
fi
echo "===================== filter: ${FILTER}"
CMAKE_BUILD_TYPE=${BUILD_TYPE:-ASAN}
CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE^^}"
echo "Get params:
PARALLEL -- ${PARALLEL}
CLEAN -- ${CLEAN}
"
echo "Build SelectDB Cloud UT"
if [[ "_${ENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
sed -i "s/DORIS_TOOLCHAIN=gcc/DORIS_TOOLCHAIN=clang/g" env.sh
echo "export DORIS_TOOLCHAIN=clang" >>custom_env.sh
fi
. "${DORIS_HOME}/env.sh"
CMAKE_BUILD_DIR="${DORIS_HOME}/cloud/ut_build_${CMAKE_BUILD_TYPE}"
if [[ "${CLEAN}" -eq 1 ]]; then
rm "${CMAKE_BUILD_DIR}" -rf
rm "${DORIS_HOME}/cloud/output/" -rf
fi
if [[ ! -d "${CMAKE_BUILD_DIR}" ]]; then
mkdir -p "${CMAKE_BUILD_DIR}"
fi
if [[ -z "${GLIBC_COMPATIBILITY}" ]]; then
GLIBC_COMPATIBILITY=ON
fi
if [[ -z "${USE_DWARF}" ]]; then
USE_DWARF=OFF
fi
MAKE_PROGRAM="$(command -v "${BUILD_SYSTEM}")"
echo "-- Make program: ${MAKE_PROGRAM}"
cd "${CMAKE_BUILD_DIR}"
find . -name "*.gcda" -exec rm {} \;
"${CMAKE_CMD}" -G "${GENERATOR}" \
-DCMAKE_MAKE_PROGRAM="${MAKE_PROGRAM}" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DMAKE_TEST=ON \
-DGLIBC_COMPATIBILITY="${GLIBC_COMPATIBILITY}" \
-DUSE_DWARF="${USE_DWARF}" \
-DUSE_MEM_TRACKER=ON \
-DUSE_JEMALLOC=OFF \
-DSTRICT_MEMORY_USE=OFF \
-DENABLE_CLANG_COVERAGE="${ENABLE_CLANG_COVERAGE}" \
"${CMAKE_USE_CCACHE}" \
"${DORIS_HOME}/cloud/"
"${BUILD_SYSTEM}" -j "${PARALLEL}"
"${BUILD_SYSTEM}" install
mkdir -p "${CMAKE_BUILD_DIR}/test/log"
if [[ "${RUN}" -ne 1 ]]; then
echo "Finished"
exit 0
fi
echo "**********************************"
echo " Running MetaService Unit Test "
echo "**********************************"
# test binary output dir
cd test
# FILTER: binary_name:gtest_filter
# FILTER: meta_service_test:DetachSchemaKVTest.*
# ./run_all_tests.sh --test "\"$(echo "${FILTER}" | awk -F: '{print $1}')\"" --filter "\"$(echo "${FILTER}" | awk -F: '{print $2}')\"" --fdb "\"${FDB}\""
if [[ "_${ENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
bash -x ./run_all_tests.sh --coverage --test "$(echo "${FILTER}" | awk -F: '{print $1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb "${FDB}"
else
bash ./run_all_tests.sh --test "$(echo "${FILTER}" | awk -F: '{print $1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb "${FDB}"
fi