summaryrefslogtreecommitdiffstats
path: root/tests/func.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/func.sh')
-rw-r--r--tests/func.sh45
1 files changed, 38 insertions, 7 deletions
diff --git a/tests/func.sh b/tests/func.sh
index 567d91d9..214773bb 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -202,6 +202,24 @@ restore_selinux() {
setenforce $sys_selinux
}
+wait_for_reshape_end() {
+ # wait for grow-continue to finish but break if sync_action does not
+ # contain any reshape value
+ while true
+ do
+ sync_action=$(grep -Ec '(resync|recovery|reshape|check|repair) *=' /proc/mdstat)
+ if (( "$sync_action" != 0 )); then
+ sleep 1
+ continue
+ elif [[ $(pgrep -f "mdadm --grow --continue" > /dev/null) != "" ]]; then
+ echo "Grow continue did not finish but reshape is done" >&2
+ exit 1
+ else
+ break
+ fi
+ done
+}
+
setup_systemd_env() {
warn "Warning! Test suite will set up systemd environment!\n"
echo "Use \"systemctl show-environment\" to show systemd environment variables"
@@ -357,15 +375,28 @@ check() {
max=`cat /proc/sys/dev/raid/speed_limit_max`
echo 200000 > /proc/sys/dev/raid/speed_limit_max
sleep 0.1
- while grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat ||
- grep -v idle > /dev/null /sys/block/md*/md/sync_action
+ iterations=0
+ # Wait 10 seconds for one of the actions appears in sync_action.
+ while [ $iterations -le 10 ]
do
- sleep 0.5
- done
- while ps auxf | grep "mdadm --grow --continue" | grep -v grep
- do
- sleep 1
+ sync_action=$(grep -Ec '(resync|recovery|reshape|check|repair) *=' /proc/mdstat)
+ if (( "$sync_action" == 0 )); then
+ sleep 1
+ iterations=$(( $iterations + 1 ))
+ continue
+ else
+ break
+ fi
done
+ echo "Reshape has not started after 10 seconds"
+
+ # Now let's wait for reshape to finish.
+ echo "Waiting for grow-continue to finish"
+ wait_for_reshape_end
+ # If we have matrix-raid there's a second process ongoing
+ sleep 5
+ wait_for_reshape_end
+
echo $min > /proc/sys/dev/raid/speed_limit_min
echo $max > /proc/sys/dev/raid/speed_limit_max
;;