diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-03-16 13:00:05 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-03-16 13:00:05 +0000 |
commit | 351be15dc481a130ca880121b53f849e1053c687 (patch) | |
tree | 953399bafee31d9bc34e82166efefcfb44e1e7f1 /test/shell/lvconvert-mirror-basic.sh | |
parent | cce2475889ae32e8bfff6d35dc797e6054372120 (diff) | |
download | lvm2-351be15dc481a130ca880121b53f849e1053c687.tar.gz lvm2-351be15dc481a130ca880121b53f849e1053c687.tar.xz lvm2-351be15dc481a130ca880121b53f849e1053c687.zip |
Update tests
Indent
Shell improvements - use internal function for checks
Use PVs in "" (LV and VG cannot have spaces)
Several test very starting 'dmeventd' without annoucing
it via prepade_dmeventd.
Fix some of test actually.
Diffstat (limited to 'test/shell/lvconvert-mirror-basic.sh')
-rw-r--r-- | test/shell/lvconvert-mirror-basic.sh | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/test/shell/lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh index 8d398632..a0f50f6d 100644 --- a/test/shell/lvconvert-mirror-basic.sh +++ b/test/shell/lvconvert-mirror-basic.sh @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +#!/bin/sh +# Copyright (C) 2010-2012 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 @@ -10,15 +11,12 @@ . lib/test -log_name_to_count() -{ - if [ "$1" = "mirrored" ]; then - echo 2 - elif [ "$1" = "disk" ]; then - echo 1 - else - echo 0 - fi +log_name_to_count() { + case "$1" in + mirrored) echo 2 ;; + disk) echo 1 ;; + *) echo 0 ;; + esac } # FIXME: For test_[up|down]convert, I'd still like to be able @@ -38,15 +36,14 @@ log_name_to_count() # 2-way disk-log mirror while not active # -> test_lvconvert 2 disk 3 disk 0 -test_lvconvert() -{ +test_lvconvert() { local start_count=$1 local start_count_p1=$(($start_count + 1)) local start_log_type=$2 local finish_count=$3 local finish_count_p1=$(($finish_count + 1)) local finish_log_type=$4 - local dev_array=($dev1 $dev2 $dev3 $dev4 $dev5) + local dev_array=("$dev1" "$dev2" "$dev3" "$dev4" "$dev5") local start_log_count local finish_log_count local max_log_count @@ -58,19 +55,15 @@ test_lvconvert() #test $finish_count -gt $start_count && up=true # Do we have enough devices for the mirror images? - if [ $start_count_p1 -gt ${#dev_array[@]} ]; then - echo "Action requires too many devices" - return 1 - fi + test $start_count_p1 -gt ${#dev_array[@]} && \ + die "Action requires too many devices" # Do we have enough devices for the mirror images? - if [ $finish_count_p1 -gt ${#dev_array[@]} ]; then - echo "Action requires too many devices" - return 1 - fi + test $finish_count_p1 -gt ${#dev_array[@]} && \ + die "Action requires too many devices" - start_log_count=`log_name_to_count $start_log_type` - finish_log_count=`log_name_to_count $finish_log_type` + start_log_count=$(log_name_to_count $start_log_type) + finish_log_count=$(log_name_to_count $finish_log_type) if [ $finish_log_count -gt $start_log_count ]; then max_log_count=$finish_log_count else @@ -92,9 +85,7 @@ test_lvconvert() fi lvs -a -o name,copy_percent,devices $vg - if ! $active; then - lvchange -an $vg/$lv1 - fi + test $active || lvchange -an $vg/$lv1 # Are there extra devices for the log or do we overlap if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then @@ -104,9 +95,7 @@ test_lvconvert() lvconvert -m $finish_count --mirrorlog $finish_log_type \ $vg/$lv1 $alloc - if ! $active; then - lvchange -ay $vg/$lv1 - fi + test $active || lvchange -ay $vg/$lv1 check mirror_no_temporaries $vg $lv1 if [ "$finish_count_p1" -eq 1 ]; then |