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
parent 792b1b44b4
commit 736e08ed3b
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]}')' 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 function lib_rw_compare_checksums
{ {
[ $# -eq 6 ] || lib_exit 1 "wrong number $# of arguments (args = $*)" [ $# -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 dev=$(lv_config_get_lv_device $res)
local host role primary_cksum_out secondary_cksum_out cksum_out local host role primary_cksum_out secondary_cksum_out cksum_out
local cksum_dev=$dev local cksum_dev=$dev
local dd_bsize=4096 dd_count
for role in "primary" "secondary"; do for role in "primary" "secondary"; do
local dummy_file
eval host='$'${role}_host eval host='$'${role}_host
dummy_file=$main_mars_directory/dummy-$host
marsadm_do_cmd $host "down" $res || lib_exit 1 marsadm_do_cmd $host "down" $res || lib_exit 1
if [ $cmp_size -ne 0 ]; then if [ $cmp_size -eq 0 ]; then
local dummy_file=$main_mars_directory/dummy-$host local link_value
lib_vmsg " dumping $cmp_size G of $dev to $dummy_file" local link="${resource_dir_list[$res]}/size"
lib_remote_idfile $host \ lib_vmsg " reading link $host:$link"
"dd if=$dev of=$dummy_file bs=1024 count=$(($cmp_size * 1024 * 1024))" || lib_exit 1 link_value=$(lib_remote_idfile $primary_host "readlink $link") || \
lib_remote_idfile $host "ls -l $dummy_file" lib_exit 1
cksum_dev=$dummy_file 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 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" lib_rw_cksum $host $cksum_dev "cksum_out"
eval ${role}_cksum_out='"${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
lib_remote_idfile $host "rm -f $dummy_file" || lib_exit 1
fi
marsadm_do_cmd $host "up" $res || lib_exit 1 marsadm_do_cmd $host "up" $res || lib_exit 1
done done
if [ "$primary_cksum_out" != "$secondary_cksum_out" ]; then if [ "$primary_cksum_out" != "$secondary_cksum_out" ]; then