test_suite: to calculate checksums take mars size of data device

This commit is contained in:
Frank Liepold 2013-12-10 15:11:25 +01:00 committed by Thomas Schoebel-Theuer
parent 376822f5a8
commit 39b37c9c72
1 changed files with 28 additions and 10 deletions

View File

@ -131,6 +131,8 @@ function lib_rw_cksum
eval $varname_cksum='('${my_cksum_out[0]}' '${my_cksum_out[1]}')'
}
# if the size to compare equals 0 we take the mars size of the
# data devices
function lib_rw_compare_checksums
{
[ $# -eq 6 ] || lib_exit 1 "wrong number $# of arguments (args = $*)"
@ -139,23 +141,39 @@ function lib_rw_compare_checksums
local dev=$(lv_config_get_lv_device $res)
local host role primary_cksum_out secondary_cksum_out cksum_out
local cksum_dev=$dev
local dd_bsize=4096 dd_count
for role in "primary" "secondary"; do
local dummy_file
eval host='$'${role}_host
dummy_file=$main_mars_directory/dummy-$host
marsadm_do_cmd $host "down" $res || lib_exit 1
if [ $cmp_size -ne 0 ]; then
local dummy_file=$main_mars_directory/dummy-$host
lib_vmsg " dumping $cmp_size G of $dev to $dummy_file"
lib_remote_idfile $host \
"dd if=$dev of=$dummy_file bs=1024 count=$(($cmp_size * 1024 * 1024))" || lib_exit 1
lib_remote_idfile $host "ls -l $dummy_file"
cksum_dev=$dummy_file
if [ $cmp_size -eq 0 ]; then
local link_value
local link="${resource_dir_list[$res]}/size"
lib_vmsg " reading link $host:$link"
link_value=$(lib_remote_idfile $primary_host "readlink $link") || \
lib_exit 1
if ! expr "$link_value" : '^[0-9][0-9]*$' >/dev/null; then
lib_exit 1 " $link_value is not a numeric value"
fi
if [ $((($link_value / $dd_bsize) * $dd_bsize)) -ne $link_value ]
then
lib_exit 1 "value $link_value not divsible by $dd_bsize"
fi
dd_count=$(($link_value / $dd_bsize))
else
dd_count=$((($cmp_size * 1024 * 1024 * 1024) / $dd_bsize))
fi
lib_vmsg " dumping $(($dd_count * $dd_bsize)) bytes of $dev to $dummy_file"
lib_remote_idfile $host \
"dd if=$dev of=$dummy_file bs=$dd_bsize count=$dd_count" || \
lib_exit 1
lib_remote_idfile $host "ls -l $dummy_file"
cksum_dev=$dummy_file
lib_rw_cksum $host $cksum_dev "cksum_out"
eval ${role}_cksum_out='"${cksum_out[*]}"'
if [ $cmp_size -ne 0 ]; then
lib_remote_idfile $host "rm -f $dummy_file" || lib_exit 1
fi
lib_remote_idfile $host "rm -f $dummy_file" || lib_exit 1
marsadm_do_cmd $host "up" $res || lib_exit 1
done
if [ "$primary_cksum_out" != "$secondary_cksum_out" ]; then