#!/bin/sh
source ./standby_env.sh
function test_1()
{
check_instance
gsql -d $db -p $dn1_primary_port -c "DROP TABLE if exists mpp_test1; CREATE TABLE mpp_test1(id INT,name VARCHAR(15) NOT NULL);"
gsql -d $db -p $dn1_primary_port -c "set enable_data_replicate=on; copy mpp_test1 from '$scripts_dir/data/data5';"
b=`expr $rawdata_lines \* 1`
if [ $(gsql -d $db -p $dn1_primary_port -c "select count(1) from mpp_test1;" | grep $b |wc -l) -eq 1 ]; then
echo "all of success!"
else
echo "copy to primary $failed_keyword!"
exit 1
fi
sleep 1
gs_ctl switchover -w -t $gsctl_wait_time -D $data_dir/datanode1_standby
if [ $? -eq 0 ]; then
echo "all of success!"
else
echo "$failed_keyword"
exit 1
fi
b=`expr $rawdata_lines \* 1`
if [ $(gsql -d $db -p $dn1_standby_port -c "select count(1) from mpp_test1;" | grep $b |wc -l) -eq 1 ]; then
echo "all of success!"
else
echo "standby data does not match with primary, $failed_keyword!"
exit 1
fi
sleep 10
gs_ctl query -D $data_dir/datanode1_standby
}
function tear_down()
{
sleep 2
gs_ctl query -D $data_dir/datanode1
gs_ctl switchover -w -t $gsctl_wait_time -D $data_dir/datanode1
if [ $? -eq 0 ]; then
echo "all of success!"
else
echo "$failed_keyword"
exit 1
fi
sleep 3
gsql -d $db -p $dn1_primary_port -c "DROP TABLE if exists mpp_test1;"
}
test_1
tear_down