mirror of https://github.com/schoebel/mars
test_suite: continue test for marsadm --force primary
This commit is contained in:
parent
736e08ed3b
commit
7f97cabbcb
|
@ -110,7 +110,6 @@ function switch2primary_force
|
|||
[ $# -eq 4 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
|
||||
local primary_host=$1 secondary_host=$2 res=$3 writer_script=$4
|
||||
local write_count time_waited host logfile length_logfile net_throughput
|
||||
local dev=$(resource_get_data_device $res)
|
||||
# # replace string remote_host with $secondary_host
|
||||
# declare -A impact_cmd
|
||||
# eval impact_cmd=(\
|
||||
|
@ -129,40 +128,71 @@ function switch2primary_force
|
|||
$res "logfile" "length_logfile" "time_waited" \
|
||||
0 "net_throughput"
|
||||
lib_vmsg " ${FUNCNAME[0]}: fetch time: $time_waited"
|
||||
# waiting for empty logfile on secondary_host
|
||||
|
||||
switch2primary_wait_for_first_own_logfile_on_new_primary $secondary_host \
|
||||
$res
|
||||
for host in $primary_host $secondary_host; do
|
||||
switch2primary_check_write_to_logfiles $host $res
|
||||
done
|
||||
|
||||
switch2primary_correct_split_brain $primary_host $secondary_host $res
|
||||
|
||||
}
|
||||
|
||||
function switch2primary_wait_for_first_own_logfile_on_new_primary
|
||||
{
|
||||
local host=$1 res=$2
|
||||
local maxwait=60 waited=0
|
||||
while true;do
|
||||
local last_logfile=$(marsadm_get_last_logfile $secondary_host $res $secondary_host)
|
||||
local last_logfile=$(marsadm_get_last_logfile $host $res $host)
|
||||
if [ -n "$last_logfile" ]; then
|
||||
lib_vmsg " found logfile $last_logfile on $secondary_host"
|
||||
lib_vmsg " found logfile $last_logfile on $host"
|
||||
break
|
||||
fi
|
||||
let waited+=1
|
||||
lib_vmsg " waited $waited for logfile to appear on $secondary_host"
|
||||
lib_vmsg " waited $waited for own logfile to appear on $host"
|
||||
if [ $waited -ge $maxwait ]; then
|
||||
lib_exit 1 "maxwait $maxwait exceeded"
|
||||
fi
|
||||
done
|
||||
for host in $primary_host $secondary_host; do
|
||||
local length_logfile length_logfile_old
|
||||
length_logfile_old=$(perftest_get_length_last_logfile $host $res $host)
|
||||
lib_vmsg " length last logfile on $host: $length_logfile_old"
|
||||
lib_remote_idfile $host \
|
||||
"yes | dd oflag=direct bs=4096 count=1 of=$dev" || \
|
||||
lib_exit 1
|
||||
length_logfile=$(perftest_get_length_last_logfile $host $res $host)
|
||||
lib_vmsg " length last logfile on $host: $length_logfile"
|
||||
if [ $length_logfile -eq $length_logfile_old ]; then
|
||||
lib_exit 1 "nothing written to logfiles on $host"
|
||||
fi
|
||||
done
|
||||
|
||||
# marsadm_do_cmd $primary_host "secondary" "$res" || lib_exit 1
|
||||
# marsadm_do_cmd $primary_host "invalidate" "$res" || lib_exit 1
|
||||
# lib_wait_for_initial_end_of_sync $secondary_host $primary_host $res \
|
||||
# $resource_maxtime_initial_sync \
|
||||
# $resource_time_constant_initial_sync \
|
||||
# "time_waited"
|
||||
}
|
||||
|
||||
# check whether write access to the data device causes writes to the logfiles
|
||||
function switch2primary_check_write_to_logfiles
|
||||
{
|
||||
local host=$1 res=$2
|
||||
local length_logfile length_logfile_old
|
||||
local dev=$(resource_get_data_device $res)
|
||||
length_logfile_old=$(perftest_get_length_last_logfile $host $res $host)
|
||||
lib_vmsg " length last logfile on $host: $length_logfile_old"
|
||||
lib_remote_idfile $host \
|
||||
"yes | dd oflag=direct bs=4096 count=1 of=$dev" || \
|
||||
lib_exit 1
|
||||
length_logfile=$(perftest_get_length_last_logfile $host $res $host)
|
||||
lib_vmsg " length last logfile on $host: $length_logfile"
|
||||
if [ $length_logfile -eq $length_logfile_old ]; then
|
||||
lib_exit 1 "nothing written to logfiles on $host"
|
||||
fi
|
||||
}
|
||||
|
||||
function switch2primary_correct_split_brain
|
||||
{
|
||||
local host=$1 # the former primary
|
||||
local primary_host=$2 res=$3
|
||||
local dev=$(resource_get_data_device $res)
|
||||
local time_waited
|
||||
mount_umount_data_device $host $res
|
||||
marsadm_do_cmd $host "secondary" "$res" || lib_exit 1
|
||||
marsadm_do_cmd $primary_host "invalidate" "$res" || lib_exit 1
|
||||
lib_wait_for_initial_end_of_sync $primary_host $host $res \
|
||||
$resource_maxtime_initial_sync \
|
||||
$resource_time_constant_initial_sync \
|
||||
"time_waited"
|
||||
lib_vmsg " write some data to $primary_host:$dev"
|
||||
lib_remote_idfile $primary_host \
|
||||
"yes | dd oflag=direct bs=4096 count=1 of=$dev" || \
|
||||
lib_exit 1
|
||||
lib_wait_for_secondary_to_become_uptodate_and_cmp_cksums "resource" \
|
||||
$host $primary_host \
|
||||
$res $dev 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue