Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions clustermd_tests/func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -238,6 +276,7 @@ do_setup()
{
check_env
ulimit -c unlimited
record_system_speed_limit
}

do_clean()
Expand Down
10 changes: 10 additions & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down