Merge pull request !3334 from 陈志凯/master
This commit is contained in:
opengauss-bot
2023-04-13 06:40:23 +00:00
committed by Gitee
7 changed files with 691 additions and 24 deletions

View File

@ -1020,7 +1020,7 @@ static void InitStorageConfigureNamesBool()
NULL},
{{"ss_enable_aio",
PGC_SIGHUP,
PGC_POSTMASTER,
NODE_SINGLENODE,
SHARED_STORAGE_OPTIONS,
gettext_noop("Whether use dss aio"),
@ -1029,7 +1029,7 @@ static void InitStorageConfigureNamesBool()
&g_instance.attr.attr_storage.dms_attr.enable_dss_aio,
true,
NULL,
assign_ss_enable_aio,
NULL,
NULL},
#ifdef USE_ASSERT_CHECKING
@ -5879,11 +5879,6 @@ static bool check_ss_enable_ssl(bool *newval, void **extra, GucSource source)
return true;
}
static void assign_ss_enable_aio(bool newval, void *extra)
{
g_instance.attr.attr_storage.dms_attr.enable_dss_aio = newval;
}
#ifdef USE_ASSERT_CHECKING
static void assign_ss_enable_verify_page(bool newval, void *extra)
{

View File

@ -1,2 +1,2 @@
dms_commit_id=22f2e5803caca648071ab2c7398bee4e177c8487
dss_commit_id=7084d251cc53bdae2973c146bb394d1913d6ddab
dms_commit_id=541342d6830864702b700b91f041596c1f8aeb01
dss_commit_id=0624291f4495300ada7375b57b49ff33be84f1b2

View File

@ -4785,7 +4785,7 @@ void FlushBuffer(void *buf, SMgrRelation reln, ReadBufferMethod flushmethod, boo
SegFlushCheckDiskLSN(spc, fakenode, bufferinfo.blockinfo.forknum, bufdesc->extra->seg_blockno, bufToWrite);
#endif
if (ENABLE_DMS && t_thrd.role == PAGEWRITER_THREAD && ENABLE_DSS_AIO) {
if (ENABLE_DMS && (t_thrd.role == PAGEWRITER_THREAD) && ENABLE_DSS_AIO) {
int thread_id = t_thrd.pagewriter_cxt.pagewriter_id;
PageWriterProc *pgwr = &g_instance.ckpt_cxt_ctl->pgwr_procs.writer_proc[thread_id];
DSSAioCxt *aio_cxt = &pgwr->aio_cxt;

View File

@ -818,7 +818,7 @@ typedef struct st_logger_param {
#define DMS_LOCAL_MINOR_VER_WEIGHT 1000
#define DMS_LOCAL_MAJOR_VERSION 0
#define DMS_LOCAL_MINOR_VERSION 0
#define DMS_LOCAL_VERSION 58
#define DMS_LOCAL_VERSION 59
#ifdef __cplusplus
}

View File

@ -56,11 +56,15 @@ assign_hatest_parameter()
{
for node in $@
do
echo -e "\nss_enable_reform = on" >> ${node}/postgresql.conf
echo -e "\nlog_min_messages = log" >> ${node}/postgresql.conf
echo -e "\nlogging_module = 'on(ALL)'" >> ${node}/postgresql.conf
echo "${node}:"
cat ${node}/postgresql.conf | grep ss_enable_dms
echo -e "ss_enable_reform = on" >> ${node}/postgresql.conf
echo -e "log_min_messages = log" >> ${node}/postgresql.conf
echo -e "logging_module = 'on(ALL)'" >> ${node}/postgresql.conf
echo -e "ss_log_level = 255" >> ${node}/postgresql.conf
echo -e "ss_log_backup_file_count = 100" >> ${node}/postgresql.conf
echo -e "ss_log_max_file_size = 1024MB" >> ${node}/postgresql.conf
echo -e "enable_bbox_dump = on" >> ${node}/postgresql.conf
cat ${node}/postgresql.conf | grep enable_bbox_dump
done
}

View File

@ -1,7 +1,7 @@
CURPATH=$(dirname $(readlink -f $0))
echo "check env var"
if [ ${GAUSSHOME} ] && [ -d ${GAUSSHOME}/bin ];then
echo "GAUSSHOME :${GAUSSHOME}"
echo "GAUSSHOME: ${GAUSSHOME}"
else
echo "GAUSSHOME NOT EXIST"
exit 1;
@ -18,6 +18,11 @@ PGPORT=(6600 6700)
SS_DATA=${HOME}/ss_hatest
nodedata_cfg="0:127.0.0.1:6611,1:127.0.0.1:6711"
export CM_CONFIG_PATH=${CURPATH}/cm_config.ini
export TPCC_PATH=~/benchmarksql/run
TPCC_P=("0-primary.gs" "1-primary.gs" "2-primary.gs")
TPCC_S=("0-standby.gs" "1-standby.gs" "2-standby.gs")
GAUSSLOG_TMP=("${SS_DATA}/gausslog0" "${SS_DATA}/gausslog1" "${SS_DATA}/gausslog2")
declare -a NEXT_REFORMER_ID
function ha_test_init()
{
@ -78,7 +83,7 @@ function function_leave()
function db_shutdown
{
print "shutdown node$1"
print "shutdown node $1"
${BIN_PATH}/gsql -d postgres -p ${PGPORT[$1]} -c "shutdown;"
pid=`ps ux|grep gaussdb|grep ${DB_HOME[$1]}|grep -v grep`
@ -92,7 +97,7 @@ function db_shutdown
function db_kill
{
print "kill node $1"
ps ux | grep gaussdb | grep ${DB_HOME[$1]} | grep -v grep |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
ps ux | grep gaussdb | grep ${DB_HOME[$1]} | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
pid=`ps ux | grep gaussdb | grep ${DB_HOME[$1]} | grep -v grep`
while [[ ! -z $pid ]]; do
sleep 1
@ -104,7 +109,10 @@ function db_kill
function db_start
{
print "node $1 start"
export GAUSSLOG=${GAUSSLOG_TMP[$1]}
print "export GAUSSLOG=${GAUSSLOG_TMP[$1]}"
${BIN_PATH}/gaussdb -D ${DB_HOME[$1]} > /dev/null 2>&1 &
print "${BIN_PATH}/gaussdb -D ${DB_HOME[$1]} > /dev/null 2>&1 &"
}
function db_start_wait
@ -224,7 +232,7 @@ function failover_restart
sh ${CURPATH}/cm_ctl.sh set REFORMER_ID 1
db_start 1
sleep 20
db_start_wait 1
db_start_wait 1
db_role_get 1
db_role_check 1 Primary
@ -233,7 +241,7 @@ function failover_restart
db_start_wait 0
db_role_get 0
db_role_check 0 Standby
switchover 0
switchover 0
function_leave
}
@ -271,13 +279,13 @@ function deploy_two_inst
source ${CURPATH}/build_ss_database_common.sh
kill_gaussdb
clean_database_env ${SS_DATA}
sh ${CURPATH}/conf_start_dss_inst.sh 2 ${SS_DATA} ${SS_DATA}/dss_disk
sh ${CURPATH}/conf_start_dss_inst.sh 2 ${SS_DATA} ${SS_DATA}/dss_disk
init_gaussdb 0 ${SS_DATA}/dss_home0 $SS_DATA $nodedata_cfg
init_gaussdb 1 ${SS_DATA}/dss_home1 $SS_DATA $nodedata_cfg
set_gaussdb_port ${SS_DATA}/dn0 ${PGPORT[0]}
set_gaussdb_port ${SS_DATA}/dn1 ${PGPORT[1]}
set_gaussdb_port ${SS_DATA}/dn1 ${PGPORT[1]}
assign_hatest_parameter ${SS_DATA}/dn0 ${SS_DATA}/dn1
@ -307,8 +315,211 @@ function check_user()
fi
}
function create_user_tpcc()
{
gsql -d postgres -p ${PGPORT} -c "create user tpcc with password \"Huawei@123\"; grant all privileges to tpcc;"
}
function runDatabaseBuild()
{
NODE_IDX=$1
cd ${TPCC_PATH}
sh runDatabaseBuild.sh ${TPCC_P[$NODE_IDX]}
print "sh runDatabaseBuild.sh ${TPCC_P[$NODE_IDX]}"
}
function runbenchmark()
{
is_primary=$1
NODE_IDX=$2
cd ${TPCC_PATH}
if [[ $is_primary = "Primary" ]]; then
print "runbenchmark Primary $NODE_IDX"
sh runBenchmark.sh ${TPCC_P[$NODE_IDX]} > /dev/null 2>&1 &
else
print "runbenchmark Standby $NODE_IDX"
sh runBenchmark.sh ${TPCC_S[$NODE_IDX]} > /dev/null 2>&1 &
fi
}
function tpcc_init()
{
create_user_tpcc
runDatabaseBuild 0
}
function restart_primary_tpcc()
{
function_enter
runbenchmark Primary 0
runbenchmark Standby 1
sleep 60
db_kill 0
db_start 0
sleep 30
db_start_wait 0
function_leave
}
function function_enter_failover()
{
echo ""
print "===================TestCaseBegin:${FUNCNAME[1]}====================="
}
function function_leave_failover()
{
print "===================TestCaseEnd:${FUNCNAME[1]}====================="
}
function kick_node_offline()
{
NODE_MASK=3
NODE_ID=$1
db_kill $NODE_ID
NEXT_REFORMER_ID=$(( (${NODE_ID} + 1)%2 ))
NEXT_BITMAP_ONLINE=$(( ~(1 << ${NODE_ID}) & $NODE_MASK ))
sh ${CURPATH}/cm_ctl.sh set BITMAP_ONLINE $NEXT_BITMAP_ONLINE
sh ${CURPATH}/cm_ctl.sh set REFORMER_ID $NEXT_REFORMER_ID
print "node$NODE_ID is kick off , node:${NEXT_REFORMER_ID} will become reformer, bitmap_online:$NEXT_BITMAP_ONLINE"
}
function kick_node_online()
{
NODE_MASK=3
NODE_ID=$1
db_kill $NODE_ID
NEXT_REFORMER_ID=$(( (${NODE_ID} + 1)%2 ))
sh ${CURPATH}/cm_ctl.sh set REFORMER_ID $NEXT_REFORMER_ID
db_start $NODE_ID
print "node$NODE_ID is kick off , node:${NEXT_REFORMER_ID} will become reformer, bitmap_online:$NEXT_BITMAP_ONLINE"
}
function failover_alive_tpcc_old_offline()
{
function_enter_failover
db_start_wait 0
db_start_wait 1
db_role_get 0
db_role_get 1
for (( i=0;i<${#DB_ROLE[@]};i++ ))
do
if [ ${DB_ROLE[$i]} = 'Primary' ]; then
runbenchmark Primary $i
PRIMARY_ID=$i
else
runbenchmark Standby $i
fi
done
sleep 120
kick_node_offline $PRIMARY_ID
DELETED_ID=$PRIMARY_ID
pid=`ps ux | grep gaussdb | grep ${DB_HOME[$NEXT_REFORMER_ID]} | grep -v grep`
wait_time=0
while [[ ! -z $pid ]]; do
sleep 20
db_role_get $NEXT_REFORMER_ID
if [[ ${DB_ROLE[$NEXT_REFORMER_ID]} == 'Primary' ]] || [[ ${DB_ROLE[$NEXT_REFORMER_ID]} == 'Standby' ]]; then
break;
fi
wait_time=`expr ${wait_time} + 20`
if [ ${wait_time} -gt 1200 ]; then
print "failover wait too long."
exit 0
fi
pid=`ps ux | grep gaussdb | grep ${DB_HOME[$NEXT_REFORMER_ID]} | grep -v grep`
done
if [[ -z $pid ]]; then
print "failover failed, maybe caused by backend cannot exit, please check"
db_start $NEXT_REFORMER_ID
fi
db_start_wait $NEXT_REFORMER_ID
db_role_get $NEXT_REFORMER_ID
db_role_check $NEXT_REFORMER_ID Primary
db_start $DELETED_ID
sh ${CURPATH}/cm_ctl.sh set BITMAP_ONLINE 3
db_start_wait $DELETED_ID
db_role_get $DELETED_ID
db_role_check $DELETED_ID Standby
function_leave_failover
}
function failover_alive_tpcc_old_online()
{
function_enter_failover
db_start_wait 0
db_start_wait 1
db_role_get 0
db_role_get 1
for (( i=0;i<${#DB_ROLE[@]};i++ ))
do
if [ ${DB_ROLE[$i]} = 'Primary' ]; then
runbenchmark Primary $i
PRIMARY_ID=$i
else
runbenchmark Standby $i
fi
done
sleep 120
kick_node_online $PRIMARY_ID
DELETED_ID=$PRIMARY_ID
pid=`ps ux | grep gaussdb | grep ${DB_HOME[$NEXT_REFORMER_ID]} | grep -v grep`
wait_time=0
while [[ ! -z $pid ]]; do
sleep 20
db_role_get $NEXT_REFORMER_ID
if [[ ${DB_ROLE[$NEXT_REFORMER_ID]} == 'Primary' ]] || [[ ${DB_ROLE[$NEXT_REFORMER_ID]} == 'Standby' ]]; then
break;
fi
wait_time=`expr ${wait_time} + 20`
if [ ${wait_time} -gt 1200 ]; then
print "failover wait too long."
exit 0
fi
pid=`ps ux | grep gaussdb | grep ${DB_HOME[$NEXT_REFORMER_ID]} | grep -v grep`
done
if [[ -z $pid ]]; then
print "failover failed, maybe caused by backend cannot exit, please check"
db_start $NEXT_REFORMER_ID
fi
db_start_wait $DELETED_ID
db_role_get $DELETED_ID
db_role_check $DELETED_ID Standby
db_start_wait $NEXT_REFORMER_ID
db_role_get $NEXT_REFORMER_ID
db_role_check $NEXT_REFORMER_ID Primary
function_leave_failover
}
function muti_execute()
{
times=$1
for(( time=0;time<$times;time++ ))
do
print "=====times:$time===="
## run function
$2
done
}
check_user
deploy_two_inst
ha_test_init
testcase
## if you want use tpcc
#tpcc_init
#muti_execute 10 restart_primary_tpcc
#muti_execute 10 failover_alive_tpcc_old_offline
#muti_execute 10 failover_alive_tpcc_old_online
exit 0

457
src/test/ss/ha_test_cm.sh Normal file
View File

@ -0,0 +1,457 @@
#!/bin/sh
##need set
IPS=$1
ENVFILE_FILE=$2
TPCC_PATH=/data3/script/benchmarksql/run
TPCC_P=("0-primary.gs" "1-primary.gs" "2-primary.gs")
TPCC_S=("0-standby.gs" "1-standby.gs" "2-standby.gs")
##no need set
CURPATH=$(dirname $(readlink -f $0))
OUTPUT_LOG=${CURPATH}/results/run_cm.log
IPS_ARR=()
NODE_ID=()
ID_ARR=()
DB_ROLE=()
declare DB_CONFIG_HOME
declare REFORMER_LOCK_STR
declare PGPORT
declare NODE_NUM
declare cluster_ready
PRIMARY_ID=-1
PROMOTE_ID=-1
DELETED_ID=-1
REFORMER_ID=-1
function print
{
echo `date "+[%Y-%m-%d %H:%M:%S] $1."`
echo `date "+[%Y-%m-%d %H:%M:%S] $1."` >> ${OUTPUT_LOG}
}
reset_global_variable()
{
PRIMARY_ID=-1
PROMOTE_ID=-1
DELETED_ID=-1
REFORMER_ID=-1
}
function get_port()
{
res=`cm_ctl query -Cvd`
for out in $res
do
result=$(echo $out | grep -w dn1)
if [[ $result != '' ]]; then
DB_CONFIG_HOME=$result
break
fi
done
config_file=${DB_CONFIG_HOME}/postgresql.conf
PGPORT=`cat $config_file | grep -w "port =" | awk '{print $3}'`
}
function get_reformer_lock_str()
{
res=`cm_ctl ddb --get / --prefix`
for out in $res
do
result=$(echo $out | grep -w dms_reformer_lock)
if [[ $result != '' ]]; then
REFORMER_LOCK_STR=$result
break
fi
done
}
function init_global_variable()
{
echo "" > $OUTPUT_LOG
source $ENVFILE_FILE
i=0
for ip in $IPS
do
IPS_ARR[$i]=$ip
i=`expr $i + 1`
done
NODE_NUM=$i
DMS_ID_BASE=6001
for(( i=0;i<${#IPS_ARR[@]};i++ ))
do
NODE_ID[i]=`expr $i + 1`
ID_ARR[i]=`expr $i + $DMS_ID_BASE`
DB_ROLE[i]='unknown'
done
get_reformer_lock_str
get_port
rm -rf ${CURPATH}/results
mkdir -p ${CURPATH}/results
touch ${CURPATH}/results/run_cm.log
print_global_variable
}
function print_global_variable()
{
print "ENVFILE_FILE:$ENVFILE_FILE"
for(( i=0;i<${#IPS_ARR[@]};i++ ))
do
print "IPS[$i]:${IPS_ARR[$i]}"
done
for(( i=0;i<${#IPS_ARR[@]};i++ ))
do
print "NODE_ID[$i]:${NODE_ID[$i]}"
done
print "REFORMER_LOCK_STR:$REFORMER_LOCK_STR"
print "PGPORT:$PGPORT"
}
function scan_role()
{
for(( i=0;i<${#DB_ROLE[@]};i++ ))
do
echo ${DB_ROLE[$i]}
done
}
function get_reformer()
{
DMS_ID=`cm_ctl ddb --get $REFORMER_LOCK_STR | grep 60 | awk '{print $2}'`
if [[ $DMS_ID == '' ]];then
echo "get reformer error"
fi
REFORMER_ID=`expr $DMS_ID - 6001`
print "NODE_ID:$REFORMER_ID got reformer lock"
}
function kick()
{
#cmd=`ssh $USER@${IPS_ARR[$PRIMARY_ID]} "source $ENVFILE_FILE && cm_ctl stop -n ${NODE_ID[$PRIMARY_ID]} -I ${ID_ARR[$PRIMARY_ID]}"`
NODE_IDX=$1
cmd=`cm_ctl stop -n ${NODE_ID[NODE_IDX]} -I ${ID_ARR[NODE_IDX]}`
print "cm_ctl stop -n ${NODE_ID[NODE_IDX]} -I ${ID_ARR[NODE_IDX]}"
DELETED_ID=$NODE_IDX
}
function db_start()
{
NODE_IDX=$1
#cmd=`ssh $USER@${IPS_ARR[$PRIMARY_ID]} "source $ENVFILE_FILE && cm_ctl start -n ${NODE_ID[$NODE_IDX]}"`
cmd=`cm_ctl start -n ${NODE_ID[$NODE_IDX]}`
}
function db_kill()
{
DB_CONFIG_HOME=$1
ps ux | grep gaussdb | grep ${DB_CONFIG_HOME} | grep -v grep | awk '{print $2}' |xargs kill -9 > /dev/null 2>&1
pid=`ps ux | grep gaussdb | grep ${DB_CONFIG_HOME} | grep -v grep`
while [[ ! -z $pid ]]; do
sleep 1
pid=`ps ux | grep gaussdb | grep ${DB_CONFIG_HOME} | grep -v grep`
done
sleep 1
}
function ssh_db_kill()
{
print "kill node $1"
NODE_IDX=$1
ssh $USER@${IPS_ARR[$NODE_IDX]} "$(typeset -f db_kill);db_kill $DB_CONFIG_HOME"
}
function create_user()
{
gsql -d postgres -p ${PGPORT} -c "create user hatest with password \"Huawei@123\"; grant all privileges to hatest;"
}
function db_role_get_allnode()
{
for(( i=0;i<$NODE_NUM;i++ ))
do
role=`timeout 10 gsql -d postgres -p ${PGPORT} -U hatest -W "Huawei@123" -c "select local_role from pg_stat_get_stream_replications();" -h ${IPS_ARR[$i]} | grep -E 'Primary|Standby' | sed s/[[:space:]]//g`
echo "role: $role"
if [ $role = "" ]; then
cluster_ready=0
return
fi
if [ $role = "Primary" ]; then
PRIMARY_ID=$i
fi
DB_ROLE[$i]=$role
echo "DB_ROLE $i:${DB_ROLE[$i]}"
done
cluster_ready=1
}
function db_wait_all_node_ready()
{
while true
do
db_role_get_allnode
if (( $cluster_ready == 1)); then
break;
fi
done
}
function db_role_get()
{
NODE_IDX=$1
DB_ROLE[$1]=`timeout 5 gsql -d postgres -p ${PGPORT} -U hatest -W "Huawei@123" -c "select local_role from pg_stat_get_stream_replications();" -h ${IPS_ARR[$NODE_IDX]} | grep -E 'Primary|Standby' | sed s/[[:space:]]//g`
}
function db_role_check()
{
role_result="${DB_ROLE[$1]}"
role_expect="$2"
if [ "$role_result" != "$role_expect" ]; then
print "node $1 role check fail, should be $role_expect, but $role_result"
exit 1
fi
}
function function_enter()
{
echo ""
print "===================TestCaseBegin:${FUNCNAME[1]}====================="
db_role_get 0
db_role_get 1
db_role_check 0 Primary
db_role_check 1 Standby
}
function function_leave()
{
db_role_get 0
db_role_get 1
db_role_check 0 Primary
db_role_check 1 Standby
print "===================TestCaseEnd:${FUNCNAME[1]}====================="
}
function function_enter_failover()
{
echo ""
print "===================TestCaseBegin:${FUNCNAME[1]}====================="
}
function function_leave_failover()
{
print "===================TestCaseEnd:${FUNCNAME[1]}====================="
}
function db_start_wait()
{
wait_time=0
NODE_IDX=$1
db_role_get $NODE_IDX
cur_mode=${DB_ROLE[$NODE_IDX]}
print "wait node $NODE_IDX start"
while [[ $cur_mode != "Primary" ]] && [[ $cur_mode != "Standby" ]]; do
sleep 5
db_role_get $NODE_IDX
cur_mode=${DB_ROLE[$NODE_IDX]}
wait_time=`expr ${wait_time} + 5`
temp=`expr ${wait_time} % 30`
if [ ${temp} -eq 0 ]; then
print "wait node $NODE_IDX start ${wait_time}s"
fi
if [ ${wait_time} -gt 600 ]; then
print "wait node $NODE_IDX start ${wait_time}s, db start fail"
exit 1
fi
done
sleep 5
}
function restart_standby() {
function_enter
ssh_db_kill 1
db_start_wait 1
function_leave
}
function restart_primary() {
function_enter
ssh_db_kill 0
db_start_wait 0
function_leave
}
function switchover()
{
db_start_wait 0
db_start_wait 1
cm_ctl switchover -n ${NODE_ID[$1]} -D $DB_CONFIG_HOME
sleep 5
db_start_wait 0
db_start_wait 1
}
function switchover_4times()
{
function_enter
switchover 1
db_role_get 0
db_role_get 1
db_role_check 0 Standby
db_role_check 1 Primary
switchover 0
db_role_get 0
db_role_get 1
db_role_check 0 Primary
db_role_check 1 Standby
switchover 1
db_role_get 0
db_role_get 1
db_role_check 0 Standby
db_role_check 1 Primary
switchover 0
db_role_get 0
db_role_get 1
db_role_check 0 Primary
db_role_check 1 Standby
function_leave
}
function failover_alive() {
function_enter
get_reformer
PRIMARY_ID=$REFORMER_ID
db_start_wait $PRIMARY_ID
db_role_check $PRIMARY_ID Primary
kick $PRIMARY_ID
while true
do
get_reformer
if [ $REFORMER_ID != $DELETED_ID ]; then
PROMOTE_ID=$REFORMER_ID
break;
fi
print "need wait anthor node get lock"
sleep 5
done
db_start_wait $PROMOTE_ID
db_role_check $PROMOTE_ID Primary
db_start $DELETED_ID
db_start_wait $DELETED_ID
db_role_check $DELETED_ID Standby
switchover 0
function_leave
}
function twonode_testcase()
{
restart_standby
restart_primary
failover_alive
switchover_4times
}
function create_user_tpcc()
{
gsql -d postgres -p ${PGPORT} -c "create user tpcc with password \"Huawei@123\"; grant all privileges to tpcc;"
}
function tpcc_init() {
cd ${TPCC_PATH}
create_user_tpcc
sh runDatabaseBuild.sh 0-primary.gs
print "sh runDatabaseBuild.sh 0"
}
function runbenchmark()
{
is_primary=$1
NODE_IDX=$2
cd ${TPCC_PATH}
if [[ $is_primary = "Primary" ]]; then
print "runbenchmark Primary $NODE_IDX"
sh runBenchmark.sh ${TPCC_P[$NODE_IDX]} > /dev/null 2>&1 &
else
print "runbenchmark Standby $NODE_IDX"
sh runBenchmark.sh ${TPCC_S[$NODE_IDX]} > /dev/null 2>&1 &
fi
}
function restart_primary_tpcc() {
function_enter
runbenchmark Primary 0
runbenchmark Standby 1
sleep 60
ssh_db_kill 0
db_start_wait 0
function_leave
}
function failover_alive_tpcc() {
function_enter_failover
get_reformer
db_wait_all_node_ready
for(( i=0;i<${#DB_ROLE[@]};i++ ))
do
if [ ${DB_ROLE[$i]} = 'Primary' ]; then
runbenchmark Primary $i
else
runbenchmark Standby $i
fi
done
sleep 60
kick $PRIMARY_ID
while true
do
get_reformer
if [ $REFORMER_ID != $DELETED_ID ]; then
PROMOTE_ID=$REFORMER_ID
break;
fi
print "need wait anthor node get lock"
sleep 10
done
db_start_wait $PROMOTE_ID
db_role_check $PROMOTE_ID Primary
db_start $DELETED_ID
db_start_wait $DELETED_ID
db_role_check $DELETED_ID Standby
function_leave_failover
}
function muti_execute()
{
times=$1
for(( time=0;time<$times;time++ ))
do
print "times:$time"
## run function
$2
done
}
init_global_variable
db_wait_all_node_ready
switchover 0
create_user
twonode_testcase
#tpcc_init
#muti_execute 10 restart_primary_tpcc
#muti_execute 10 failover_alive_tpcc