1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

tests: fix working with devs in array

Also fixes one instance of invalid  'mirror_image_on' test
and places there correct indexed set of PVs.
This commit is contained in:
Zdenek Kabelac 2017-07-08 18:23:47 +02:00
parent fdbb680531
commit bc10d0373a

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
# Copyright (C) 2008-2017 Red Hat, Inc. All rights reserved.
# Copyright (C) 2007 NEC Corporation
#
# This copyrighted material is made available to anyone wishing to use,
@ -20,18 +20,20 @@ export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-}
. lib/inittest
list_pvs=()
lv_is_on_ ()
{
local lv=$vg/$1
shift
local pvs=$@
local list_pvs=( "$@" )
echo "Check if $lv is exactly on PVs $pvs"
echo "Check if $lv is exactly on PVs" "${list_pvs[@]}"
rm -f out1 out2
echo $pvs | sed 's/ /\n/g' | sort | uniq > out1
printf "%s\n" "${list_pvs[@]}" | sort | uniq > out1
lvs -a -o+devices $lv
get lv_devices $lv | sed 's/ /\n/g' | sort | uniq > out2 || true
get lv_devices "$lv" | sort | uniq > out2
diff --ignore-blank-lines out1 out2
}
@ -40,24 +42,25 @@ mimages_are_on_ ()
{
local lv=$1
shift
local pvs=$@
local mimages
local list_pvs=( "$@" )
local mimages=()
local i
echo "Check if mirror images of $lv are on PVs $pvs"
rm -f out1 out2
echo $pvs | sed 's/ /\n/g' | sort | uniq > out1
lvs --noheadings -a -o lv_name $vg | tee lvs_log
mimages=$(grep "${lv}_mimage_" lvs_log | \
sed 's/\[//g; s/\]//g' || true)
echo "Check if mirror images of $lv are on PVs" "${list_pvs[@]}"
printf "%s\n" "${list_pvs[@]}" | sort | uniq > out1
for i in $mimages; do
get lv_field_lv_ "$vg" lv_name -a | grep "${lv}_mimage_" | tr -d [] | tee lvs_log
readarray -t mimages < lvs_log
for i in "${mimages[@]}"; do
echo "Checking $vg/$i"
lvs -a -o+devices $vg/$i
lvs -a -odevices --noheadings $vg/$i | tee lvs_log
sed 's/([^)]*)//g; s/ //g; s/,/ /g' lvs_log | sort | uniq >> out2 || true
lvs -a -o+devices "$vg/$i"
done
for i in "${mimages[@]}"; do
get lv_devices "$vg/$i"
done | sort | uniq > out2
diff --ignore-blank-lines out1 out2
}
@ -79,16 +82,16 @@ rest_pvs_()
{
local index=$1
local num=$2
local rem=
local rem=()
local n
local dev
for n in $(seq 1 $(( index - 1 )) ) $(seq $(( index + 1 )) $num); do
eval dev=$\dev$n
rem="$rem $dev"
eval "dev=\$dev$n"
rem+=( "$dev" )
done
echo "$rem"
printf "%s\n" "${rem[@]}"
}
# ---------------------------------------------------------------------
@ -156,9 +159,10 @@ test_3way_mirror_fail_1_()
lvcreate -an -Zn -l2 --type mirror -m2 --nosync -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4":$BLOCKS
mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3"
mirrorlog_is_on_ $lv1 "$dev4"
eval aux disable_dev \$dev$index
eval aux disable_dev "\$dev$index"
vgreduce --removemissing --force $vg
mimages_are_on_ $lv1 $(rest_pvs_ $index 3)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 3)"
mimages_are_on_ "$lv1" "${list_pvs[@]}"
mirrorlog_is_on_ $lv1 "$dev4"
}
@ -166,7 +170,7 @@ for n in $(seq 1 3); do
#COMM fail mirror image $(($n - 1)) of 3-way mirrored LV"
prepare_lvs_
test_3way_mirror_fail_1_ $n
eval recover_vg_ \$dev$n
eval recover_vg_ "\$dev$n"
done
# ---------------------------------------------------------------------
@ -181,18 +185,20 @@ test_3way_mirror_fail_2_()
lvcreate -an -Zn -l2 --type mirror -m2 --nosync -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4":$BLOCKS
mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3"
mirrorlog_is_on_ $lv1 "$dev4"
rest_pvs_ $index 3
aux disable_dev $(rest_pvs_ $index 3)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 3)"
aux disable_dev "${list_pvs[@]}"
vgreduce --force --removemissing $vg
lv_is_linear_ $lv1
eval lv_is_on_ $lv1 \$dev$n
eval lv_is_on_ $lv1 "\$dev$n"
}
for n in $(seq 1 3); do
#COMM fail mirror images other than mirror image $(($n - 1)) of 3-way mirrored LV
prepare_lvs_
test_3way_mirror_fail_2_ $n
recover_vg_ $(rest_pvs_ $n 3)
readarray -t list_pvs <<< "$(rest_pvs_ "$n" 3)"
recover_vg_ "${list_pvs[@]}"
done
# ---------------------------------------------------------------------
@ -212,7 +218,8 @@ test_3way_mirror_plus_1_fail_1_()
lvs -a -o +devices
vgreduce --removemissing --force $vg
lvs -a -o+devices # $vg
check mirror_images_on $vg $lv1 "$dev5" # $(rest_pvs_ $index 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 4)"
check mirror_images_on $vg $lv1 "${list_pvs[@]}"
check mirror_log_on $vg $lv1 "$dev5"
}
@ -238,7 +245,8 @@ test_3way_mirror_plus_1_fail_3_()
check mirror_images_on $vg $lv1 "$dev1" "$dev2" "$dev3" "$dev4"
check mirror_log_on $vg $lv1 "$dev5"
lvs -a -o+devices $vg
aux disable_dev $(rest_pvs_ $index 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 4)"
aux disable_dev "${list_pvs[@]}"
vgreduce --removemissing --force $vg
lvs -a -o+devices $vg
eval dev=\$dev$n
@ -250,7 +258,8 @@ for n in $(seq 1 4); do
#COMM "fail mirror images other than mirror image $(($n - 1)) of 4-way (1 converting) mirrored LV"
prepare_lvs_
test_3way_mirror_plus_1_fail_3_ $n
recover_vg_ $(rest_pvs_ $n 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$n" 4)"
recover_vg_ "${list_pvs[@]}"
done
# ---------------------------------------------------------------------
@ -268,7 +277,8 @@ test_2way_mirror_plus_2_fail_1_()
mirrorlog_is_on_ $lv1 "$dev5"
eval aux disable_dev \$dev$n
vgreduce --removemissing --force $vg
mimages_are_on_ $lv1 $(rest_pvs_ $index 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 4)"
mimages_are_on_ "$lv1" "${list_pvs[@]}"
mirrorlog_is_on_ $lv1 "$dev5"
}
@ -276,7 +286,7 @@ for n in $(seq 1 4); do
#COMM "fail mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV"
prepare_lvs_
test_2way_mirror_plus_2_fail_1_ $n
eval recover_vg_ \$dev$n
eval recover_vg_ "\$dev$n"
done
# ---------------------------------------------------------------------
@ -293,7 +303,8 @@ test_2way_mirror_plus_2_fail_3_()
lvconvert -m+2 $vg/$lv1 "$dev3" "$dev4"
mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" "$dev4"
mirrorlog_is_on_ $lv1 "$dev5"
aux disable_dev $(rest_pvs_ $index 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$index" 4)"
aux disable_dev "${list_pvs[@]}"
vgreduce --removemissing --force $vg
lvs -a -o+devices $vg
eval dev=\$dev$n
@ -305,7 +316,8 @@ for n in $(seq 1 4); do
#COMM "fail mirror images other than mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV"
prepare_lvs_
test_2way_mirror_plus_2_fail_3_ $n
recover_vg_ $(rest_pvs_ $n 4)
readarray -t list_pvs <<< "$(rest_pvs_ "$n" 4)"
recover_vg_ "${list_pvs[@]}"
done
# ---------------------------------------------------------------------