Skip to content

Commit 5afa29b

Browse files
author
zhaochun
committed
Added: change Doris build.sh to get environment variables from
custom_env.sh, and add run-ut.sh and run-fe-ut.sh
1 parent ae9ce81 commit 5afa29b

File tree

10 files changed

+383
-67
lines changed

10 files changed

+383
-67
lines changed

be/src/util/metrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::ostream& operator<<(std::ostream& os, MetricType type) {
2525
os << "counter";
2626
break;
2727
case MetricType::GAUGE:
28-
os << "guage";
28+
os << "gauge";
2929
break;
3030
case MetricType::HISTOGRAM:
3131
os << "histogram";

be/src/util/system_metrics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void SystemMetrics::_install_disk_metrics(MetricRegistry* registry,
203203

204204
void SystemMetrics::_update_disk_metrics() {
205205
#ifdef BE_TEST
206-
FILE* fp = fopen(k_ut_fd_path, "r");
206+
FILE* fp = fopen(k_ut_diskstats_path, "r");
207207
#else
208208
FILE* fp = fopen("/proc/diskstats", "r");
209209
#endif
@@ -398,7 +398,7 @@ void SystemMetrics::_install_fd_metrics(MetricRegistry* registry) {
398398

399399
void SystemMetrics::_update_fd_metrics() {
400400
#ifdef BE_TEST
401-
FILE* fp = fopen(k_ut_diskstats_path, "r");
401+
FILE* fp = fopen(k_ut_fd_path, "r");
402402
#else
403403
FILE* fp = fopen("/proc/sys/fs/file-nr", "r");
404404
#endif

be/test/http/metrics_action_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ TEST_F(MetricsActionTest, prometheus_output) {
5050
MetricLabels().add("type", "put").add("path", "/sports"),
5151
&put_requests_total);
5252
s_expect_response =
53-
"# TYPE test_cpu_idle GAUGE\n"
53+
"# TYPE test_cpu_idle gauge\n"
5454
"test_cpu_idle 50\n"
55-
"# TYPE test_requests_total COUNTER\n"
55+
"# TYPE test_requests_total counter\n"
5656
"test_requests_total{path=\"/sports\",type=\"put\"} 2345\n";
5757
HttpRequest request(nullptr);
5858
MetricsAction action(&registry);
@@ -65,7 +65,7 @@ TEST_F(MetricsActionTest, prometheus_no_prefix) {
6565
cpu_idle.set_value(50);
6666
registry.register_metric("cpu_idle", &cpu_idle);
6767
s_expect_response =
68-
"# TYPE cpu_idle GAUGE\n"
68+
"# TYPE cpu_idle gauge\n"
6969
"cpu_idle 50\n";
7070
HttpRequest request(nullptr);
7171
MetricsAction action(&registry);

be/test/olap/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ ADD_BE_TEST(in_list_predicate_test)
1919
ADD_BE_TEST(null_predicate_test)
2020
ADD_BE_TEST(file_helper_test)
2121
ADD_BE_TEST(file_utils_test)
22-
ADD_BE_TEST(delete_handler_test)
23-
ADD_BE_TEST(column_reader_test)
24-
ADD_BE_TEST(row_cursor_test)
22+
# ADD_BE_TEST(delete_handler_test)
23+
# ADD_BE_TEST(column_reader_test)
24+
# ADD_BE_TEST(row_cursor_test)
2525

2626
## deleted
2727
# ADD_BE_TEST(olap_reader_test)

be/test/util/system_metrics_test.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@ TEST_F(SystemMetricsTest, no_proc_file) {
284284
}
285285

286286
int main(int argc, char** argv) {
287-
std::string conffile = std::string(getenv("DORIS_HOME")) + "/conf/be.conf";
288-
if (!palo::config::init(conffile.c_str(), false)) {
289-
fprintf(stderr, "error read config file. \n");
290-
return -1;
291-
}
292-
palo::init_glog("be-test");
293287
::testing::InitGoogleTest(&argc, argv);
294288
return RUN_ALL_TESTS();
295289
}

build.sh

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,12 @@ set -eo pipefail
2828

2929
ROOT=`dirname "$0"`
3030
ROOT=`cd "$ROOT"; pwd`
31-
export DORIS_HOME=$ROOT
3231

33-
PARALLEL=8
32+
export DORIS_HOME=${ROOT}
3433

35-
# Check java version
36-
if [ -z ${JAVA_HOME} ]; then
37-
echo "Error: JAVA_HOME is not set, use thirdparty/installed/jdk1.8.0_131"
38-
export JAVA_HOME=${DORIS_HOME}/thirdparty/installed/jdk1.8.0_131
39-
fi
34+
. ${DORIS_HOME}/env.sh
4035

41-
JAVA=${JAVA_HOME}/bin/java
42-
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
43-
if [ $JAVA_VER -lt 18 ]; then
44-
echo "Require JAVA with JDK version at least 1.8"
45-
exit 1
46-
fi
47-
48-
MVN=mvn
49-
# Check maven
50-
if ! ${MVN} --version; then
51-
echo "mvn is not found"
52-
exit 1
53-
fi
54-
55-
# check python
56-
export PYTHON=python
57-
if ! ${PYTHON} --version; then
58-
export PYTHON=python2.7
59-
if ! ${PYTHON} --version; then
60-
echo "python is not found"
61-
exit
62-
fi
63-
fi
64-
65-
if [ -z ${DORIS_THIRDPARTY} ]; then
66-
export DORIS_THIRDPARTY=${DORIS_HOME}/thirdparty
67-
fi
36+
PARALLEL=8
6837

6938
# Check args
7039
usage() {

env.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved
3+
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
# check DORIS_HOME
18+
if [[ -z ${DORIS_HOME} ]]; then
19+
echo "Error: DORIS_HOME is not set"
20+
exit 1
21+
fi
22+
23+
# include custom environment variables
24+
if [[ -f ${DORIS_HOME}/custom_env.sh ]]; then
25+
source ${DORIS_HOME}/custom_env.sh
26+
fi
27+
28+
# check java version
29+
if [ -z ${JAVA_HOME} ]; then
30+
echo "Error: JAVA_HOME is not set, use thirdparty/installed/jdk1.8.0_131"
31+
export JAVA_HOME=${DORIS_HOME}/thirdparty/installed/jdk1.8.0_131
32+
fi
33+
34+
export JAVA=${JAVA_HOME}/bin/java
35+
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
36+
if [ $JAVA_VER -lt 18 ]; then
37+
echo "Error: require JAVA with JDK version at least 1.8"
38+
exit 1
39+
fi
40+
41+
# check maven
42+
export MVN=mvn
43+
if ! ${MVN} --version; then
44+
echo "Error: mvn is not found"
45+
exit 1
46+
fi
47+
48+
# check python
49+
export PYTHON=python
50+
if ! ${PYTHON} --version; then
51+
export PYTHON=python2.7
52+
if ! ${PYTHON} --version; then
53+
echo "Error: python is not found"
54+
exit
55+
fi
56+
fi
57+
58+
# set DORIS_THIRDPARTY
59+
if [ -z ${DORIS_THIRDPARTY} ]; then
60+
export DORIS_THIRDPARTY=${DORIS_HOME}/thirdparty
61+
fi
62+

fs_brokers/apache_hdfs_broker/build.sh

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,15 @@
1616
# under the License.
1717

1818
set -e
19+
1920
ROOT=`dirname "$0"`
2021
ROOT=`cd "$ROOT"; pwd`
2122

22-
# check java version
23-
if [ -z $JAVA_HOME ]; then
24-
echo "Error: JAVA_HOME is not set, use thirdparty/installed/jdk1.8.0_131"
25-
export JAVA_HOME=${ROOT}/../../thirdparty/installed/jdk1.8.0_131
26-
fi
27-
JAVA=${JAVA_HOME}/bin/java
28-
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
29-
if [ $JAVA_VER -lt 18 ]; then
30-
echo "Error: java version is too old" $JAVA_VER" need jdk 1.8."
31-
exit 1
32-
fi
23+
export DORIS_HOME=${ROOT}/../..
3324

34-
export BROKER_HOME=$ROOT
25+
. ${DORIS_HOME}/env.sh
3526

36-
MVN=mvn
37-
# Check ant
38-
if ! ${MVN} --version; then
39-
echo "mvn is not found"
40-
exit 1
41-
fi
27+
export BROKER_HOME=$ROOT
4228

4329
# prepare thrift
4430
mkdir -p ${BROKER_HOME}/src/main/resources/thrift

run-fe-ut.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2018, Baidu.com, Inc. All Rights Reserved
3+
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
set -eo pipefail
18+
19+
ROOT=`dirname "$0"`
20+
ROOT=`cd "$ROOT"; pwd`
21+
22+
export DORIS_HOME=${ROOT}
23+
24+
. ${DORIS_HOME}/env.sh
25+
26+
# Check args
27+
usage() {
28+
echo "
29+
Usage: $0 <options>
30+
Optional options:
31+
--clean clean and build ut
32+
--run build and run ut
33+
34+
Eg.
35+
$0 build and run ut
36+
$0 --coverage build and run coverage statistic
37+
"
38+
exit 1
39+
}
40+
41+
OPTS=$(getopt \
42+
-n $0 \
43+
-o '' \
44+
-l 'coverage' \
45+
-- "$@")
46+
47+
if [ $? != 0 ] ; then
48+
usage
49+
fi
50+
51+
eval set -- "$OPTS"
52+
53+
COVERAGE=
54+
if [ $# == 1 ] ; then
55+
#default
56+
COVERAGE=0
57+
else
58+
COVERAGE=0
59+
while true; do
60+
case "$1" in
61+
--coverage) COVERAGE=1 ; shift ;;
62+
--) shift ; break ;;
63+
*) ehco "Internal error" ; exit 1 ;;
64+
esac
65+
done
66+
fi
67+
68+
echo "Build Frontend UT"
69+
70+
rm ${DORIS_HOME}/fe/build/ -rf
71+
rm ${DORIS_HOME}/fe/output/ -rf
72+
73+
echo "******************************"
74+
echo " Runing PaloBe Unittest "
75+
echo "******************************"
76+
77+
cd ${DORIS_HOME}/fe/
78+
mkdir -p build/compile
79+
80+
if [ ${COVERAGE} -eq 1 ]; then
81+
echo "Run coverage statistic"
82+
ant cover-test
83+
else
84+
echo "Run Frontend UT"
85+
$MVN test
86+
fi

0 commit comments

Comments
 (0)