test_suite: allow log-rotate logrotate_loop to fail

This commit is contained in:
Frank Liepold 2014-01-08 10:20:55 +01:00
parent 1df9628447
commit 084e33728d
3 changed files with 52 additions and 9 deletions

View File

@ -77,15 +77,26 @@ function logrotate_wait_for_umount_data_device
function logrotate_loop
{
local host=$1 res=$2 number_of_rotate_loops=$3 sleep_time_between_rotates=$4
local count=0 logfile logfile_old="x"
lib_vmsg "starting rotate loop on $host"
local logrotate_rc_req=0 logrotate_msg="succeed"
local count=0 logfile
local logrotate_rc_act rc_prim rc_desig_prim
marsadm_host_is_primary $host $res; rc_prim=$?
marsadm_host_is_designated_primary $host $res; rc_desig_prim=$?
if [ $rc_prim -ne 1 -o $rc_desig_prim -ne 1 ]; then
logrotate_rc_req=1
logrotate_msg="fail"
fi
lib_vmsg "starting rotate loop on $host (primary=$rc_prim, desig.prim=$rc_desig_prim, logrotate must $logrotate_msg)"
while [ $count -lt $number_of_rotate_loops ]; do
marsadm_do_cmd $host "log-rotate" $res || lib_exit 1
logfile=$(marsadm_get_last_logfile $host $res $host) || lib_exit 1
if [ "$logfile" != "$logfile_old" ]; then
lib_vmsg " new logfile $host:$logfile"
marsadm_do_cmd $host "log-rotate" $res
logrotate_rc_act=$?
if [ \( $logrotate_rc_act -ne 0 -a $logrotate_rc_req -eq 0 \) \
-o \( $logrotate_rc_act -eq 0 -a $logrotate_rc_req -ne 0 \) ]
then
lib_exit 1 "required rc = $logrotate_rc_req != $logrotate_rc_act = act. rc"
fi
logfile_old="$logfile"
logfile=$(marsadm_get_last_logfile $host $res $host) || lib_exit 1
lib_vmsg " last logfile $host:$logfile"
if [ $(($count % $logrotate_number_of_rotates_before_delete)) -eq 0 ]
then
marsadm_do_cmd $host "log-delete-all" $res || lib_exit 1

View File

@ -19,13 +19,19 @@
function lib_linktree_get_designated_primary_linkname
{
local resource_name=$1
local res=$1
echo ${resource_dir_list[$res]}/primary
}
function lib_linktree_get_primary_linkname
{
local host=$1 res=$2
echo ${resource_dir_list[$res]}/actual-$host/is-primary
}
function lib_linktree_get_res_host_linkname
{
local host=$1 resource_name=$2 action=$3
local host=$1 res=$2 action=$3
echo ${resource_dir_list[$res]}/$action-$host
}

View File

@ -272,3 +272,29 @@ function marsadm_get_number_bytes_unreadable_logend
fi
echo $restlen
}
function marsadm_host_is_primary
{
local host=$1 res=$2
local link link_status
local link="$(lib_linktree_get_primary_linkname $host $res)"
lib_linktree_check_link $host "$link" 1
link_status=$?
if [ $link_status -ne ${main_link_status["link_ok"]} ]; then
return 0
fi
return 1
}
function marsadm_host_is_designated_primary
{
local host=$1 res=$2
local link link_status
local link="$(lib_linktree_get_designated_primary_linkname $res)"
lib_linktree_check_link $host "$link" $host
link_status=$?
if [ $link_status -ne ${main_link_status["link_ok"]} ]; then
return 0
fi
return 1
}