diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh index ea156836..b7a7ccbf 100644 --- a/clustermd_tests/func.sh +++ b/clustermd_tests/func.sh @@ -169,20 +169,58 @@ stop_md() } record_system_speed_limit() { - system_speed_limit_max=`cat /proc/sys/dev/raid/speed_limit_max` - system_speed_limit_min=`cat /proc/sys/dev/raid/speed_limit_min` + local ip + local idx=0 + + for ip in $NODE1 $NODE2 + do + nodes_system_speed_limit_min[$idx]=$(ssh $ip "cat /proc/sys/dev/raid/speed_limit_min") + nodes_system_speed_limit_max[$idx]=$(ssh $ip "cat /proc/sys/dev/raid/speed_limit_max") + idx=$[idx+1] + done } # To avoid sync action finishes before checking it, it needs to limit # the sync speed control_system_speed_limit() { - echo $test_speed_limit_min > /proc/sys/dev/raid/speed_limit_min - echo $test_speed_limit_max > /proc/sys/dev/raid/speed_limit_max + local ip + local idx=0 + + for ip in $NODE1 $NODE2 + do + ssh $ip "echo ${nodes_test_speed_limit_min[$idx]} > /proc/sys/dev/raid/speed_limit_min" + ssh $ip "echo ${nodes_test_speed_limit_max[$idx]} > /proc/sys/dev/raid/speed_limit_max" + idx=$[idx+1] + done } restore_system_speed_limit() { - echo $system_speed_limit_min > /proc/sys/dev/raid/speed_limit_max - echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max + local ip + local idx=0 + local min + local max + + for ip in $NODE1 $NODE2 + do + min=${nodes_system_speed_limit_min[$idx]} + max=${nodes_system_speed_limit_max[$idx]} + + if [ -z "$min" ] + then + echo "$ip: speed_limit_min was not recorded, skip restoring." >> $logdir/$logfile + else + ssh $ip "echo $min > /proc/sys/dev/raid/speed_limit_min" + fi + + if [ -z "$max" ] + then + echo "$ip: speed_limit_max was not recorded, skip restoring." >> $logdir/$logfile + else + ssh $ip "echo $max > /proc/sys/dev/raid/speed_limit_max" + fi + + idx=$[idx+1] + done } record_selinux() { @@ -238,6 +276,7 @@ do_setup() { check_env ulimit -c unlimited + record_system_speed_limit } do_clean() diff --git a/test b/test index 7fa68177..8b3152de 100755 --- a/test +++ b/test @@ -6,10 +6,20 @@ targetdir="/var/tmp" logdir="$targetdir" config=/tmp/mdadm.conf testdir=$PWD/tests + +# used by tests system_speed_limit_max=0 system_speed_limit_min=0 test_speed_limit_min=100 test_speed_limit_max=500 + +# used by clustermd_tests +nodes_system_speed_limit_min=() +nodes_system_speed_limit_max=() +# NODE1, NODE2 +nodes_test_speed_limit_min=(100 1000) +nodes_test_speed_limit_max=(500 100000) + devlist= # If super1 metadata name doesn't have the same hostname with machine, # it's treated as foreign.