Skip to content

Commit

Permalink
Added: change Doris build.sh to get environment variables from
Browse files Browse the repository at this point in the history
custom_env.sh, and add run-ut.sh and run-fe-ut.sh
  • Loading branch information
zhaochun committed Oct 30, 2018
1 parent ae9ce81 commit 5afa29b
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 67 deletions.
2 changes: 1 addition & 1 deletion be/src/util/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::ostream& operator<<(std::ostream& os, MetricType type) {
os << "counter";
break;
case MetricType::GAUGE:
os << "guage";
os << "gauge";
break;
case MetricType::HISTOGRAM:
os << "histogram";
Expand Down
4 changes: 2 additions & 2 deletions be/src/util/system_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void SystemMetrics::_install_disk_metrics(MetricRegistry* registry,

void SystemMetrics::_update_disk_metrics() {
#ifdef BE_TEST
FILE* fp = fopen(k_ut_fd_path, "r");
FILE* fp = fopen(k_ut_diskstats_path, "r");
#else
FILE* fp = fopen("/proc/diskstats", "r");
#endif
Expand Down Expand Up @@ -398,7 +398,7 @@ void SystemMetrics::_install_fd_metrics(MetricRegistry* registry) {

void SystemMetrics::_update_fd_metrics() {
#ifdef BE_TEST
FILE* fp = fopen(k_ut_diskstats_path, "r");
FILE* fp = fopen(k_ut_fd_path, "r");
#else
FILE* fp = fopen("/proc/sys/fs/file-nr", "r");
#endif
Expand Down
6 changes: 3 additions & 3 deletions be/test/http/metrics_action_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ TEST_F(MetricsActionTest, prometheus_output) {
MetricLabels().add("type", "put").add("path", "/sports"),
&put_requests_total);
s_expect_response =
"# TYPE test_cpu_idle GAUGE\n"
"# TYPE test_cpu_idle gauge\n"
"test_cpu_idle 50\n"
"# TYPE test_requests_total COUNTER\n"
"# TYPE test_requests_total counter\n"
"test_requests_total{path=\"/sports\",type=\"put\"} 2345\n";
HttpRequest request(nullptr);
MetricsAction action(&registry);
Expand All @@ -65,7 +65,7 @@ TEST_F(MetricsActionTest, prometheus_no_prefix) {
cpu_idle.set_value(50);
registry.register_metric("cpu_idle", &cpu_idle);
s_expect_response =
"# TYPE cpu_idle GAUGE\n"
"# TYPE cpu_idle gauge\n"
"cpu_idle 50\n";
HttpRequest request(nullptr);
MetricsAction action(&registry);
Expand Down
6 changes: 3 additions & 3 deletions be/test/olap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ADD_BE_TEST(in_list_predicate_test)
ADD_BE_TEST(null_predicate_test)
ADD_BE_TEST(file_helper_test)
ADD_BE_TEST(file_utils_test)
ADD_BE_TEST(delete_handler_test)
ADD_BE_TEST(column_reader_test)
ADD_BE_TEST(row_cursor_test)
# ADD_BE_TEST(delete_handler_test)
# ADD_BE_TEST(column_reader_test)
# ADD_BE_TEST(row_cursor_test)

## deleted
# ADD_BE_TEST(olap_reader_test)
Expand Down
6 changes: 0 additions & 6 deletions be/test/util/system_metrics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ TEST_F(SystemMetricsTest, no_proc_file) {
}

int main(int argc, char** argv) {
std::string conffile = std::string(getenv("DORIS_HOME")) + "/conf/be.conf";
if (!palo::config::init(conffile.c_str(), false)) {
fprintf(stderr, "error read config file. \n");
return -1;
}
palo::init_glog("be-test");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
37 changes: 3 additions & 34 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,12 @@ set -eo pipefail

ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`
export DORIS_HOME=$ROOT

PARALLEL=8
export DORIS_HOME=${ROOT}

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

JAVA=${JAVA_HOME}/bin/java
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
if [ $JAVA_VER -lt 18 ]; then
echo "Require JAVA with JDK version at least 1.8"
exit 1
fi

MVN=mvn
# Check maven
if ! ${MVN} --version; then
echo "mvn is not found"
exit 1
fi

# check python
export PYTHON=python
if ! ${PYTHON} --version; then
export PYTHON=python2.7
if ! ${PYTHON} --version; then
echo "python is not found"
exit
fi
fi

if [ -z ${DORIS_THIRDPARTY} ]; then
export DORIS_THIRDPARTY=${DORIS_HOME}/thirdparty
fi
PARALLEL=8

# Check args
usage() {
Expand Down
62 changes: 62 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved

# Licensed 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.

# check DORIS_HOME
if [[ -z ${DORIS_HOME} ]]; then
echo "Error: DORIS_HOME is not set"
exit 1
fi

# include custom environment variables
if [[ -f ${DORIS_HOME}/custom_env.sh ]]; then
source ${DORIS_HOME}/custom_env.sh
fi

# check java version
if [ -z ${JAVA_HOME} ]; then
echo "Error: JAVA_HOME is not set, use thirdparty/installed/jdk1.8.0_131"
export JAVA_HOME=${DORIS_HOME}/thirdparty/installed/jdk1.8.0_131
fi

export JAVA=${JAVA_HOME}/bin/java
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
if [ $JAVA_VER -lt 18 ]; then
echo "Error: require JAVA with JDK version at least 1.8"
exit 1
fi

# check maven
export MVN=mvn
if ! ${MVN} --version; then
echo "Error: mvn is not found"
exit 1
fi

# check python
export PYTHON=python
if ! ${PYTHON} --version; then
export PYTHON=python2.7
if ! ${PYTHON} --version; then
echo "Error: python is not found"
exit
fi
fi

# set DORIS_THIRDPARTY
if [ -z ${DORIS_THIRDPARTY} ]; then
export DORIS_THIRDPARTY=${DORIS_HOME}/thirdparty
fi

22 changes: 4 additions & 18 deletions fs_brokers/apache_hdfs_broker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@
# under the License.

set -e

ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`

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

export BROKER_HOME=$ROOT
. ${DORIS_HOME}/env.sh

MVN=mvn
# Check ant
if ! ${MVN} --version; then
echo "mvn is not found"
exit 1
fi
export BROKER_HOME=$ROOT

# prepare thrift
mkdir -p ${BROKER_HOME}/src/main/resources/thrift
Expand Down
86 changes: 86 additions & 0 deletions run-fe-ut.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash
# Copyright (c) 2018, Baidu.com, Inc. All Rights Reserved

# Licensed 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 DORIS_HOME=${ROOT}

. ${DORIS_HOME}/env.sh

# Check args
usage() {
echo "
Usage: $0 <options>
Optional options:
--clean clean and build ut
--run build and run ut
Eg.
$0 build and run ut
$0 --coverage build and run coverage statistic
"
exit 1
}

OPTS=$(getopt \
-n $0 \
-o '' \
-l 'coverage' \
-- "$@")

if [ $? != 0 ] ; then
usage
fi

eval set -- "$OPTS"

COVERAGE=
if [ $# == 1 ] ; then
#default
COVERAGE=0
else
COVERAGE=0
while true; do
case "$1" in
--coverage) COVERAGE=1 ; shift ;;
--) shift ; break ;;
*) ehco "Internal error" ; exit 1 ;;
esac
done
fi

echo "Build Frontend UT"

rm ${DORIS_HOME}/fe/build/ -rf
rm ${DORIS_HOME}/fe/output/ -rf

echo "******************************"
echo " Runing PaloBe Unittest "
echo "******************************"

cd ${DORIS_HOME}/fe/
mkdir -p build/compile

if [ ${COVERAGE} -eq 1 ]; then
echo "Run coverage statistic"
ant cover-test
else
echo "Run Frontend UT"
$MVN test
fi
Loading

0 comments on commit 5afa29b

Please sign in to comment.