summaryrefslogtreecommitdiffstats
path: root/tests/func.sh
diff options
context:
space:
mode:
authorKinga Stefaniuk <kinga.stefaniuk@intel.com>2024-10-24 15:09:47 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-11-13 14:17:35 +0100
commitf0ed3e2ec105637d0a0391ac3c35a2c577e0b273 (patch)
treef1b8fd4973135737a99add6c1e11f33995cff680 /tests/func.sh
parentFix 07reshape5initr test (diff)
downloadmdadm-f0ed3e2ec105637d0a0391ac3c35a2c577e0b273.tar.xz
mdadm-f0ed3e2ec105637d0a0391ac3c35a2c577e0b273.zip
func.sh: do not hang when grow-continue can't finish
When grow-continue process is ongoing, sync_action indicates that recovery is in progress. If grow-continue does not finish, even if sync_action is not "reshape" anymore, the test should fail. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
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
;;