mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-11 09:18:25 +03:00
Improve the "check" testing utility: slightly refactor and provide
active/inactive checks.
This commit is contained in:
parent
e0dd25f92b
commit
29ad12df51
@ -2,8 +2,12 @@
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
lvl() {
|
||||
lvs -a --noheadings "$@"
|
||||
}
|
||||
|
||||
lvdevices() {
|
||||
lvs -a -odevices --noheadings "$@" | sed 's/([^)]*)//g; s/,/ /g'
|
||||
lvl -odevices "$@" | sed 's/([^)]*)//g; s/,/ /g'
|
||||
}
|
||||
|
||||
mirror_images_redundant()
|
||||
@ -57,9 +61,9 @@ mirror_log_on()
|
||||
|
||||
lv_is_contiguous()
|
||||
{
|
||||
test `lvs -a --segments --noheadings $1 | wc -l` -eq 1 || {
|
||||
test `lvl --segments $1 | wc -l` -eq 1 || {
|
||||
echo "LV $1 expected to be contiguous, but is not:"
|
||||
lvs -a --segments --noheadings $1
|
||||
lvl --segments $1
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
@ -89,9 +93,9 @@ mirror_images_clung()
|
||||
|
||||
mirror() {
|
||||
lv="$1/$2"
|
||||
lvs -oattr "$lv" | grep "m" || {
|
||||
lvl -oattr "$lv" | grep "m" || {
|
||||
echo "$lv expected a mirror, but is not:"
|
||||
lvs -a $lv
|
||||
lvl -a $lv
|
||||
exit 1
|
||||
}
|
||||
mirror_images_redundant "$1" "$2"
|
||||
@ -108,9 +112,37 @@ mirror_legs() {
|
||||
|
||||
linear() {
|
||||
lv="$1/$2"
|
||||
lvs -ostripes "$lv" | grep -q "1" || {
|
||||
lvl -ostripes "$lv" | grep -q "1" || {
|
||||
echo "$lv expected linear, but is not:"
|
||||
lvs -a "$lv" -o+devices
|
||||
lvl "$lv" -o+devices
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
active() {
|
||||
lv="$1/$2"
|
||||
lvl -oattr "$lv" 2> /dev/null | grep -q "^ *....a.$" || {
|
||||
echo "$lv expected active, but lvs says it's not:"
|
||||
lvl "$lv" -o+devices 2>/dev/null
|
||||
exit 1
|
||||
}
|
||||
dmsetup table | egrep -q "$1-$2: *[^ ]+" || {
|
||||
echo "$lv expected active, lvs thinks it is but there are no mappings!"
|
||||
dmsetup table | grep $1-$2:
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
inactive() {
|
||||
lv="$1/$2"
|
||||
lvl -oattr "$lv" 2> /dev/null | grep -q '^ *....[-isd].$' || {
|
||||
echo "$lv expected inactive, but lvs says it's not:"
|
||||
lvl "$lv" -o+devices 2>/dev/null
|
||||
exit 1
|
||||
}
|
||||
dmsetup table | not egrep -q "$1-$2: *[^ ]+" || {
|
||||
echo "$lv expected inactive, lvs thinks it is but there are mappings!"
|
||||
dmsetup table | grep $1-$2:
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user