mirror of
https://github.com/schoebel/mars
synced 2024-12-16 19:55:34 +00:00
test_suite: refactoring
This commit is contained in:
parent
7f66424118
commit
d8b3e6da7c
@ -133,20 +133,22 @@ function lib_err_check_and_copy_global_err_files_all
|
||||
|
||||
function lib_err_wait_for_error_messages
|
||||
{
|
||||
[ $# -eq 5 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
|
||||
[ $# -eq 6 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
|
||||
local host=$1 msg_file=$2 errmsg_pattern="$3"
|
||||
local number_errmsg_req=$4 maxwait=$5
|
||||
local number_errmsg_req=$4 maxwait=$5 comp_cmd=$6
|
||||
local count waited=0 rc
|
||||
|
||||
case $comp_cmd in # ((
|
||||
eq|le|ge) :;;
|
||||
*) lib_exit 1 "wrong comp_cmd type $comp_cmd" ;;
|
||||
esac
|
||||
lib_vmsg " waiting for error messages in $msg_file on $host"
|
||||
while true; do
|
||||
lib_vmsg " checking existence of file $msg_file on $host"
|
||||
if lib_remote_idfile $host "ls -l --full-time $msg_file"; then
|
||||
count=$(lib_remote_idfile $host \
|
||||
"egrep '$errmsg_pattern' $msg_file | wc -l") || lib_exit 1
|
||||
lib_vmsg " found $count messages (pattern = '$errmsg_pattern'), waited $waited"
|
||||
if [ $count -ge $number_errmsg_req ]; then
|
||||
break
|
||||
fi
|
||||
count=$(lib_err_count_error_messages $host "$errmsg_pattern" \
|
||||
$msg_file) || lib_exit 1
|
||||
lib_vmsg " found $count messages (pattern = '$errmsg_pattern'), waited $waited"
|
||||
if [ $count -$comp_cmd $number_errmsg_req ]; then
|
||||
break
|
||||
fi
|
||||
lib_vmsg " waited $waited for $msg_file to exist or $number_errmsg_req to be found in $msg_file"
|
||||
let waited+=1
|
||||
@ -157,3 +159,15 @@ function lib_err_wait_for_error_messages
|
||||
done
|
||||
}
|
||||
|
||||
function lib_err_count_error_messages
|
||||
{
|
||||
[ $# -eq 3 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
|
||||
local host=$1 errmsg_pattern="$2" msg_file=$3
|
||||
if lib_remote_idfile $host "ls -l --full-time $msg_file" >/dev/null; then
|
||||
lib_remote_idfile $host \
|
||||
"egrep '$errmsg_pattern' $msg_file | grep -vw egrep | wc -l" \
|
||||
|| lib_exit 1
|
||||
return
|
||||
fi
|
||||
echo 0
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ function remote_dev_run
|
||||
lib_err_wait_for_error_messages $primary_host $lib_err_total_log_file \
|
||||
"$remote_dev_errmsg_pattern" \
|
||||
$remote_dev_number_errmsg_req \
|
||||
$remote_dev_maxtime_to_wait_for_errmsg
|
||||
$remote_dev_maxtime_to_wait_for_errmsg "ge"
|
||||
|
||||
lib_err_check_nonexistence_of_other_error_messages $primary_host \
|
||||
$lib_err_total_log_file \
|
||||
|
@ -341,7 +341,7 @@ function resource_check_low_space_error
|
||||
lib_exit 1 "pattern resource_mars_dir_full_${msgtype}_pattern_list[$err_type] not found"
|
||||
fi
|
||||
msgpattern="${msgpattern//$resource_msg_resource_dir_name_pattern/$(resource_get_resource_dir $res)}"
|
||||
lib_err_wait_for_error_messages $host $msgfile "$msgpattern" 1 10
|
||||
lib_err_wait_for_error_messages $host $msgfile "$msgpattern" 1 10 "ge"
|
||||
}
|
||||
|
||||
function resource_dd_until_mars_dir_full
|
||||
|
@ -79,13 +79,15 @@ function syslog_run
|
||||
|
||||
file_destroy_dd_on_logfile $secondary_host $logfile $length_logfile
|
||||
|
||||
nr_msg_orig=$(syslog_count_or_check_messages $secondary_host \
|
||||
$syslog_flood_limit 1) || lib_exit 1
|
||||
nr_msg_orig=$(lib_err_count_error_messages $secondary_host \
|
||||
"$syslog_err_msg_pattern" $syslog_logfile) || lib_exit 1
|
||||
|
||||
marsadm_do_cmd $secondary_host "resume-replay" $res || lib_exit 1
|
||||
|
||||
syslog_count_or_check_messages $secondary_host \
|
||||
$(( $nr_msg_orig + $syslog_flood_limit )) 0
|
||||
lib_err_wait_for_error_messages $secondary_host $syslog_logfile \
|
||||
"$syslog_err_msg_pattern" \
|
||||
$(( $nr_msg_orig + $syslog_flood_limit )) \
|
||||
$syslog_msg_wait_time "eq"
|
||||
|
||||
# stopp generation of new error messages
|
||||
marsadm_pause_cmd "apply" $secondary_host $res
|
||||
@ -102,12 +104,14 @@ function syslog_run
|
||||
|
||||
marsadm_do_cmd $secondary_host "resume-replay" $res || lib_exit 1
|
||||
|
||||
nr_msg_orig=$(syslog_count_or_check_messages $secondary_host \
|
||||
$syslog_flood_limit 1) || lib_exit 1
|
||||
nr_msg_orig=$(lib_err_count_error_messages $secondary_host \
|
||||
"$syslog_err_msg_pattern" $syslog_logfile) || lib_exit 1
|
||||
|
||||
lib_vmsg " sleeping syslog_recovery_s = $syslog_recovery_s seconds"
|
||||
|
||||
syslog_count_or_check_messages $secondary_host $nr_msg_orig 0
|
||||
lib_err_wait_for_error_messages $secondary_host $syslog_logfile \
|
||||
"$syslog_err_msg_pattern" \
|
||||
$nr_msg_orig $syslog_msg_wait_time "eq"
|
||||
done
|
||||
|
||||
}
|
||||
@ -128,33 +132,3 @@ function syslog_set_logging_parameters
|
||||
lib_remote_idfile $host "echo $value > $file" || lib_exit 1
|
||||
done
|
||||
}
|
||||
|
||||
# we cannot use lib_err_wait_for_error_messages, because we need a grep -v egrep
|
||||
# because sometimes all commands are logged in /var/log/syslog ...
|
||||
# If only_count==1 then the number of messages found is printed to stdout.
|
||||
function syslog_count_or_check_messages
|
||||
{
|
||||
[ $# -eq 3 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
|
||||
local host=$1 nr_msg_req=$2 only_count=$3
|
||||
local waited=0 maxwait=$syslog_msg_wait_time
|
||||
while true; do
|
||||
local nr_msg_act
|
||||
nr_msg_act="$(lib_remote_idfile $host \
|
||||
"egrep '$syslog_err_msg_pattern' $syslog_logfile")" || \
|
||||
lib_exit 1
|
||||
nr_msg_act=$(echo "$nr_msg_act" | grep -vw egrep | wc -l)
|
||||
if [ $only_count -eq 1 ]; then
|
||||
echo $nr_msg_act
|
||||
return
|
||||
fi
|
||||
if [ $nr_msg_act -eq $nr_msg_req ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
let waited+=1
|
||||
lib_vmsg " waited $waited for $nr_msg_req (act. found = $nr_msg_act)"
|
||||
if [ $waited -eq $maxwait ]; then
|
||||
lib_exit 1 "maxwait $maxwait exceeded"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user