merge master
This commit is contained in:
@ -672,7 +672,7 @@ ifeq ($(enable_thread_check), yes)
|
||||
endif
|
||||
cp $(with_3rd)/buildtools/server_key/* '$(DESTDIR)$(bindir)/'
|
||||
endif
|
||||
cp -r $(with_3rd)/platform/$(PLAT_FORM_STR)/huaweijdk8/jdk1.8.0_272/jre/* '$(DESTDIR)$(bindir)/../jre/'
|
||||
cp -r $(with_3rd)/platform/$(PLAT_FORM_STR)/openjdk8/jdk1.8.222/jre/* '$(DESTDIR)$(bindir)/../jre/'
|
||||
|
||||
cp $(PLJAVA_LIB_PATH)/* '$(DESTDIR)$(libdir)/'
|
||||
cp $(PLJAVA_JAR_PATH)/$(JARPLJAVA) '$(DESTDIR)$(pkglibdir)/java/'
|
||||
|
403
src/test/ha/script/Private_LLT_Build_Ha.sh
Normal file
403
src/test/ha/script/Private_LLT_Build_Ha.sh
Normal file
@ -0,0 +1,403 @@
|
||||
|
||||
# 获取当前执行脚本绝对路径
|
||||
path=$(dirname "${BASH_SOURCE-$0}")
|
||||
real_path=$(cd "$path">/dev/null;pwd)
|
||||
|
||||
# 定义函数,功能:引入配置文件 及 function目录下定义的函数
|
||||
function source_file()
|
||||
{
|
||||
[ ! -f "${g_conf_file}" ] && echo "Can not find config file ${g_conf_file}" && exit 1
|
||||
|
||||
# 去除配置文件中的\r字符
|
||||
config_str="$(cat "$g_conf_file" | grep -v "^[[:space:]]*$" | \
|
||||
grep -v "^#" | tr -d '\r')"
|
||||
|
||||
config_str_new="$config_str"
|
||||
#printf "$config_str_new\n"
|
||||
# 引入配置文件
|
||||
eval "$config_str"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "source ${g_conf_file} failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# source function目录下定义的函数
|
||||
while read line
|
||||
do
|
||||
source "$line"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "source ${line} failed"
|
||||
return 1
|
||||
fi
|
||||
done << _EOF_
|
||||
$(find "${real_path}/function/" -mindepth 1 -maxdepth 1 \
|
||||
-name "[0-9][0-9].*.sh" -type f | sort)
|
||||
_EOF_
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# 展示环境信息
|
||||
function show_env_detail
|
||||
{
|
||||
# get OS version.
|
||||
os_name="$(get_osname)"
|
||||
if [ "${os_name}" == "" ]; then
|
||||
error "openGauss" "Can not get OS type on Current node"
|
||||
return 1
|
||||
else
|
||||
log "openGauss" "OS Type: ${os_name}"
|
||||
fi
|
||||
|
||||
# show env var
|
||||
log "openGauss" "Work Dir: ${g_boot_dir}"
|
||||
log "openGauss" "Code Dir: ${g_src_dir}"
|
||||
log "openGauss" "Log Dir: ${g_log_file}"
|
||||
log "openGauss" "Build Dir: ${g_build_dir}"
|
||||
log "openGauss" "Current User: ${USER}"
|
||||
log "openGauss" "Configure Pkg Type: ${g_release_mode}"
|
||||
log "openGauss" "User for HAcheck: ${g_execute_user}"
|
||||
log "openGauss" "Port for HAcheck: ${g_check_port}"
|
||||
|
||||
log "openGauss" "ENV VAR -- MPPHOME: ${MPPHOME}"
|
||||
log "openGauss" "ENV VAR -- GAUSSHOME: ${GAUSSHOME}"
|
||||
log "openGauss" "ENV VAR -- MPPDB_CODE: ${MPPDB_CODE}"
|
||||
log "openGauss" "ENV VAR -- CC: ${CC}"
|
||||
log "openGauss" "ENV VAR -- CXX: ${CXX}"
|
||||
log "openGauss" "ENV VAR -- LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
|
||||
log "openGauss" "ENV VAR -- PATH: ${PATH}"
|
||||
|
||||
log "openGauss" "OPTION -- Retrans_enable: ${g_retrans_enable}"
|
||||
log "openGauss" "OPTION -- g_master_user: ${g_master_user}"
|
||||
log "openGauss" "OPTION -- g_master_log_path: ${g_master_log_path}"
|
||||
log "openGauss" "OPTION -- g_top_build_id: ${g_top_build_id}"
|
||||
log "openGauss" "OPTION -- g_cur_build_id: ${g_cur_build_id}"
|
||||
}
|
||||
|
||||
# mk_hacheck
|
||||
function mk_hacheck
|
||||
{
|
||||
|
||||
# get OS version.
|
||||
os_name="$(get_osname)"
|
||||
#change current work dir to src
|
||||
log "openGauss" "Change current dir to src dir"
|
||||
log "openGauss" "Command: cd ${g_src_dir}"
|
||||
cd ${g_src_dir} >> ${g_log_file} 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
error "openGauss" "Change dir failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#configure
|
||||
configure_start_time=$(date +%s.%N)
|
||||
log "openGauss" "configure_start_time="${configure_start_time}""
|
||||
log "openGauss" "Begin configure..."
|
||||
chmod 755 configure
|
||||
|
||||
if [ "${g_release_mode}" == "release" ]; then
|
||||
log "openGauss" "Command: ./configure --prefix="${g_build_dir}" CC=g++ CFLAGS='-O2' --enable-thread-safety --with-readline --without-zlib --disable-debug --gcc-version=8.2.0 "
|
||||
./configure --prefix="${g_build_dir}" CC=g++ CFLAGS='-O2' --enable-thread-safety --with-readline --without-zlib --disable-debug --gcc-version=8.2.0 >> ${g_log_file} 2>&1
|
||||
else
|
||||
log "openGauss" "Command: ./configure --prefix="${g_build_dir}" --enable-debug --enable-cassert CC=g++ CFLAGS='-g3 -O2 -w' --without-zlib --gcc-version=8.2.0 --3rd="${BINARYLIBS}""
|
||||
./configure --prefix="${g_build_dir}" --enable-debug --enable-cassert CC=g++ CFLAGS='-g3 -O2 -w' --without-zlib --gcc-version=8.2.0 --3rd="${BINARYLIBS}">> ${g_log_file} 2>&1
|
||||
fi
|
||||
|
||||
configure_stop_time=$(date +%s.%N)
|
||||
log "openGauss" "configure_stop_time="${configure_stop_time}""
|
||||
if [ $? -ne 0 ]; then
|
||||
error "openGauss" "Configure failed."
|
||||
log "openGauss" "Configure detail:"
|
||||
sed -n '/configure --prefix/,$'p ${g_log_file}|sed 1d|sed '$d'|sed '$d'
|
||||
flag_configure_fail=1
|
||||
return 1
|
||||
else
|
||||
log "openGauss" "Configure succeed."
|
||||
flag_configure_fail=0
|
||||
fi
|
||||
|
||||
#make clean
|
||||
makeclean_start_time=$(date +%s.%N)
|
||||
log "openGauss" "makeclean_start_time="${makeclean_start_time}""
|
||||
log "openGauss" "Begin make clean..."
|
||||
log "openGauss" "Command: make clean -sj 8"
|
||||
make clean -sj 8 >> ${g_log_file} 2>&1
|
||||
makeclean_stop_time=$(date +%s.%N)
|
||||
log "openGauss" "makeclean_stop_time="${makeclean_stop_time}""
|
||||
if [ $? -ne 0 ]; then
|
||||
error "openGauss" "Make clean failed"
|
||||
flag_makeclean_fail=1
|
||||
return 1
|
||||
else
|
||||
log "openGauss" "Make clean succeed."
|
||||
flag_makeclean_fail=0
|
||||
fi
|
||||
|
||||
#make install
|
||||
makeinstall_start_time=$(date +%s.%N)
|
||||
log "openGauss" "makeinstall_start_time="${makeinstall_start_time}""
|
||||
log "openGauss" "Begin make install..."
|
||||
for((i=1;i<=2;i++))
|
||||
do
|
||||
log "openGauss" "Try $i time ..."
|
||||
log "openGauss" "Command: make install -sj 8"
|
||||
cd ${g_src_dir} && make install -sj 8 >> ${g_log_file} 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
log "openGauss" "Make install succeed."
|
||||
flag_makeinstall_fail=0
|
||||
break
|
||||
else
|
||||
if [ $i -eq 2 ];then
|
||||
error "openGauss" "Make install failed."
|
||||
log "openGauss" "Make install detail:"
|
||||
sed -n '/make install -sj 8/,$'p ${g_log_file}|sed 1d|sed '$d'|sed '$d'
|
||||
[ -f "${g_src_dir}/src/test/regress/log/install.log" ] && cat ${g_src_dir}/src/test/regress/log/install.log
|
||||
flag_makeinstall_fail=1
|
||||
return 1
|
||||
else
|
||||
error "openGauss" "Make install failed first time."
|
||||
log "openGauss" "Execute make clean -sj 8 for make install again."
|
||||
cd ${g_src_dir} && make clean -sj 8 >> ${g_log_file} 2>&1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
makeinstall_stop_time=$(date +%s.%N)
|
||||
log "openGauss" "makeinstall_stop_time="${makeinstall_stop_time}""
|
||||
#make hacheck
|
||||
makehacheck_start_time=$(date +%s.%N)
|
||||
log "openGauss" "makehacheck_start_time="${makehacheck_start_time}""
|
||||
log "openGauss" "Begin make hacheck..."
|
||||
CUR_USER=`whoami`
|
||||
if [ "${CUR_USER}" == "root" ]; then
|
||||
log "openGauss" "Current user is root."
|
||||
#create user
|
||||
#add_user
|
||||
chown -R ${g_execute_user} ${g_boot_dir} >> ${g_log_file} 2>&1
|
||||
chmod 777 ${g_boot_dir} >> ${g_log_file} 2>&1
|
||||
#change port
|
||||
sed -i "s/export g_base_port=8888/export g_base_port=${g_check_port}/g" ${g_src_dir}/src/test/ha/standby_env.sh
|
||||
#change user to make check
|
||||
log "openGauss" "Begin do the ${check_mode} ..."
|
||||
log "openGauss" "Command: su - ${g_execute_user} -c \"source $g_conf_file && export && cd \"${g_src_dir}/src/test/ha\" && make ${check_mode} PART=${check_part}\""
|
||||
result=`su - ${g_execute_user} -c "source $g_conf_file && export && cd \"${g_src_dir}/src/test/ha\" && make ${check_mode} PART=${check_part}" >> ${g_log_file} 2>&1`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
makehacheck_stop_time=$(date +%s.%N)
|
||||
log "openGauss" "makehacheck_stop_time="${makehacheck_stop_time}""
|
||||
error "openGauss" "Make ${check_mode} failed."
|
||||
cat ${g_src_dir}/src/test/ha/deploy_standby_multi_single.log 2>&1 | tee -a ${g_log_file}
|
||||
cat ${g_src_dir}/src/test/ha/deploy_standby_single.log 2>&1 | tee -a ${g_log_file}
|
||||
cat ${g_src_dir}/src/test/ha/gaussdb.log 2>&1 | tee -a ${g_log_file}
|
||||
cat ${g_src_dir}/src/test/ha/gs_ctl.log 2>&1 | tee -a ${g_log_file}
|
||||
cat ${g_src_dir}/src/test/ha/stop_database_multi_single.log 2>&1 | tee -a ${g_log_file}
|
||||
cat ${g_src_dir}/src/test/ha/stop_database_single.log 2>&1 | tee -a ${g_log_file}
|
||||
flag_makehacheck_fail=1
|
||||
return 1
|
||||
else
|
||||
makehacheck_stop_time=$(date +%s.%N)
|
||||
log "openGauss" "makehacheck_stop_time="${makehacheck_stop_time}""
|
||||
flag_makehacheck_fail=0
|
||||
log "openGauss" "Make ${check_mode} succeed."
|
||||
fi
|
||||
else
|
||||
error "openGauss" "Need current user to be root"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function transport_info
|
||||
{
|
||||
export g_aes_rand_key="$(date +%s%N)"
|
||||
g_trans_log_path=${g_master_log_path}/$(date +'%Y%m%d')_TID_${g_top_build_id}
|
||||
if [ -z "$g_master_ip" -o \
|
||||
-z "$g_master_user" -o \
|
||||
-z "$g_master_password" -o \
|
||||
-z "$g_master_log_path" -o \
|
||||
-z "$g_top_build_id" -o \
|
||||
-z "$g_cur_build_id" \
|
||||
];then
|
||||
error "openGauss" "Fail transport logs. Option Retrans parameters have error(s),please check"
|
||||
return 1
|
||||
fi
|
||||
res=0
|
||||
sh ${real_path}/function/remote.sh -i $g_master_ip -u $g_master_user -p "$g_master_password" -m "ssh-cmd" -t 100000 -c "mkdir -p $g_trans_log_path" 2>&1 >> ${g_log_file}
|
||||
res=$(expr $res \| $?)
|
||||
for i in $(ls ${g_log_file%.log}*)
|
||||
do
|
||||
sh ${real_path}/function/remote.sh -i $g_master_ip -u $g_master_user -p "$g_master_password" -m "scp-out" -t 100000 -s $i -d $g_trans_log_path 2>&1 >> ${g_log_file}
|
||||
res=$(expr $res \| $?)
|
||||
#echo "DETAIL: ftp://mpp:mpp@$g_master_ip/log_fastcheck/${g_trans_log_path##*/}/${i##*/}" | tee -a ${g_log_file}
|
||||
done
|
||||
if [ $res -ne 0 ];then
|
||||
error "openGauss" "Fail transport logs"
|
||||
fi
|
||||
}
|
||||
|
||||
function cal_interval_time
|
||||
{
|
||||
if [ $# -ne 2 ];then
|
||||
printf " "
|
||||
return 1
|
||||
fi
|
||||
local t=$(awk 'BEGIN{print '$2' - '$1'}')
|
||||
local z=${t%.*}
|
||||
printf "%.2d:%.2d:%.2d" $((z/60/60)) $((z/60%60)) $((z%60))
|
||||
}
|
||||
function judge_time
|
||||
{
|
||||
local display="$1"
|
||||
local flag_fail=$2
|
||||
local start_time=$3
|
||||
local stop_time=$4
|
||||
if [ -z "$flag_fail" -o x"$flag_fail" = x"1" ];then
|
||||
flag_str="Failure"
|
||||
else
|
||||
flag_str="Success"
|
||||
fi
|
||||
interval_time="$(cal_interval_time $start_time $stop_time)"
|
||||
[ -z "$start_time" ] && start_time=" " || start_time=$(date -d @$start_time '+%Y-%m-%d %T')
|
||||
[ -z "$stop_time" ] && stop_time=" " || stop_time=$(date -d @$stop_time '+%Y-%m-%d %T')
|
||||
printf "|$display| $flag_str | $start_time | $stop_time | $interval_time |\n"
|
||||
}
|
||||
function gen_report
|
||||
{
|
||||
if [ "${check_mode}" = "hacheck_single" -o "${check_mode}" = "hacheck_multi_single" ];then
|
||||
printf "\
|
||||
==============================================================================================
|
||||
| Work Dir | ${g_boot_dir}
|
||||
| llt part | ${check_part}
|
||||
----------------------------------------------------------------------------------------------
|
||||
| Stage | Status | Start Time | Stop Time | Exec Time |
|
||||
|--------------------------------------------------------------------------------------------|
|
||||
"
|
||||
judge_time " configure " "${flag_configure_fail}" "$configure_start_time" "$configure_stop_time"
|
||||
judge_time " make clean " "${flag_makeclean_fail}" "$makeclean_start_time" "$makeclean_stop_time"
|
||||
judge_time " make install " "${flag_makeinstall_fail}" "$makeinstall_start_time" "$makeinstall_stop_time"
|
||||
judge_time " make ${check_mode} " "${flag_makehacheck_fail}" "$makehacheck_start_time" "$makehacheck_stop_time"
|
||||
interval_total_time="$(cal_interval_time $total_start_time $total_stop_time)"
|
||||
echo ----------------------------------------------------------------------------------------------
|
||||
echo "HACHECK TOTAL TIME: $interval_total_time"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
function clean_env
|
||||
{
|
||||
for u in $(echo $g_clean_user|sed 's/,/ /g')
|
||||
do
|
||||
cleanEnv_ipcs $u
|
||||
done
|
||||
|
||||
ps -ef|grep ${g_src_dir}/src/test/ha|grep -v grep|awk '{print $2}'|xargs kill -9 > /dev/null 2>&1
|
||||
# 清理环境
|
||||
rm -rf ${g_src_dir}/src/test/ha/results
|
||||
|
||||
echo 1 > /proc/sys/vm/drop_caches
|
||||
echo 3 > /proc/sys/vm/drop_caches
|
||||
umask 022
|
||||
}
|
||||
|
||||
# main function
|
||||
function main
|
||||
{
|
||||
total_start_time=$(date +%s.%N)
|
||||
|
||||
echo ========================================================================================== | tee -a ${g_log_file}
|
||||
show_env_detail
|
||||
echo | tee -a ${g_log_file}
|
||||
|
||||
echo ========================================================================================== | tee -a ${g_log_file}
|
||||
clean_env 2>&1 | tee -a ${g_log_file}
|
||||
echo | tee -a ${g_log_file}
|
||||
|
||||
echo ========================================================================================== | tee -a ${g_log_file}
|
||||
mk_hacheck
|
||||
if [ $? -ne 0 ]; then
|
||||
error "openGauss" "Fail make hacheck"
|
||||
fi
|
||||
echo | tee -a ${g_log_file}
|
||||
|
||||
total_stop_time=$(date +%s.%N)
|
||||
|
||||
gen_report 2>&1 | tee -a ${g_log_file}
|
||||
|
||||
reportfile="regression.out${check_part}"
|
||||
if [ -f $reportfile ];then
|
||||
cp ${g_src_dir}/src/test/regress/regression.out ${g_src_dir}/src/test/regress/${reportfile}
|
||||
fi
|
||||
|
||||
if [ $g_retrans_enable -eq 1 ]; then
|
||||
transport_info
|
||||
fi
|
||||
|
||||
if [ "${flag_makeinstall_fail}" == 1 ] || [ "${flag_makehacheck_fail}" == 1 ] || [ "${flag_makeclean_fail}" == 1 ];then
|
||||
error "openGauss" "Exit the make hacheck whith error."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 帮助
|
||||
function show_help
|
||||
{
|
||||
echo
|
||||
echo "Usage: `basename $0` [option]"
|
||||
echo "options:"
|
||||
echo "-m Notes: check mode"
|
||||
echo "-p Notes: check part"
|
||||
echo "-c Notes: hdfs_conf_path"
|
||||
echo "-d Notes: top mission build id"
|
||||
echo "-h Notes: help"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo "`basename $0`"
|
||||
echo
|
||||
return 0
|
||||
}
|
||||
|
||||
# 获取入参
|
||||
while getopts "m:p:c:d:h" options;
|
||||
do
|
||||
case ${options} in
|
||||
m) check_mode="${OPTARG}"
|
||||
;;
|
||||
p) check_part="${OPTARG}"
|
||||
;;
|
||||
c) log_file="${OPTARG}"
|
||||
;;
|
||||
d) top_build_id="${OPTARG}"
|
||||
;;
|
||||
h) show_help
|
||||
exit 1
|
||||
;;
|
||||
*) show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$check_mode" ] ; then
|
||||
echo "ERROR: need -m"
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
arch=$(uname -m)
|
||||
|
||||
# 引入配置文件 及 function目录下定义的函数
|
||||
|
||||
g_conf_file=${real_path}/config.ini
|
||||
chmod 644 $g_conf_file
|
||||
source_file
|
||||
|
||||
# 定义日志目录
|
||||
#g_log_dir=${real_path}/log
|
||||
[ -z "${g_cur_build_id}" ] && g_cur_build_id=xx
|
||||
[ -z "${g_top_build_id}" ] && g_top_build_id=xx
|
||||
#g_log_file=${g_log_dir}/opengauss_ID_${g_cur_build_id}_$(date +'%Y%m%d_%H%M%S').log
|
||||
#g_log_file=${g_log_dir}/opengauss_llt_$(printf "%.2d" ${check_part})_$(date +'%Y%m%d_%H%M%S').log
|
||||
g_log_file=${log_file}
|
||||
|
||||
# 当前ip
|
||||
g_agent_ip=$(echo "${SSH_CONNECTION}"|awk '{print $3}')
|
||||
|
||||
# 主程序入口
|
||||
main
|
58
src/test/ha/script/Private_Main_Ha.sh
Normal file
58
src/test/ha/script/Private_Main_Ha.sh
Normal file
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
tools_path=/home/script
|
||||
agent_path=/usr1/gauss_jenkins/jenkins/workspace/openGauss/
|
||||
log_path=/home/log
|
||||
check_nu=$1
|
||||
#################################### create dir and logfile###########################################
|
||||
test -d $log_path && rm -rf $log_path
|
||||
mkdir $log_path
|
||||
g_lltlog_dir=${tools_path}/log
|
||||
g_lltlog_file=${g_lltlog_dir}/makemppdb_llt_$(printf "%.2d" ${check_nu})_$(date +'%Y%m%d_%H%M%S').log
|
||||
mkdir -p ${g_lltlog_dir}
|
||||
#################################### modify config.ini################################################
|
||||
#sed -i "/^g_boot_dir=/c\g_boot_dir=${agent_path}" /home/PrivateBuild_tools/config.ini
|
||||
|
||||
date
|
||||
#################################### merge modify ##################################################
|
||||
# echo merge_modify_start_time=$(date +%s.%N) >> ${g_lltlog_file} 2>&1
|
||||
# sh $tools_path/Private_Get_Modify.sh
|
||||
# if [ $? -ne "0" ];then
|
||||
# printf "Failed to download the personal branch code! Error:\n"
|
||||
# [ -f "${log_path}/pullerror" ] && cat ${log_path}/pullerror
|
||||
# exit 1
|
||||
# fi
|
||||
# date
|
||||
# echo merge_modify_stop_time=$(date +%s.%N) >> ${g_lltlog_file} 2>&1
|
||||
#echo "[`date +'%Y-%m-%d %H:%M:%S'`] [openGauss] INFO: Command: cd ${agent_path} && git submodule init && git submodule update --remote && cd $agent_path/binarylibs && git lfs pull"
|
||||
#cd $agent_path
|
||||
#git submodule init
|
||||
#git submodule update --remote
|
||||
#cd $agent_path/binarylibs
|
||||
#git lfs pull
|
||||
#################################### check llt part ##################################################
|
||||
if [ $check_nu -le 4 ] ; then
|
||||
check_mode='hacheck_single'
|
||||
elif [ $check_nu -le 7 ] ; then
|
||||
check_mode='hacheck_multi_single'
|
||||
check_nu=`expr $check_nu \- 5`
|
||||
else
|
||||
check_mode='hacheck_multi_single_mot'
|
||||
check_nu=`expr $check_nu \- 8`
|
||||
fi
|
||||
|
||||
#################################### do llt job ##################################################
|
||||
echo llt_job_start_time=$(date +%s.%N) >> ${g_lltlog_file} 2>&1
|
||||
# grep '|' $log_path/build_incr_file |grep -v "Test/mppcases_c10" |grep -v "script/script" | awk '{print $1}' > $log_path/incr_file
|
||||
|
||||
# if [ `cat $log_path/incr_file |wc -l` -gt 0 ];then
|
||||
sh $tools_path/Private_LLT_Build_Ha.sh -m $check_mode -p $check_nu -c ${g_lltlog_file}
|
||||
if [ $? -ne "0" ];then
|
||||
printf "Failed to make hacheck! Please check the above logs to see the reason\n"
|
||||
exit 1
|
||||
fi
|
||||
# fi
|
||||
echo llt_job_stop_time=$(date +%s.%N) >> ${g_lltlog_file} 2>&1
|
||||
date
|
||||
|
||||
printf "==================================== Do LLT END ========================================\n"
|
||||
|
63
src/test/ha/script/config.ini
Normal file
63
src/test/ha/script/config.ini
Normal file
@ -0,0 +1,63 @@
|
||||
##########################
|
||||
# global parameters
|
||||
##########################
|
||||
|
||||
# workspace
|
||||
g_boot_dir=/usr1/gauss_jenkins/jenkins/workspace/openGauss
|
||||
|
||||
# user for make fastcheck
|
||||
g_execute_user=tester2
|
||||
|
||||
# pkg type : debug/release
|
||||
g_release_mode=debug
|
||||
|
||||
# code dir
|
||||
g_src_dir=${g_boot_dir}
|
||||
|
||||
# build dir
|
||||
g_build_dir=${g_boot_dir}/install
|
||||
|
||||
# port for fastcheck
|
||||
g_check_port=8798
|
||||
|
||||
# clean user
|
||||
g_clean_user=tester2
|
||||
|
||||
|
||||
##########################
|
||||
# env parameters
|
||||
##########################
|
||||
|
||||
export MPPHOME=${g_boot_dir}/src/test/regress/tmp_check/install/${g_build_dir}
|
||||
export GAUSSHOME=${g_build_dir}
|
||||
export MPPDB_CODE=${g_boot_dir}
|
||||
|
||||
export BINARYLIBS=${g_boot_dir}/binarylibs
|
||||
export CC=${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/gcc/bin/gcc
|
||||
export CXX=${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/gcc/bin/g++
|
||||
export LD_LIBRARY_PATH=${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/gcc/lib64\
|
||||
:${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/isl/lib\
|
||||
:${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/mpc/lib\
|
||||
:${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/mpfr/lib\
|
||||
:${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/gmp/lib\
|
||||
:${g_build_dir}/lib\
|
||||
:$LD_LIBRARY_PATH
|
||||
export PATH=${BINARYLIBS}/buildtools/centos7.6_x86_64/gcc8.2/gcc/bin\
|
||||
:${g_build_dir}/bin\
|
||||
:$PATH
|
||||
|
||||
# LANG
|
||||
LANG="en_US.UTF-8"
|
||||
SYSFONT="latarcyrheb-sun16"
|
||||
|
||||
##########################
|
||||
# 回传
|
||||
##########################
|
||||
|
||||
g_retrans_enable=0
|
||||
g_master_ip=0.0.0.0
|
||||
g_master_user=root
|
||||
g_master_password=TestPwd@123
|
||||
g_master_log_path=/home/mpp/log_fastcheck
|
||||
g_top_build_id=${BUILD_TOP_ID}
|
||||
g_cur_build_id=${BUILD_ID}
|
159
src/test/ha/script/function/01.log.sh
Normal file
159
src/test/ha/script/function/01.log.sh
Normal file
@ -0,0 +1,159 @@
|
||||
|
||||
###################################################
|
||||
# 把内容写入日志文件
|
||||
###################################################
|
||||
function _write_logfile()
|
||||
{
|
||||
# g_log_file 为空,则默认设置为 /tmp/fi-preinstall.log
|
||||
if [ -z "$g_log_file" ]; then
|
||||
echo "ERROR: need global parameter g_log_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#如果日志文件已经产生,可以直接写入(绝大部分情况符合此场景)
|
||||
if [ -f "${g_log_file}" ]; then
|
||||
echo "$*" >> "${g_log_file}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
#日志文件不存在,日志文件所在的目录已经存在,可以直接写入
|
||||
if [ -d "$(dirname ${g_log_file})" ]; then
|
||||
echo "$*" >> "${g_log_file}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
#日志文件所在的目录不存在
|
||||
mkdir -p "$(dirname ${g_log_file})" > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
#目录创建成功,可以写入日志
|
||||
echo "$*" >> "${g_log_file}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 检查日志文件的权限
|
||||
###################################################
|
||||
function check_logfile()
|
||||
{
|
||||
# g_log_file 为空,则默认设置为 /tmp/fi-preinstall.log
|
||||
if [ -z "$g_log_file" ]; then
|
||||
g_log_file="./log_privateBuildCheck"
|
||||
fi
|
||||
|
||||
if [ ! -e "${g_log_file}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
#如果日志文件已经产生,可以直接写入(绝大部分情况符合此场景)
|
||||
if [ -f "${g_log_file}" -a -r "${g_log_file}" -a -w "${g_log_file}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
#日志文件存在且没有可写权限,返回失败
|
||||
echo -e "\033[31mERROR: ${g_log_file}: Permission denied, Please check your permission or clean /tmp/fi-preinstall.log and /tmp/diskmgt/\033[0m"
|
||||
return 1
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 记录错误日志
|
||||
###################################################
|
||||
function error()
|
||||
{
|
||||
if [ $# -lt 2 ] ;then
|
||||
echo "ERROR: error function need at least 2 parameter !!!"
|
||||
exit 1
|
||||
fi
|
||||
module="$1"
|
||||
shift
|
||||
msg="[$(date '+%Y-%m-%d %T')] [${module}] ERROR: $@"
|
||||
# 在界面上输出
|
||||
echo -e "\033[31m${msg}\033[0m"
|
||||
|
||||
# 记录日志
|
||||
_write_logfile "${msg}"
|
||||
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 记录警告日志
|
||||
###################################################
|
||||
function warn()
|
||||
{
|
||||
if [ $# -lt 2 ] ;then
|
||||
echo "ERROR: warn function need at least 2 parameter !!!"
|
||||
exit 1
|
||||
fi
|
||||
module="$1"
|
||||
shift
|
||||
msg="[$(date '+%Y-%m-%d %T')] [${module}] WARNING: $@"
|
||||
# 在界面上输出
|
||||
echo -e "\033[33m${msg}\033[0m"
|
||||
|
||||
# 记录日志
|
||||
_write_logfile "${msg}"
|
||||
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 记录提示日志
|
||||
###################################################
|
||||
function log()
|
||||
{
|
||||
if [ $# -lt 2 ] ;then
|
||||
echo "ERROR: log function need at least 2 parameter !!!"
|
||||
exit 1
|
||||
fi
|
||||
module="$1"
|
||||
shift
|
||||
msg="[$(date '+%Y-%m-%d %T')] [${module}] INFO: $@"
|
||||
# 在界面上输出
|
||||
echo "${msg}"
|
||||
|
||||
# 记录日志
|
||||
_write_logfile "${msg}"
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 记录一般日志(不往界面输出)
|
||||
###################################################
|
||||
function info()
|
||||
{
|
||||
if [ $# -lt 2 ] ;then
|
||||
echo "ERROR: log function need at least 2 parameter !!!"
|
||||
exit 1
|
||||
fi
|
||||
module="$1"
|
||||
shift
|
||||
msg="[$(date '+%Y-%m-%d %T')] [${module}] INFO: $@"
|
||||
|
||||
# 记录日志
|
||||
_write_logfile "${msg}"
|
||||
}
|
||||
|
||||
###################################################
|
||||
# 记录debug(不往界面输出)
|
||||
###################################################
|
||||
function debug()
|
||||
{
|
||||
#如果 g_debug 没有定义,则直接返回
|
||||
if [ -z "${g_debug}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ] ;then
|
||||
echo "ERROR: debug function need at least 2 parameter !!!"
|
||||
exit 1
|
||||
fi
|
||||
module="$1"
|
||||
shift
|
||||
msg="[$(date '+%Y-%m-%d %T')] [${module}] DEBUG: $@"
|
||||
|
||||
# 记录日志
|
||||
if [ "${g_debug}" -eq 1 ]; then
|
||||
_write_logfile "${msg}"
|
||||
fi
|
||||
}
|
||||
|
35
src/test/ha/script/function/02.cleanEnv_ipcs.sh
Normal file
35
src/test/ha/script/function/02.cleanEnv_ipcs.sh
Normal file
@ -0,0 +1,35 @@
|
||||
# 清理环境--消息队列、共享内存、信号量
|
||||
function cleanEnv_ipcs
|
||||
{
|
||||
user=$1
|
||||
|
||||
if [ -z $user ] ;then
|
||||
echo -e "\033[31m[CleanEnv--ipcs] ERROR: Need 1 parameter !!!\033[0m"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "[CleanEnv--ipcs] `date \"+%Y-%m-%d %T\"` START"
|
||||
|
||||
# 清理消息队列
|
||||
echo ' Removing "Q(message queues)" created by "'$user'" ...'
|
||||
ipcs -q|grep "\b${user}\b"|awk '{print $2}'|xargs -t -I {} ipcrm -q {}
|
||||
|
||||
# 清理共享内存
|
||||
echo ' Removing "M(shared memory segments)" created by "'$user'" ...'
|
||||
ipcs -m|grep "\b${user}\b"|awk '{print $2}'|xargs -t -I {} ipcrm -m {}
|
||||
|
||||
# 清理信号量
|
||||
echo ' Removing "S(semaphore arrays)" created by "'$user'" ...'
|
||||
ipcs -s|grep "\b${user}\b"|awk '{print $2}'|xargs -t -I {} ipcrm -s {}
|
||||
|
||||
# 检查清理结果
|
||||
res="$(ipcs -qms|grep "\btester1\b\|key\|----")"
|
||||
if [ $(printf "%s\n" "$res"|wc -l) -eq 6 ] ; then
|
||||
echo "[CleanEnv--ipcs] `date \"+%Y-%m-%d %T\"` SUCCESS !!!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\033[31m[CleanEnv--ipcs] `date \"+%Y-%m-%d %T\"` FAIL!!!\033[0m"
|
||||
printf "%s\n" "$res"
|
||||
return 1
|
||||
fi
|
||||
}
|
21
src/test/ha/script/function/03.get_osname.sh
Normal file
21
src/test/ha/script/function/03.get_osname.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#获取系统版本
|
||||
function get_osname
|
||||
{
|
||||
rhel_release="/etc/redhat-release"
|
||||
sles_release="/etc/SuSE-release"
|
||||
#获取RedHat的版本
|
||||
if [ -f "${rhel_release}" ]; then
|
||||
name="redhat-$(cat "${rhel_release}" | awk '{print $7}')"
|
||||
fi
|
||||
#获取SuSE的版本
|
||||
if [ -f "${sles_release}" ]; then
|
||||
name="suse-$(cat "${sles_release}" | grep "^VERSION" | awk '{print $3}')"
|
||||
name="${name}.$(cat "${sles_release}" | grep "^PATCHLEVEL" | awk '{print $3}')"
|
||||
fi
|
||||
#获取openEuler的版本
|
||||
if [ -f "/etc/openEuler-release" ]; then
|
||||
name=$(cat /etc/openEuler-release | awk -F ' ' '{print $1}' | tr A-Z a-z)
|
||||
fi
|
||||
echo $name
|
||||
}
|
||||
|
193
src/test/ha/script/function/remote.sh
Normal file
193
src/test/ha/script/function/remote.sh
Normal file
@ -0,0 +1,193 @@
|
||||
#!/bin/sh
|
||||
# \
|
||||
exec expect -- "$0" ${1+"$@"}
|
||||
|
||||
###################################################
|
||||
# 用法: 脚本名 -i IP.地址 -p 密码 -t 超时时间 -m 命令模式 -c 具体命令
|
||||
###################################################
|
||||
# 功能描述:
|
||||
# 1:在远端的服务器上执行命令(使用-m ssh-cmd);
|
||||
# 2:把本地文件拷贝至远端服务器(使用-m scp-out);
|
||||
# 备注:如果远端没有scp命令,需要使用cat+ssh
|
||||
# 把本地文件拷贝至远端服务器
|
||||
# 3:把远端文件拷贝至本地(使用-m scp-in);
|
||||
# 4:对于建立互信的环境可以不使用-p参数设置密码;
|
||||
# 5:默认的用户名为root
|
||||
# 6:默认的端口号为22
|
||||
# 7:默认的脚本超时时间为120秒
|
||||
# 8:执行结果以标准输出的形式输出
|
||||
# 9:密码或用户名错误返回128
|
||||
# 10:超时返回129
|
||||
###################################################
|
||||
|
||||
#设置默认值
|
||||
set port 22
|
||||
set user "root"
|
||||
set timeout 120
|
||||
set password ""
|
||||
set host ""
|
||||
set mode ""
|
||||
set command ""
|
||||
set src ""
|
||||
set dst ""
|
||||
|
||||
set key "$env(g_aes_rand_key)"
|
||||
|
||||
###############################################
|
||||
# 显示帮助信息
|
||||
###############################################
|
||||
proc help {} {
|
||||
global argv0
|
||||
send_user "usage: $argv0\n"
|
||||
send_user " -i <ip> Host or IP\n"
|
||||
send_user " -P <port> Port. Default = 22\n"
|
||||
send_user " -u <user> UserName. Default = root\n"
|
||||
send_user " -p <password> Password.\n"
|
||||
send_user " -t <timeout> Timeout. Default = 120\n"
|
||||
send_user " -m <mode> Mode. include: ssh-cmd, scp-out, scp-in\n"
|
||||
send_user " -c <command> Ssh Command\n"
|
||||
send_user " -s <src> Scp Source File\n"
|
||||
send_user " -d <dst> Scp Destination File\n"
|
||||
send_user " -a <aes-file> Use aes encrypt passwd\n"
|
||||
send_user " -v Version\n"
|
||||
send_user " -h Help\n"
|
||||
send_user "Sample:\n"
|
||||
send_user "$argv0 -i 0.0.0.0 -p pass -t 5 -m ssh-cmd -c ifconfig\n"
|
||||
send_user "$argv0 -i 0.0.0.0 -p pass -m scp-out -s /etc/passwd -d /tmp/passwd\n"
|
||||
}
|
||||
|
||||
###############################################
|
||||
# 输出错误日志
|
||||
###############################################
|
||||
proc errlog {errmsg h code} {
|
||||
global host
|
||||
send_user "Error: $errmsg on $host (${code}) \n"
|
||||
if {[string compare "$h" "yes"] == 0} {
|
||||
help
|
||||
}
|
||||
exit $code
|
||||
}
|
||||
|
||||
#参数个数不能为0
|
||||
if {[llength $argv] == 0} {
|
||||
errlog "argv is null" "yes" "1"
|
||||
}
|
||||
|
||||
#参数解析
|
||||
while {[llength $argv]>0} {
|
||||
set flag [lindex $argv 0]
|
||||
switch -- $flag "-i" {
|
||||
set host [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-P" {
|
||||
set port [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-u" {
|
||||
set user [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-p" {
|
||||
set password [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-t" {
|
||||
set timeout [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-m" {
|
||||
set mode [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-c" {
|
||||
set command [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-s" {
|
||||
set src [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-d" {
|
||||
set dst [lindex $argv 1]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-a" {
|
||||
set password [ exec openssl enc -aes-256-cbc -salt -a -d -k "$key" -in [lindex $argv 1] 2> /dev/null ]
|
||||
set argv [lrange $argv 2 end]
|
||||
} "-v" {
|
||||
send_user "Ver: 1.0\n"
|
||||
exit 0
|
||||
} "-h" {
|
||||
help
|
||||
exit 0
|
||||
} default {
|
||||
set user [lindex $argv 0]
|
||||
set argv [lrange $argv 1 end]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
#主机名或IP为空
|
||||
if {"$host" == ""} {
|
||||
errlog "host is null" "yes" "1"
|
||||
}
|
||||
|
||||
#执行命令
|
||||
if {[string compare "$mode" "ssh-cmd"] == 0} {
|
||||
if {"$command" == ""} {
|
||||
errlog "command is null" "yes" "1"
|
||||
}
|
||||
spawn ssh -oServerAliveInterval=60 -oStrictHostKeyChecking=no -oVerifyHostKeyDNS=yes -oUserKnownHostsFile=/dev/null -t -p $port $user@$host "$command"
|
||||
} elseif {[string compare "$mode" "scp-out"] == 0} {
|
||||
if {"$src" == "" || "$dst" == ""} {
|
||||
errlog "src or dst is null" "yes" "1"
|
||||
}
|
||||
spawn scp -r -oServerAliveInterval=60 -oStrictHostKeyChecking=no -oVerifyHostKeyDNS=yes -oUserKnownHostsFile=/dev/null -P $port $src $user@$host:$dst
|
||||
} elseif {[string compare "$mode" "scp-in"] == 0} {
|
||||
if {"$src" == "" || "$dst" == ""} {
|
||||
errlog "src or dst is null" "yes" "1"
|
||||
}
|
||||
spawn scp -r -oServerAliveInterval=60 -oStrictHostKeyChecking=no -oVerifyHostKeyDNS=yes -oUserKnownHostsFile=/dev/null -P $port $user@$host:$src $dst
|
||||
} else {
|
||||
errlog "mode($mode) invalid" "yes" "1"
|
||||
}
|
||||
|
||||
#命令执行结果
|
||||
expect {
|
||||
-nocase -re "please try again" {
|
||||
errlog "Bad Password/UserName, Or Account locked" "no" "128"
|
||||
}
|
||||
-nocase -re "password" {
|
||||
send "$password\r"
|
||||
exp_continue
|
||||
}
|
||||
timeout {
|
||||
errlog "Executing timeout" "no" "129"
|
||||
}
|
||||
}
|
||||
|
||||
#获取命令执行结果
|
||||
catch wait result
|
||||
set ret [lindex $result 3]
|
||||
if { $ret != 0 } {
|
||||
#如有远端没有scp命令的话,scp会失败的,此时需要使用cat+ssh的方法拷贝数据
|
||||
#暂不考虑从远端拷贝数据至本地,且远端无scp的场景
|
||||
if {$ret == 1 && [string compare "$mode" "scp-out"] == 0} {
|
||||
spawn /bin/sh -c "cat $src | ssh -oServerAliveInterval=60 -oStrictHostKeyChecking=no -oVerifyHostKeyDNS=yes -oUserKnownHostsFile=/dev/null -t -p $port $user@$host 'cat > $dst'"
|
||||
#命令执行结果
|
||||
expect {
|
||||
-nocase -re "please try again" {
|
||||
errlog "Bad Password/UserName, Or Account locked" "no" "128"
|
||||
}
|
||||
-nocase -re "password" {
|
||||
send "$password\r"
|
||||
exp_continue
|
||||
}
|
||||
timeout {
|
||||
errlog "Executing timeout" "no" "129"
|
||||
}
|
||||
}
|
||||
|
||||
#获取命令执行结果
|
||||
catch wait result
|
||||
set ret [lindex $result 3]
|
||||
if { $ret == 0 } {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
errlog "Execute failed" "no" "$ret"
|
||||
}
|
||||
exit $ret
|
||||
|
Reference in New Issue
Block a user