master - tests: enhance pvmove testing
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbb732bd8eb5308eeb1dc7cc6d747552844018ac Commit: fbb732bd8eb5308eeb1dc7cc6d747552844018ac Parent: 47b7cc6850091aac9d32070ad3c3a727bae5f188 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Sep 16 11:18:31 2013 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Sep 16 11:22:04 2013 +0200
tests: enhance pvmove testing
Rewrite check lv_on and add new lv_tree_on
Move more pvmove test unrelated code out to check & get sections (so they do not obfuscate trace output unnecesserily)
Use new lv_tree_on()
NOTE: unsure how the snapshot origin should be accounted here.
Split pmove-all-segments into separate tests for raid and thins (so the test output properly shows what has been skipped in test)
--- test/lib/check.sh | 40 ++++- test/lib/get.sh | 34 ++++ test/shell/pvmove-all-segtypes.sh | 300 +++++----------------------------- test/shell/pvmove-basic.sh | 311 ++++++++++++++++-------------------- test/shell/pvmove-raid-segtypes.sh | 79 +++++++++ test/shell/pvmove-thin-segtypes.sh | 83 ++++++++++ 6 files changed, 410 insertions(+), 437 deletions(-)
test/lib/check.sh +32 -8
@@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. +# Copyright (C) 2010-2013 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
@@ -54,14 +54,38 @@ mirror_images_redundant() { $(cat check.tmp.all) } +lv_err_list_() { + (echo "$2" | not grep -m 1 -q "$1") || \ + echo "$3 on [ $(echo "$2" | grep "$1" | cut -b3- | tr '\n' ' ')] " +} + +lv_on_diff_() { + declare -a devs=("${!1}") # pass in shell array + local expect=( "${@:4}" ) # make an array starting from 4th args... + local diff_e + + # Find diff between 2 shell arrays, print them as stdin files + diff_e=$(diff <(printf "%s\n" "${expect[@]}" | sort | uniq ) <(printf "%s\n" "${devs[@]}") ) || + die "LV $2/$3 $(lv_err_list_ "^>" "${diff_e}" found)$(lv_err_list_ "^<" "${diff_e}" "not found")." +} + +# list devices for given LV lv_on() { - local lv=$1/$2 - (lvdevices $lv | grep -F "$3") || \ - die "LV $lv expected on $3 but is not:" \ - $(lvdevices $lv) - test $(lvdevices $lv | grep -vF "$3" | wc -l) -eq 0 || \ - die "LV $lv contains unexpected devices:" \ - $(lvdevices $lv) + local devs + + devs=( $(lvdevices "$1/$2" | sort | uniq ) ) + + lv_on_diff_ devs[@] "${@}" +} + +# list devices for given LV and all its subdevices +lv_tree_on() { + local devs + + # Get sorted list of devices + devs=( $(get lv_tree_devices "$1" "$2") ) + + lv_on_diff_ devs[@] "${@}" } mirror_images_on() {
test/lib/get.sh +34 -0
@@ -43,6 +43,40 @@ lv_devices() { lv_field "$1" devices -a "${@:2}" | sed 's/([^)]*)//g; s/,/\n/g' } +lv_field_lv_() { + lv_field "$1" "$2" -a --unbuffered | sed 's/\[//; s/]//' +} + +lv_tree_devices_() { + local lv="$1/$2" + local type=$(lv_field "$lv" segtype -a --unbuffered | head -n 1) + local orig=$(lv_field_lv_ "$lv" origin) + # FIXME: should we count in also origins ? + #test -z "$orig" || lv_tree_devices_ $1 $orig + case "$type" in + linear|striped) + lv_devices "$lv" + ;; + mirror|raid*) + local log=$(lv_field_lv_ "$lv" mirror_log) + test -z "$log" || lv_tree_devices_ "$1" "$log" + for i in $(lv_devices "$lv") + do lv_tree_devices_ "$1" "$i"; done + ;; + thin) + lv_tree_devices_ "$1" "$(lv_field_lv_ $lv pool_lv)" + ;; + thin-pool) + lv_tree_devices_ "$1" "$(lv_field_lv_ $lv data_lv)" + lv_tree_devices_ "$1" "$(lv_field_lv_ $lv metadata_lv)" + ;; + esac +} + +lv_tree_devices() { + lv_tree_devices_ "$@" | sort | uniq +} + #set -x unset LVM_VALGRIND "$@"
test/shell/pvmove-all-segtypes.sh +44 -256
340 lines not on this page · raw message
test/shell/pvmove-basic.sh +138 -173
488 lines not on this page · raw message
test/shell/pvmove-raid-segtypes.sh new file +79 -0
79 lines not on this page · raw message
test/shell/pvmove-thin-segtypes.sh new file +83 -0
83 lines not on this page · raw message