Merge pull request #29273 from taosdata/cover/3.0
merge: from cover/3.0 to 3.0 branch
This commit is contained in:
commit
eafbc5e97d
|
@ -385,6 +385,7 @@ Core dir: {core_dir}
|
||||||
send_msg(notification_robot_url, get_msg(text))
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
else:
|
else:
|
||||||
send_msg(alert_robot_url, get_msg(text))
|
send_msg(alert_robot_url, get_msg(text))
|
||||||
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
|
|
||||||
#send_msg(get_msg(text))
|
#send_msg(get_msg(text))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -419,6 +419,7 @@ Core dir: {core_dir}
|
||||||
send_msg(notification_robot_url, get_msg(text))
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
else:
|
else:
|
||||||
send_msg(alert_robot_url, get_msg(text))
|
send_msg(alert_robot_url, get_msg(text))
|
||||||
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
|
|
||||||
#send_msg(get_msg(text))
|
#send_msg(get_msg(text))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -407,6 +407,7 @@ Core dir: {core_dir}
|
||||||
send_msg(notification_robot_url, get_msg(text))
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
else:
|
else:
|
||||||
send_msg(alert_robot_url, get_msg(text))
|
send_msg(alert_robot_url, get_msg(text))
|
||||||
|
send_msg(notification_robot_url, get_msg(text))
|
||||||
|
|
||||||
#send_msg(get_msg(text))
|
#send_msg(get_msg(text))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -7,12 +7,120 @@ GREEN_DARK='\033[0;32m'
|
||||||
GREEN_UNDERLINE='\033[4;32m'
|
GREEN_UNDERLINE='\033[4;32m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
TDENGINE_DIR=/root/TDinternal/community
|
function print_color() {
|
||||||
|
local color="$1"
|
||||||
|
local message="$2"
|
||||||
|
echo -e "${color}${message}${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 初始化参数
|
||||||
|
TDENGINE_DIR="/root/TDinternal/community"
|
||||||
|
BRANCH=""
|
||||||
|
SAVE_LOG="notsave"
|
||||||
|
|
||||||
|
# 解析命令行参数
|
||||||
|
while getopts "hd:b:t:s:" arg; do
|
||||||
|
case $arg in
|
||||||
|
d)
|
||||||
|
TDENGINE_DIR=$OPTARG
|
||||||
|
;;
|
||||||
|
b)
|
||||||
|
BRANCH=$OPTARG
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
SAVE_LOG=$OPTARG
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
echo "Usage: $(basename $0) -d [TDengine_dir] -b [branch] -s [save ci case log]"
|
||||||
|
echo " -d [TDengine_dir] [default /root/TDinternal/community] "
|
||||||
|
echo " -b [branch] [default local branch] "
|
||||||
|
echo " -s [save/notsave] [default save ci case log in TDengine_dir/tests/ci_bak] "
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
echo "Usage: ./$(basename $0) -h"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# 检查是否提供了命令名称
|
||||||
|
if [ -z "$TDENGINE_DIR" ]; then
|
||||||
|
echo "Error: TDengine dir is required."
|
||||||
|
echo "Usage: $(basename $0) -d [TDengine_dir] -b [branch] -s [save ci case log] "
|
||||||
|
echo " -d [TDengine_dir] [default /root/TDinternal/community] "
|
||||||
|
echo " -b [branch] [default local branch] "
|
||||||
|
echo " -s [save/notsave] [default save ci case log in TDengine_dir/tests/ci_bak] "
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#echo "TDENGINE_DIR = $TDENGINE_DIR"
|
echo "TDENGINE_DIR = $TDENGINE_DIR"
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
TDENGINE_ALLCI_REPORT=$TDENGINE_DIR/tests/all-ci-report-$today.log
|
TDENGINE_ALLCI_REPORT="$TDENGINE_DIR/tests/all-ci-report-$today.log"
|
||||||
|
BACKUP_DIR="$TDENGINE_DIR/tests/ci_bak"
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
#cd $BACKUP_DIR && rm -rf *
|
||||||
|
|
||||||
|
|
||||||
|
function buildTDengine() {
|
||||||
|
print_color "$GREEN" "TDengine build start"
|
||||||
|
|
||||||
|
# pull parent code
|
||||||
|
cd "$TDENGINE_DIR/../"
|
||||||
|
print_color "$GREEN" "git pull parent code..."
|
||||||
|
git remote prune origin > /dev/null
|
||||||
|
git remote update > /dev/null
|
||||||
|
|
||||||
|
# pull tdengine code
|
||||||
|
cd $TDENGINE_DIR
|
||||||
|
print_color "$GREEN" "git pull tdengine code..."
|
||||||
|
git remote prune origin > /dev/null
|
||||||
|
git remote update > /dev/null
|
||||||
|
REMOTE_COMMIT=`git rev-parse --short remotes/origin/$branch`
|
||||||
|
LOCAL_COMMIT=`git rev-parse --short @`
|
||||||
|
print_color "$GREEN" " LOCAL: $LOCAL_COMMIT"
|
||||||
|
print_color "$GREEN" "REMOTE: $REMOTE_COMMIT"
|
||||||
|
|
||||||
|
if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then
|
||||||
|
print_color "$GREEN" "repo up-to-date"
|
||||||
|
else
|
||||||
|
print_color "$GREEN" "repo need to pull"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git reset --hard
|
||||||
|
git checkout -- .
|
||||||
|
git checkout $branch
|
||||||
|
git checkout -- .
|
||||||
|
git clean -f
|
||||||
|
git pull
|
||||||
|
|
||||||
|
[ -d $TDENGINE_DIR/debug ] || mkdir $TDENGINE_DIR/debug
|
||||||
|
cd $TDENGINE_DIR/debug
|
||||||
|
|
||||||
|
print_color "$GREEN" "rebuild.."
|
||||||
|
LOCAL_COMMIT=`git rev-parse --short @`
|
||||||
|
|
||||||
|
rm -rf *
|
||||||
|
makecmd="cmake -DBUILD_TEST=false -DBUILD_HTTP=false -DBUILD_DEPENDENCY_TESTS=0 -DBUILD_TOOLS=true -DBUILD_GEOS=true -DBUILD_TEST=true -DBUILD_CONTRIB=false ../../"
|
||||||
|
print_color "$GREEN" "$makecmd"
|
||||||
|
$makecmd
|
||||||
|
|
||||||
|
make -j 8 install
|
||||||
|
|
||||||
|
print_color "$GREEN" "TDengine build end"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 检查并获取分支名称
|
||||||
|
if [ -n "$BRANCH" ]; then
|
||||||
|
branch="$BRANCH"
|
||||||
|
print_color "$GREEN" "Testing branch: $branch "
|
||||||
|
print_color "$GREEN" "Build is required for this test!"
|
||||||
|
buildTDengine
|
||||||
|
else
|
||||||
|
print_color "$GREEN" "Build is not required for this test!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
function runCasesOneByOne () {
|
function runCasesOneByOne () {
|
||||||
|
@ -20,23 +128,50 @@ function runCasesOneByOne () {
|
||||||
if [[ "$line" != "#"* ]]; then
|
if [[ "$line" != "#"* ]]; then
|
||||||
cmd=`echo $line | cut -d',' -f 5`
|
cmd=`echo $line | cut -d',' -f 5`
|
||||||
if [[ "$2" == "sim" ]] && [[ $line == *"script"* ]]; then
|
if [[ "$2" == "sim" ]] && [[ $line == *"script"* ]]; then
|
||||||
|
echo $cmd
|
||||||
case=`echo $cmd | cut -d' ' -f 3`
|
case=`echo $cmd | cut -d' ' -f 3`
|
||||||
|
case_file=`echo $case | tr -d ' /' `
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
date +%F\ %T | tee -a $TDENGINE_ALLCI_REPORT && timeout 20m $cmd > /dev/null 2>&1 && \
|
date +%F\ %T | tee -a $TDENGINE_ALLCI_REPORT && timeout 20m $cmd > $TDENGINE_DIR/tests/$case_file.log 2>&1 && \
|
||||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_ALLCI_REPORT \
|
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_ALLCI_REPORT || \
|
||||||
|| echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_ALLCI_REPORT
|
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
|
|
||||||
|
# # 记录日志和备份
|
||||||
|
# mkdir -p "$BACKUP_DIR/$case_file"
|
||||||
|
# tar --exclude='*.sock*' -czf "$BACKUP_DIR/$case_file/sim.tar.gz" -C "$TDENGINE_DIR/.." sim
|
||||||
|
# mv "$TDENGINE_DIR/tests/$case_file.log" "$BACKUP_DIR/$case_file"
|
||||||
|
|
||||||
|
if [ "$SAVE_LOG" == "save" ]; then
|
||||||
|
mkdir -p "$BACKUP_DIR/$case_file"
|
||||||
|
tar --exclude='*.sock*' -czf "$BACKUP_DIR/$case_file/sim.tar.gz" -C "$TDENGINE_DIR/.." sim
|
||||||
|
mv "$TDENGINE_DIR/tests/$case_file.log" "$BACKUP_DIR/$case_file"
|
||||||
|
else
|
||||||
|
echo "This case not save log!"
|
||||||
|
fi
|
||||||
|
|
||||||
end_time=`date +%s`
|
end_time=`date +%s`
|
||||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_ALLCI_REPORT
|
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
|
|
||||||
elif [[ "$line" == *"$2"* ]]; then
|
elif [[ "$line" == *"$2"* ]]; then
|
||||||
|
echo $cmd
|
||||||
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
||||||
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
||||||
fi
|
fi
|
||||||
case=`echo $cmd | cut -d' ' -f 4-20`
|
case=`echo $cmd | cut -d' ' -f 4-20`
|
||||||
|
case_file=`echo $case | tr -d ' /' `
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
date +%F\ %T | tee -a $TDENGINE_ALLCI_REPORT && timeout 20m $cmd > /dev/null 2>&1 && \
|
date +%F\ %T | tee -a $TDENGINE_ALLCI_REPORT && timeout 20m $cmd > $TDENGINE_DIR/tests/$case_file.log 2>&1 && \
|
||||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_ALLCI_REPORT || \
|
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_ALLCI_REPORT || \
|
||||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_ALLCI_REPORT
|
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
|
|
||||||
|
if [ "$SAVE_LOG" == "save" ]; then
|
||||||
|
mkdir -p "$BACKUP_DIR/$case_file"
|
||||||
|
tar --exclude='*.sock*' -czf "$BACKUP_DIR/$case_file/sim.tar.gz" -C "$TDENGINE_DIR/.." sim
|
||||||
|
mv "$TDENGINE_DIR/tests/$case_file.log" "$BACKUP_DIR/$case_file"
|
||||||
|
else
|
||||||
|
echo "This case not save log!"
|
||||||
|
fi
|
||||||
|
|
||||||
end_time=`date +%s`
|
end_time=`date +%s`
|
||||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_ALLCI_REPORT
|
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
fi
|
fi
|
||||||
|
@ -45,62 +180,62 @@ function runCasesOneByOne () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runUnitTest() {
|
function runUnitTest() {
|
||||||
echo "=== Run unit test case ==="
|
print_color "$GREEN" "=== Run unit test case ==="
|
||||||
echo " $TDENGINE_DIR/debug"
|
print_color "$GREEN" " $TDENGINE_DIR/../debug"
|
||||||
cd $TDENGINE_DIR/debug
|
cd $TDENGINE_DIR/../debug
|
||||||
ctest -j12
|
ctest -j12
|
||||||
echo "3.0 unit test done"
|
print_color "$GREEN" "3.0 unit test done"
|
||||||
}
|
}
|
||||||
|
|
||||||
function runSimCases() {
|
function runSimCases() {
|
||||||
echo "=== Run sim cases ==="
|
print_color "$GREEN" "=== Run sim cases ==="
|
||||||
|
|
||||||
cd $TDENGINE_DIR/tests/script
|
cd $TDENGINE_DIR/tests/script
|
||||||
runCasesOneByOne $TDENGINE_DIR/tests/parallel_test/cases-test.task sim
|
runCasesOneByOne $TDENGINE_DIR/tests/parallel_test/cases.task sim
|
||||||
|
|
||||||
totalSuccess=`grep 'sim success' $TDENGINE_ALLCI_REPORT | wc -l`
|
totalSuccess=`grep 'sim success' $TDENGINE_ALLCI_REPORT | wc -l`
|
||||||
if [ "$totalSuccess" -gt "0" ]; then
|
if [ "$totalSuccess" -gt "0" ]; then
|
||||||
echo "### Total $totalSuccess SIM test case(s) succeed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
print_color "$GREEN" "### Total $totalSuccess SIM test case(s) succeed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
totalFailed=`grep 'sim failed\|fault' $TDENGINE_ALLCI_REPORT | wc -l`
|
totalFailed=`grep 'sim failed\|fault' $TDENGINE_ALLCI_REPORT | wc -l`
|
||||||
if [ "$totalFailed" -ne "0" ]; then
|
if [ "$totalFailed" -ne "0" ]; then
|
||||||
echo "### Total $totalFailed SIM test case(s) failed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
print_color "$RED" "### Total $totalFailed SIM test case(s) failed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function runPythonCases() {
|
function runPythonCases() {
|
||||||
echo "=== Run python cases ==="
|
print_color "$GREEN" "=== Run python cases ==="
|
||||||
|
|
||||||
cd $TDENGINE_DIR/tests/parallel_test
|
cd $TDENGINE_DIR/tests/parallel_test
|
||||||
sed -i '/compatibility.py/d' cases-test.task
|
sed -i '/compatibility.py/d' cases.task
|
||||||
|
|
||||||
# army
|
# army
|
||||||
cd $TDENGINE_DIR/tests/army
|
cd $TDENGINE_DIR/tests/army
|
||||||
runCasesOneByOne ../parallel_test/cases-test.task army
|
runCasesOneByOne ../parallel_test/cases.task army
|
||||||
|
|
||||||
# system-test
|
# system-test
|
||||||
cd $TDENGINE_DIR/tests/system-test
|
cd $TDENGINE_DIR/tests/system-test
|
||||||
runCasesOneByOne ../parallel_test/cases-test.task system-test
|
runCasesOneByOne ../parallel_test/cases.task system-test
|
||||||
|
|
||||||
# develop-test
|
# develop-test
|
||||||
cd $TDENGINE_DIR/tests/develop-test
|
cd $TDENGINE_DIR/tests/develop-test
|
||||||
runCasesOneByOne ../parallel_test/cases-test.task develop-test
|
runCasesOneByOne ../parallel_test/cases.task develop-test
|
||||||
|
|
||||||
totalSuccess=`grep 'py success' $TDENGINE_ALLCI_REPORT | wc -l`
|
totalSuccess=`grep 'py success' $TDENGINE_ALLCI_REPORT | wc -l`
|
||||||
if [ "$totalSuccess" -gt "0" ]; then
|
if [ "$totalSuccess" -gt "0" ]; then
|
||||||
echo "### Total $totalSuccess python test case(s) succeed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
print_color "$GREEN" "### Total $totalSuccess python test case(s) succeed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
totalFailed=`grep 'py failed\|fault' $TDENGINE_ALLCI_REPORT | wc -l`
|
totalFailed=`grep 'py failed\|fault' $TDENGINE_ALLCI_REPORT | wc -l`
|
||||||
if [ "$totalFailed" -ne "0" ]; then
|
if [ "$totalFailed" -ne "0" ]; then
|
||||||
echo "### Total $totalFailed python test case(s) failed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
print_color "$RED" "### Total $totalFailed python test case(s) failed! ###" | tee -a $TDENGINE_ALLCI_REPORT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function runTest() {
|
function runTest() {
|
||||||
echo "run Test"
|
print_color "$GREEN" "run Test"
|
||||||
|
|
||||||
cd $TDENGINE_DIR
|
cd $TDENGINE_DIR
|
||||||
[ -d sim ] && rm -rf sim
|
[ -d sim ] && rm -rf sim
|
||||||
|
@ -119,7 +254,7 @@ function runTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopTaosd {
|
function stopTaosd {
|
||||||
echo "Stop taosd start"
|
print_color "$GREEN" "Stop taosd start"
|
||||||
systemctl stop taosd
|
systemctl stop taosd
|
||||||
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
while [ -n "$PID" ]
|
while [ -n "$PID" ]
|
||||||
|
@ -128,11 +263,11 @@ function stopTaosd {
|
||||||
sleep 1
|
sleep 1
|
||||||
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
done
|
done
|
||||||
echo "Stop tasod end"
|
print_color "$GREEN" "Stop tasod end"
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopTaosadapter {
|
function stopTaosadapter {
|
||||||
echo "Stop taosadapter"
|
print_color "$GREEN" "Stop taosadapter"
|
||||||
systemctl stop taosadapter.service
|
systemctl stop taosadapter.service
|
||||||
PID=`ps -ef|grep -w taosadapter | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef|grep -w taosadapter | grep -v grep | awk '{print $2}'`
|
||||||
while [ -n "$PID" ]
|
while [ -n "$PID" ]
|
||||||
|
@ -141,18 +276,18 @@ function stopTaosadapter {
|
||||||
sleep 1
|
sleep 1
|
||||||
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
done
|
done
|
||||||
echo "Stop tasoadapter end"
|
print_color "$GREEN" "Stop tasoadapter end"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WORK_DIR=/root/
|
WORK_DIR=/root/
|
||||||
|
|
||||||
date >> $WORK_DIR/date.log
|
date >> $WORK_DIR/date.log
|
||||||
echo "Run ALL CI Test Cases" | tee -a $WORK_DIR/date.log
|
print_color "$GREEN" "Run all ci test cases" | tee -a $WORK_DIR/date.log
|
||||||
|
|
||||||
stopTaosd
|
stopTaosd
|
||||||
|
|
||||||
runTest
|
runTest
|
||||||
|
|
||||||
date >> $WORK_DIR/date.log
|
date >> $WORK_DIR/date.log
|
||||||
echo "End of CI Test Cases" | tee -a $WORK_DIR/date.log
|
print_color "$GREEN" "End of ci test cases" | tee -a $WORK_DIR/date.log
|
|
@ -17,9 +17,10 @@ function print_color() {
|
||||||
TDENGINE_DIR="/root/TDinternal/community"
|
TDENGINE_DIR="/root/TDinternal/community"
|
||||||
BRANCH=""
|
BRANCH=""
|
||||||
TDENGINE_GCDA_DIR="/root/TDinternal/community/debug/"
|
TDENGINE_GCDA_DIR="/root/TDinternal/community/debug/"
|
||||||
|
LCOV_DIR="/usr/local/bin"
|
||||||
|
|
||||||
# Parse command line parameters
|
# Parse command line parameters
|
||||||
while getopts "hd:b:f:c:u:i:" arg; do
|
while getopts "hd:b:f:c:u:i:l:" arg; do
|
||||||
case $arg in
|
case $arg in
|
||||||
d)
|
d)
|
||||||
TDENGINE_DIR=$OPTARG
|
TDENGINE_DIR=$OPTARG
|
||||||
|
@ -39,14 +40,18 @@ while getopts "hd:b:f:c:u:i:" arg; do
|
||||||
i)
|
i)
|
||||||
BRANCH_BUILD=$OPTARG
|
BRANCH_BUILD=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
l)
|
||||||
|
LCOV_DIR=$OPTARG
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage: $(basename $0) -d [TDengine dir] -b [Test branch] -i [Build test branch] -f [TDengine gcda dir] -c [Test single case/all cases] -u [Unit test case]"
|
echo "Usage: $(basename $0) -d [TDengine dir] -b [Test branch] -i [Build test branch] -f [TDengine gcda dir] -c [Test single case/all cases] -u [Unit test case] -l [Lcov dir]"
|
||||||
echo " -d [TDengine dir] [default /root/TDinternal/community; eg: /home/TDinternal/community] "
|
echo " -d [TDengine dir] [default /root/TDinternal/community; eg: /home/TDinternal/community] "
|
||||||
echo " -b [Test branch] [default local branch; eg:cover/3.0] "
|
echo " -b [Test branch] [default local branch; eg:cover/3.0] "
|
||||||
echo " -i [Build test branch] [default no:not build, but still install ;yes:will build and install ] "
|
echo " -i [Build test branch] [default no:not build, but still install ;yes:will build and install ] "
|
||||||
echo " -f [TDengine gcda dir] [default /root/TDinternal/community/debug; eg:/root/TDinternal/community/debug/community/source/dnode/vnode/CMakeFiles/vnode.dir/src/tq/] "
|
echo " -f [TDengine gcda dir] [default /root/TDinternal/community/debug; eg:/root/TDinternal/community/debug/community/source/dnode/vnode/CMakeFiles/vnode.dir/src/tq/] "
|
||||||
echo " -c [Test single case/all cases] [default null; -c all : include parallel_test/longtimeruning_cases.task and all unit cases; -c task : include parallel_test/longtimeruning_cases.task; single case: eg: -c './test.sh -f tsim/stream/streamFwcIntervalFill.sim' ] "
|
echo " -c [Test single case/all cases] [default null; -c all : include parallel_test/longtimeruning_cases.task and all unit cases; -c task : include parallel_test/longtimeruning_cases.task; single case: eg: -c './test.sh -f tsim/stream/streamFwcIntervalFill.sim' ] "
|
||||||
echo " -u [Unit test case] [default null; eg: './schedulerTest' ] "
|
echo " -u [Unit test case] [default null; eg: './schedulerTest' ] "
|
||||||
|
echo " -l [Lcov bin dir] [default /usr/local/bin; eg: '/root/TDinternal/community/tests/lcov-1.14/bin' ] "
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
|
@ -59,13 +64,14 @@ done
|
||||||
# Check if the command name is provided
|
# Check if the command name is provided
|
||||||
if [ -z "$TDENGINE_DIR" ]; then
|
if [ -z "$TDENGINE_DIR" ]; then
|
||||||
echo "Error: TDengine dir is required."
|
echo "Error: TDengine dir is required."
|
||||||
echo "Usage: $(basename $0) -d [TDengine dir] -b [Test branch] -i [Build test branch] -f [TDengine gcda dir] -c [Test single case/all cases] -u [Unit test case] "
|
echo "Usage: $(basename $0) -d [TDengine dir] -b [Test branch] -i [Build test branch] -f [TDengine gcda dir] -c [Test single case/all cases] -u [Unit test case] -l [Lcov dir] "
|
||||||
echo " -d [TDengine dir] [default /root/TDinternal/community; eg: /home/TDinternal/community] "
|
echo " -d [TDengine dir] [default /root/TDinternal/community; eg: /home/TDinternal/community] "
|
||||||
echo " -b [Test branch] [default local branch; eg:cover/3.0] "
|
echo " -b [Test branch] [default local branch; eg:cover/3.0] "
|
||||||
echo " -i [Build test branch] [default no:not build, but still install ;yes:will build and install ] "
|
echo " -i [Build test branch] [default no:not build, but still install ;yes:will build and install ] "
|
||||||
echo " -f [TDengine gcda dir] [default /root/TDinternal/community/debug; eg:/root/TDinternal/community/debug/community/source/dnode/vnode/CMakeFiles/vnode.dir/src/tq/] "
|
echo " -f [TDengine gcda dir] [default /root/TDinternal/community/debug; eg:/root/TDinternal/community/debug/community/source/dnode/vnode/CMakeFiles/vnode.dir/src/tq/] "
|
||||||
echo " -c [Test casingle case/all casesse] [default null; -c all : include parallel_test/longtimeruning_cases.task and all unit cases; -c task : include parallel_test/longtimeruning_cases.task; single case: eg: -c './test.sh -f tsim/stream/streamFwcIntervalFill.sim' ] "
|
echo " -c [Test casingle case/all casesse] [default null; -c all : include parallel_test/longtimeruning_cases.task and all unit cases; -c task : include parallel_test/longtimeruning_cases.task; single case: eg: -c './test.sh -f tsim/stream/streamFwcIntervalFill.sim' ] "
|
||||||
echo " -u [Unit test case] [default null; eg: './schedulerTest' ] "
|
echo " -u [Unit test case] [default null; eg: './schedulerTest' ] "
|
||||||
|
echo " -l [Lcov bin dir] [default /usr/local/bin; eg: '/root/TDinternal/community/tests/lcov-1.14/bin' ] "
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -299,11 +305,18 @@ function lcovFunc {
|
||||||
print_color "$GREEN" "Test gcda file dir is default: /root/TDinternal/community/debug"
|
print_color "$GREEN" "Test gcda file dir is default: /root/TDinternal/community/debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$LCOV_DIR" ]; then
|
||||||
|
LCOV_DIR="$LCOV_DIR"
|
||||||
|
print_color "$GREEN" "Lcov bin dir: $LCOV_DIR "
|
||||||
|
else
|
||||||
|
print_color "$GREEN" "Lcov bin dir is default"
|
||||||
|
fi
|
||||||
|
|
||||||
# collect data
|
# collect data
|
||||||
lcov -d "$TDENGINE_GCDA_DIR" -capture --rc lcov_branch_coverage=1 --rc genhtml_branch_coverage=1 --no-external -b $TDENGINE_DIR -o coverage.info
|
$LCOV_DIR/lcov -d "$TDENGINE_GCDA_DIR" -capture --rc lcov_branch_coverage=1 --rc genhtml_branch_coverage=1 --no-external -b $TDENGINE_DIR -o coverage.info
|
||||||
|
|
||||||
# remove exclude paths
|
# remove exclude paths
|
||||||
lcov --remove coverage.info \
|
$LCOV_DIR/lcov --remove coverage.info \
|
||||||
'*/contrib/*' '*/test/*' '*/packaging/*' '*/taos-tools/*' '*/taosadapter/*' '*/TSZ/*' \
|
'*/contrib/*' '*/test/*' '*/packaging/*' '*/taos-tools/*' '*/taosadapter/*' '*/TSZ/*' \
|
||||||
'*/AccessBridgeCalls.c' '*/ttszip.c' '*/dataInserter.c' '*/tlinearhash.c' '*/tsimplehash.c' '*/tsdbDiskData.c' '/*/enterprise/*' '*/docs/*' '*/sim/*'\
|
'*/AccessBridgeCalls.c' '*/ttszip.c' '*/dataInserter.c' '*/tlinearhash.c' '*/tsimplehash.c' '*/tsdbDiskData.c' '/*/enterprise/*' '*/docs/*' '*/sim/*'\
|
||||||
'*/texpr.c' '*/runUdf.c' '*/schDbg.c' '*/syncIO.c' '*/tdbOs.c' '*/pushServer.c' '*/osLz4.c'\
|
'*/texpr.c' '*/runUdf.c' '*/schDbg.c' '*/syncIO.c' '*/tdbOs.c' '*/pushServer.c' '*/osLz4.c'\
|
||||||
|
@ -316,7 +329,7 @@ function lcovFunc {
|
||||||
|
|
||||||
# generate result
|
# generate result
|
||||||
echo "generate result"
|
echo "generate result"
|
||||||
lcov -l --rc lcov_branch_coverage=1 coverage.info | tee -a $TDENGINE_COVERAGE_REPORT
|
$LCOV_DIR/lcov -l --rc lcov_branch_coverage=1 coverage.info | tee -a $TDENGINE_COVERAGE_REPORT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,8 +386,14 @@ if [ ! -f "$COVERAGE_INFO" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$LCOV_DIR" ]; then
|
||||||
|
LCOV_DIR="$LCOV_DIR"
|
||||||
|
print_color "$GREEN" "Lcov bin dir: $LCOV_DIR "
|
||||||
|
else
|
||||||
|
print_color "$GREEN" "Lcov bin dir is default"
|
||||||
|
fi
|
||||||
# Generate local HTML reports
|
# Generate local HTML reports
|
||||||
genhtml "$COVERAGE_INFO" --branch-coverage --function-coverage --output-directory "$OUTPUT_DIR"
|
$LCOV_DIR/genhtml "$COVERAGE_INFO" --branch-coverage --function-coverage --output-directory "$OUTPUT_DIR"
|
||||||
|
|
||||||
# Check whether the report was generated successfully
|
# Check whether the report was generated successfully
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "Usage: $0 -v <version>"
|
||||||
|
echo "Example: $0 -v 1.14"
|
||||||
|
}
|
||||||
|
|
||||||
|
function download_lcov() {
|
||||||
|
local version=$1
|
||||||
|
local url="https://github.com/linux-test-project/lcov/releases/download/v${version}/lcov-${version}.tar.gz"
|
||||||
|
echo "Downloading lcov version ${version} from ${url}..."
|
||||||
|
curl -LO ${url}
|
||||||
|
tar -xzf lcov-${version}.tar.gz
|
||||||
|
echo "lcov version ${version} downloaded and extracted."
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_lcov() {
|
||||||
|
echo -e "\nInstalling..."
|
||||||
|
local version=$1
|
||||||
|
cd lcov-${version}
|
||||||
|
sudo make uninstall && sudo make install
|
||||||
|
cd ..
|
||||||
|
echo "lcov version ${version} installed."
|
||||||
|
}
|
||||||
|
|
||||||
|
function verify_lcov() {
|
||||||
|
echo -e "\nVerify installation..."
|
||||||
|
lcov --version
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
if [[ "$#" -ne 2 ]]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while getopts "v:h" opt; do
|
||||||
|
case ${opt} in
|
||||||
|
v)
|
||||||
|
version=${OPTARG}
|
||||||
|
download_lcov ${version}
|
||||||
|
install_lcov ${version}
|
||||||
|
verify_lcov
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
Loading…
Reference in New Issue