summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2016-06-13 14:35:09 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2016-06-23 14:59:29 +0200
commita67a5d465576d4a7c17b22a737725d6dee059e18 (patch)
tree56aeb61a650cdaea459ddbb79882bf1943859345
parent83d483269de367facc14eee9072b79ffabdcaf82 (diff)
downloadlvm2-a67a5d465576d4a7c17b22a737725d6dee059e18.tar.gz
tests: aux prepare_thin_metadata
-rw-r--r--test/lib/aux.sh23
-rw-r--r--test/shell/lvextend-thin-full.sh18
-rw-r--r--test/shell/thin-flags.sh20
3 files changed, 25 insertions, 36 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d51a65c58..865314944 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -354,6 +354,29 @@ prepare_lvmdbusd() {
echo ok
}
+#
+# Temporary solution to create some occupied thin metadata
+# This heavily depends on thin metadata output format to stay as is.
+# Currently it expects 2MB thin metadata and 200MB data volume size
+# Argument specifies how many devices should be created.
+#
+prepare_thin_metadata() {
+ local devices=$1
+ local transaction_id=${2:-0}
+ local data_block_size=${3:-128}
+ local nr_data_blocks=${4:-3200}
+ local i
+
+ echo '<superblock uuid="" time="1" transaction="'$transaction_id'" data_block_size="'$data_block_size'" nr_data_blocks="'$nr_data_blocks'">'
+ for i in $(seq 1 $devices)
+ do
+ echo ' <device dev_id="'$i'" mapped_blocks="37" transaction="'$i'" creation_time="0" snap_time="1">'
+ echo ' <range_mapping origin_begin="0" data_begin="0" length="37" time="0"/>'
+ echo ' </device>'
+ done
+ echo "</superblock>"
+}
+
teardown_devs_prefixed() {
local prefix=$1
local stray=${2:-0}
diff --git a/test/shell/lvextend-thin-full.sh b/test/shell/lvextend-thin-full.sh
index cd4705dcf..8fc89a841 100644
--- a/test/shell/lvextend-thin-full.sh
+++ b/test/shell/lvextend-thin-full.sh
@@ -25,22 +25,6 @@ aux have_thin 1 0 0 || skip
test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_restore) || skip
"$LVM_TEST_THIN_RESTORE_CMD" -V || skip
-#
-# Temporary solution to create some occupied thin metadata
-# This heavily depends on thin metadata output format to stay as is.
-# Currently it expects 2MB thin metadata and 200MB data volume size
-# Argument specifies how many devices should be created.
-fake_metadata_() {
- echo '<superblock uuid="" time="1" transaction="'$2'" data_block_size="128" nr_data_blocks="3200">'
- for i in $(seq 1 $1)
- do
- echo ' <device dev_id="'$i'" mapped_blocks="37" transaction="0" creation_time="0" snap_time="1">'
- echo ' <range_mapping origin_begin="0" data_begin="0" length="37" time="0"/>'
- echo ' </device>'
- done
- echo "</superblock>"
-}
-
aux have_thin 1 10 0 || skip
aux prepare_pvs 3 256
@@ -50,7 +34,7 @@ vgcreate -s 1M $vg $(cat DEVICES)
aux lvmconf 'activation/thin_pool_autoextend_percent = 30' \
'activation/thin_pool_autoextend_threshold = 70'
-fake_metadata_ 400 0 >data
+aux prepare_thin_metadata 400 0 | tee data
lvcreate -L200 -T $vg/pool
lvchange -an $vg
diff --git a/test/shell/thin-flags.sh b/test/shell/thin-flags.sh
index 3fcafb291..395b98d16 100644
--- a/test/shell/thin-flags.sh
+++ b/test/shell/thin-flags.sh
@@ -16,24 +16,6 @@ SKIP_WITH_LVMPOLLD=1
export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
-
-# TODO - aux/get support for this....
-fake_metadata_() {
- echo '<superblock uuid="" time="0" transaction="'$2'" data_block_size="128" nr_data_blocks="3200">'
- echo ' <device dev_id="1" mapped_blocks="0" transaction="0" creation_time="0" snap_time="0">'
- echo ' </device>'
- for i in $(seq 10 $1)
- do
- echo ' <device dev_id="'$i'" mapped_blocks="30" transaction="0" creation_time="0" snap_time="0">'
- echo ' <range_mapping origin_begin="0" data_begin="0" length="29" time="0"/>'
- echo ' </device>'
- set +x
- done
- echo "</superblock>"
- set -x
-}
-
-
. lib/inittest
#
@@ -85,7 +67,7 @@ aux lvmconf 'global/thin_check_executable = ""'
# Prepare some fake metadata prefilled to ~100%
lvcreate -L2 -n $lv1 $vg # tmp for metadata
-fake_metadata_ 500 1 >data
+aux prepare_thin_metadata 500 1 | tee data
"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
# Swap volume with restored fake metadata