mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
tests: thin repair testing
More checks for thin related tools. Add same functionality for cache related tools.
This commit is contained in:
parent
3a1c609ac4
commit
740fcdae7d
@ -30,6 +30,11 @@ export LVM_TEST_THIN_DUMP_CMD?=@THIN_DUMP_CMD@
|
||||
export LVM_TEST_THIN_REPAIR_CMD?=@THIN_REPAIR_CMD@
|
||||
export LVM_TEST_THIN_RESTORE_CMD?=@THIN_RESTORE_CMD@
|
||||
|
||||
export LVM_TEST_CACHE_CHECK_CMD?=@CACHE_CHECK_CMD@
|
||||
export LVM_TEST_CACHE_DUMP_CMD?=@CACHE_DUMP_CMD@
|
||||
export LVM_TEST_CACHE_REPAIR_CMD?=@CACHE_REPAIR_CMD@
|
||||
export LVM_TEST_CACHE_RESTORE_CMD?=@CACHE_RESTORE_CMD@
|
||||
|
||||
SUBDIRS = api unit
|
||||
SOURCES = lib/not.c lib/harness.c
|
||||
|
||||
@ -79,6 +84,10 @@ help:
|
||||
@echo " LVM_TEST_THIN_DUMP_CMD Command for thin_dump [$(LVM_TEST_THIN_DUMP_CMD)]."
|
||||
@echo " LVM_TEST_THIN_REPAIR_CMD Command for thin_repair [$(LVM_TEST_THIN_REPAIR_CMD)]."
|
||||
@echo " LVM_TEST_THIN_RESTORE_CMD Command for thin_restore [$(LVM_TEST_THIN_RESTORE_CMD)]."
|
||||
@echo " LVM_TEST_CACHE_CHECK_CMD Command for cache_check [$(LVM_TEST_CACHE_CHECK_CMD)]."
|
||||
@echo " LVM_TEST_CACHE_DUMP_CMD Command for cache_dump [$(LVM_TEST_CACHE_DUMP_CMD)]."
|
||||
@echo " LVM_TEST_CACHE_REPAIR_CMD Command for cache_repair [$(LVM_TEST_CACHE_REPAIR_CMD)]."
|
||||
@echo " LVM_TEST_CACHE_RESTORE_CMD Command for cache_restore [$(LVM_TEST_CACHE_RESTORE_CMD)]."
|
||||
@echo " LVM_TEST_UNLIMITED Set to get unlimited test log (>32MB)"
|
||||
@echo " LVM_VALGRIND Enable valgrind testing (1,2,3) execs $$"VALGRIND
|
||||
@echo " LVM_VALGRIND_CLVMD Enable valgrind testing of clvmd (1)."
|
||||
@ -153,6 +162,14 @@ lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp Makefile
|
||||
echo 'export LVMETAD_PIDFILE="@LVMETAD_PIDFILE@"' >> $@-t
|
||||
echo 'export DMEVENTD_PIDFILE="@DMEVENTD_PIDFILE@"' >> $@-t
|
||||
echo 'export CLVMD_PIDFILE="@CLVMD_PIDFILE@"' >> $@-t
|
||||
echo 'export LVM_TEST_THIN_CHECK_CMD=$${LVM_TEST_THIN_CHECK_CMD:-@THIN_CHECK_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_THIN_DUMP_CMD=$${LVM_TEST_THIN_DUMP_CMD:-@THIN_DUMP_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_THIN_REPAIR_CMD=$${LVM_TEST_THIN_REPAIR_CMD:-@THIN_REPAIR_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_THIN_RESTORE_CMD=$${LVM_TEST_THIN_RESTORE_CMD:-@THIN_RESTORE_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_CACHE_CHECK_CMD=$${LVM_TEST_CACHE_CHECK_CMD:-@CACHE_CHECK_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_CACHE_DUMP_CMD=$${LVM_TEST_CACHE_DUMP_CMD:-@CACHE_DUMP_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_CACHE_REPAIR_CMD=$${LVM_TEST_CACHE_REPAIR_CMD:-@CACHE_REPAIR_CMD@}' >> $@-t
|
||||
echo 'export LVM_TEST_CACHE_RESTORE_CMD=$${LVM_TEST_CACHE_RESTORE_CMD:-@CACHE_RESTORE_CMD@}' >> $@-t
|
||||
mv $@-t $@
|
||||
|
||||
LIB = lib/not lib/invalid lib/fail lib/should lib/harness \
|
||||
|
@ -15,9 +15,6 @@
|
||||
|
||||
aux have_thin 1 0 0 || skip
|
||||
|
||||
# disable thin_check if not present in system
|
||||
which thin_check || aux lvmconf 'global/thin_check_executable = ""'
|
||||
|
||||
aux prepare_devs 2
|
||||
|
||||
vgcreate -s 64k $vg $(cat DEVICES)
|
||||
|
@ -767,6 +767,27 @@ can_use_16T() {
|
||||
test "$(getconf LONG_BIT)" -eq 64
|
||||
}
|
||||
|
||||
# Check if major.minor.revision' string is 'at_least'
|
||||
version_at_least() {
|
||||
local major
|
||||
local minor
|
||||
local revision
|
||||
IFS=. read -r major minor revision <<< "$1"
|
||||
shift
|
||||
|
||||
test -z "$1" && return 0
|
||||
test -n "$major" || return 1
|
||||
test "$major" -gt "$1" && return 0
|
||||
test "$major" -eq "$1" || return 1
|
||||
|
||||
test -z "$2" && return 0
|
||||
test -n "$minor" || return 1
|
||||
test "$minor" -gt "$2" && return 0
|
||||
test "$minor" -eq "$2" || return 1
|
||||
|
||||
test -z "$3" && return 0
|
||||
test "$revision" -ge "$3" 2>/dev/null || return 1
|
||||
}
|
||||
#
|
||||
# Check wheter kernel [dm module] target exist
|
||||
# at least in expected version
|
||||
@ -790,21 +811,7 @@ target_at_least() {
|
||||
version=${version##* v}
|
||||
shift
|
||||
|
||||
local major=$(echo "$version" | cut -d. -f1)
|
||||
test -z "$1" && return 0
|
||||
test -n "$major" || return 1
|
||||
test "$major" -gt "$1" && return 0
|
||||
test "$major" -eq "$1" || return 1
|
||||
|
||||
test -z "$2" && return 0
|
||||
local minor=$(echo "$version" | cut -d. -f2)
|
||||
test -n "$minor" || return 1
|
||||
test "$minor" -gt "$2" && return 0
|
||||
test "$minor" -eq "$2" || return 1
|
||||
|
||||
test -z "$3" && return 0
|
||||
local revision=$(echo "$version" | cut -d. -f3)
|
||||
test "$revision" -ge "$3" 2>/dev/null || return 1
|
||||
version_at_least "$version" "$@"
|
||||
}
|
||||
|
||||
have_thin() {
|
||||
@ -812,7 +819,12 @@ have_thin() {
|
||||
target_at_least dm-thin-pool "$@" || return 1
|
||||
|
||||
# disable thin_check if not present in system
|
||||
which thin_check || lvmconf 'global/thin_check_executable = ""'
|
||||
test -x "$LVM_TEST_THIN_CHECK_CMD" || LVM_TEST_THIN_CHECK_CMD=""
|
||||
test -x "$LVM_TEST_THIN_DUMP_CMD" || LVM_TEST_THIN_DUMP_CMD=""
|
||||
test -x "$LVM_TEST_THIN_REPAIR_CMD" || LVM_TEST_THIN_REPAIR_CMD=""
|
||||
lvmconf "global/thin_check_executable = \"$LVM_TEST_THIN_CHECK_CMD\"" \
|
||||
"global/thin_dump_executable = \"$LVM_TEST_THIN_DUMP_CMD\"" \
|
||||
"global/thin_repair_executable = \"$LVM_TEST_THIN_REPAIR_CMD\""
|
||||
}
|
||||
|
||||
have_raid() {
|
||||
@ -823,6 +835,21 @@ have_raid() {
|
||||
have_cache() {
|
||||
test "$CACHE" = shared -o "$CACHE" = internal || return 1
|
||||
target_at_least dm-cache "$@"
|
||||
|
||||
test -x "$LVM_TEST_CACHE_CHECK_CMD" || LVM_TEST_CACHE_CHECK_CMD=""
|
||||
test -x "$LVM_TEST_CACHE_DUMP_CMD" || LVM_TEST_CACHE_DUMP_CMD=""
|
||||
test -x "$LVM_TEST_CACHE_REPAIR_CMD" || LVM_TEST_CACHE_REPAIR_CMD=""
|
||||
lvmconf "global/cache_check_executable = \"$LVM_TEST_CACHE_CHECK_CMD\"" \
|
||||
"global/cache_dump_executable = \"$LVM_TEST_CACHE_DUMP_CMD\"" \
|
||||
"global/cache_repair_executable = \"$LVM_TEST_CACHE_REPAIR_CMD\""
|
||||
}
|
||||
|
||||
have_tool_at_least() {
|
||||
local version=$($1 -V 2>/dev/null)
|
||||
version=${version%%-*}
|
||||
shift
|
||||
|
||||
version_at_least "$version" "$@"
|
||||
}
|
||||
|
||||
# check if lvm shell is build-in (needs readline)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
@ -16,13 +16,6 @@
|
||||
|
||||
which mkfs.ext2 || skip
|
||||
|
||||
# By default use tools from configuration (exported through Makefile)
|
||||
# Allow user to override location of binaries to take tools from different laces
|
||||
# Maybe check also version of the tools here?
|
||||
test -n "$LVM_TEST_THIN_CHECK_CMD" || LVM_TEST_THIN_CHECK_CMD=$(which thin_check) || skip
|
||||
test -n "$LVM_TEST_THIN_DUMP_CMD" || LVM_TEST_THIN_DUMP_CMD=$(which thin_dump) || skip
|
||||
test -n "$LVM_TEST_THIN_REPAIR_CMD" || LVM_TEST_THIN_REPAIR_CMD=$(which thin_repair) || skip
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
@ -43,73 +36,61 @@ lvcreate -L2 -n fixed $vg
|
||||
lvs -a -o+seg_pe_ranges $vg
|
||||
#aux error_dev "$dev2" 2050:1
|
||||
|
||||
# Make some repairable metadata damage??
|
||||
vgchange -an $vg
|
||||
|
||||
lvconvert --repair $vg/pool
|
||||
|
||||
lvs -a $vg
|
||||
|
||||
# Manual repair steps:
|
||||
# Test swapping - swap out thin-pool's metadata with our repair volume
|
||||
lvconvert -y -f --poolmetadata $vg/repair --thinpool $vg/pool
|
||||
|
||||
lvchange -aey $vg/repair $vg/fixed
|
||||
#
|
||||
# To continue this test - we need real tools available
|
||||
# When they are not present mark test as skipped, but still
|
||||
# let proceed initial part which should work even without tools
|
||||
#
|
||||
aux have_tool_at_least "$LVM_TEST_THIN_CHECK_CMD" 0 3 1 || skip
|
||||
aux have_tool_at_least "$LVM_TEST_THIN_DUMP_CMD" 0 3 1 || skip
|
||||
aux have_tool_at_least "$LVM_TEST_THIN_REPAIR_CMD" 0 3 1 || skip
|
||||
|
||||
#dd if="$DM_DEV_DIR/$vg/repair" of=back bs=1M
|
||||
lvchange -aey $vg/repair $vg/fixed
|
||||
|
||||
# Make some 'repairable' damage??
|
||||
dd if=/dev/zero of="$DM_DEV_DIR/$vg/repair" bs=1 seek=40960 count=1
|
||||
|
||||
#dd if="$DM_DEV_DIR/$vg/repair" of=back_trashed bs=1M
|
||||
#not vgchange -ay $vg
|
||||
not "$LVM_TEST_THIN_CHECK_CMD" "$DM_DEV_DIR/$vg/repair"
|
||||
|
||||
#lvconvert --repair $vg/pool
|
||||
not "$LVM_TEST_THIN_DUMP_CMD" "$DM_DEV_DIR/$vg/repair" | tee dump
|
||||
|
||||
# Using now SHOULD - since thin tools currently do not seem to work
|
||||
should not "$THIN_CHECK" "$DM_DEV_DIR/$vg/repair"
|
||||
"$LVM_TEST_THIN_REPAIR_CMD" -i "$DM_DEV_DIR/$vg/repair" -o "$DM_DEV_DIR/$vg/fixed"
|
||||
|
||||
should not "$LVM_TEST_THIN_DUMP_CMD" "$DM_DEV_DIR/$vg/repair" | tee dump
|
||||
"$LVM_TEST_THIN_DUMP_CMD" --repair "$DM_DEV_DIR/$vg/repair" | tee repaired_xml
|
||||
|
||||
should "$LVM_TEST_THIN_REPAIR_CMD" -i "$DM_DEV_DIR/$vg/repair" -o "$DM_DEV_DIR/$vg/fixed"
|
||||
|
||||
should "$LVM_TEST_THIN_DUMP_CMD" --repair "$DM_DEV_DIR/$vg/repair" | tee repaired_xml
|
||||
|
||||
should "$LVM_TEST_THIN_CHECK_CMD" "$DM_DEV_DIR/$vg/fixed"
|
||||
"$LVM_TEST_THIN_CHECK_CMD" "$DM_DEV_DIR/$vg/fixed"
|
||||
|
||||
# Swap repaired metadata back
|
||||
lvconvert -y -f --poolmetadata $vg/fixed --thinpool $vg/pool
|
||||
|
||||
# Activate pool - this should now work
|
||||
should vgchange -ay $vg
|
||||
vgchange -ay $vg
|
||||
|
||||
lvs -a -o+devices $vg
|
||||
dmsetup table
|
||||
dmsetup info -c
|
||||
dmsetup ls --tree
|
||||
vgchange -an $vg
|
||||
|
||||
# Put back 'broken' metadata
|
||||
lvconvert -y -f --poolmetadata $vg/repair --thinpool $vg/pool
|
||||
|
||||
# Check --repair usage
|
||||
lvconvert -v --repair $vg/pool
|
||||
|
||||
# Check repaired pool could be activated
|
||||
lvchange -ay $vg/pool
|
||||
|
||||
lvchange -an $vg
|
||||
|
||||
# FIXME: Currently in deep troubles - we can't remove thin volume from broken pool
|
||||
should lvremove -ff $vg
|
||||
# Restore damaged metadata
|
||||
lvconvert -y -f --poolmetadata $vg/pool_meta1 --thinpool $vg/pool
|
||||
|
||||
# let's not block PVs with openned _tdata/_tmeta devices
|
||||
aux dmsetup remove $vg-pool_tdata || true
|
||||
aux dmsetup remove $vg-pool_tmeta || true
|
||||
|
||||
dmsetup table
|
||||
|
||||
# FIXME: needs also --yes with double force
|
||||
pvremove --yes -ff "$dev1"
|
||||
pvremove --yes -ff "$dev2"
|
||||
|
||||
# FIXME: pv1 & pv2 are removed so pv3 & pv4 have no real LVs,
|
||||
# yet vgremove is refusing to do its jobs and suggest --partial??
|
||||
should vgremove -ff $vg
|
||||
|
||||
# FIXME: stressing even more - there are no pool PV, we do not pass...
|
||||
should vgreduce --removemissing -f $vg
|
||||
should vgremove -ff $vg
|
||||
|
||||
# Let's do a final forced cleanup
|
||||
pvremove --yes -ff "$dev3"
|
||||
pvremove --yes -ff "$dev4"
|
||||
# Check lvremove -ff works even with damaged pool
|
||||
lvremove -ff $vg
|
||||
|
Loading…
Reference in New Issue
Block a user