Skip to contentSkip to conversation

LVM2/test lvm-utils.sh Makefile.in t-vgmerge-u ...

PATCH [email protected] 1 participant 1 message Jan 16, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2008-01-16 21:21:23

Modified files:
test : lvm-utils.sh Makefile.in t-vgmerge-usage.sh
t-vgsplit-operation.sh
Added files:
test : t-mirror-basic.sh t-mirror-lvconvert.sh
t-pvmove-basic.sh

Log message:
Fix 'make check' runnable with recent versions of dmsetup. Fix 'make check' to use DMDIR to check DM_DEV_DIR support in dmsetup. Add basic test cases for mirrored LV.
Add basic test cases for lvconvert mirror.
Add basic test cases for pvmove.
Jun'ichi Nomura <[email protected]>

Add new vgsplit and vgmerge tests.
Dave Wysochanski <[email protected]>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mirror-basic.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mirror-lvconvert.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvmove-basic.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lvm-utils.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgmerge-usage.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4

/cvs/lvm2/LVM2/test/t-mirror-basic.sh,v --> standard output revision 1.1

- renamed from test/t-mirror-basic.sh +307 -0
@@ -0,0 +1,307 @@
+#!/bin/sh
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2007 NEC Corporation
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+test_description="ensure that pvmove works with basic options"
+privileges_required_=1
+
+. ./test-lib.sh
+
+dmsetup_has_dm_devdir_support_ ||
+{
+  say "Your version of dmsetup lacks support for changing DM_DEVDIR."
+  say "Skipping this test"
+  exit 0
+}
+
+cleanup_()
+{
+  test -n "$vg" && {
+    lvremove -ff $vg
+    vgremove $vg
+  } > /dev/null
+  test -n "$pvs" && {
+    pvremove $pvs > /dev/null
+    for d in $pvs; do
+      dmsetup remove $(basename $d)
+    done
+  }
+  losetup -d $lodev
+  rm -f $lofile
+}
+
+# ---------------------------------------------------------------------
+# config
+
+nr_pvs=5
+pvsize=$((80 * 1024 * 2))
+
+vg=mirror-basic-vg-$$
+lv1=lv1
+lv2=lv2
+lv3=lv3
+
+# ---------------------------------------------------------------------
+# Utilities
+
+pv_()
+{
+  echo "$G_dev_/mapper/pv$1"
+}
+
+lvdev_()
+{
+  echo "$G_dev_/$1/$2"
+}
+
+mimages_are_redundant_ ()
+{
+  local vg=$1
+  local lv=$vg/$2
+  local i
+
+  rm -f out
+  for i in $(lvs -odevices --noheadings $lv | sed 's/([^)]*)//g; s/,/ /g'); do
+    lvs -a -odevices --noheadings $vg/$i | sed 's/([^)]*)//g; s/,/ /g' | \
+      sort | uniq >> out
+  done
+
+  # if any duplication is found, it's not redundant
+  sort out | uniq -d | grep . && return 1
+
+  return 0
+}
+
+lv_is_contiguous_ ()
+{
+  local lv=$1
+
+  # if the lv has multiple segments, it's not contiguous
+  [ $(lvs -a --segments --noheadings $lv | wc -l) -ne 1 ] && return 1
+
+  return 0
+}
+
+lv_is_clung_ ()
+{
+  local lv=$1
+
+  # if any duplication is found, it's not redundant
+  [ $(lvs -a -odevices --noheadings $lv | sed 's/([^)]*)//g' | \
+        sort | uniq | wc -l) -ne 1 ] && return 1
+
+  return 0
+}
+
+mimages_are_contiguous_ ()
+{
+  local vg=$1
+  local lv=$vg/$2
+  local i
+
+  for i in $(lvs -odevices --noheadings $lv | sed 's/([^)]*)//g; s/,/ /g'); do
+    lv_is_contiguous_ $vg/$i || return 1
+  done
+
+  return 0
+}
+
+mimages_are_clung_ ()
+{
+  local vg=$1
+  local lv=$vg/$2
+  local i
+
+  for i in $(lvs -odevices --noheadings $lv | sed 's/([^)]*)//g; s/,/ /g'); do
+    lv_is_clung_ $vg/$i || return 1
+  done
+
+  return 0
+}
+
+mirrorlog_is_on_()
+{
+  local lv="$1"_mlog
+  shift 1
+  lvs -a -odevices --noheadings $lv | sed 's/,/\n/g' > out
+  for d in $*; do grep "$d(" out || return 1; done
+  for d in $*; do grep -v "$d(" out > out2; mv out2 out; done
+  grep . out && return 1
+  return 0
+}
+
+save_dev_sum_()
+{
+  mkfs.ext3 $1 > /dev/null &&
+  md5sum $1 > md5.$(basename $1)
+}
+
+check_dev_sum_()
+{
+  md5sum $1 > md5.tmp && cmp md5.$(basename $1) md5.tmp
+}
+
+# ---------------------------------------------------------------------
+# Initialize PVs and VGs
+
+test_expect_success \
+  'set up temp file and loopback device' \
+  'lofile=$(pwd)/lofile && lodev=$(loop_setup_ "$lofile")'
+
+offset=0
+pvs=
+for n in $(seq 1 $nr_pvs); do
+  test_expect_success \
+      "create pv$n" \
+      'echo "0 $pvsize linear $lodev $offset" > in &&
+       dmsetup create pv$n < in'
+  offset=$(($offset + $pvsize))
+done
+
+for n in $(seq 1 $nr_pvs); do
+  pvs="$pvs $(pv_ $n)"
+done
+
+test_expect_success \
+  "Run this: pvcreate $pvs" \
+  'pvcreate $pvs'
+
+test_expect_success \
+  'set up a VG' \
+  'vgcreate $vg $pvs'
+
+# ---------------------------------------------------------------------
+# Common environment setup/cleanup for each sub testcases
+
+prepare_lvs_()
+{
+  lvremove -ff $vg;
+  :
+}
+
+check_and_cleanup_lvs_()
+{
+  lvs -a -o+devices $vg &&
+  lvremove -ff $vg
+}
+
+test_expect_success "check environment setup/cleanup" \
+  'prepare_lvs_ &&
+   check_and_cleanup_lvs_'
+
+# ---------------------------------------------------------------------
+# mirrored LV tests
+
+# ---
+# create
+
+test_expect_success "create 2-way mirror with disklog from 3 PVs" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mirrorlog_is_on_ $vg/$lv1 $(pv_ 3) &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "create 2-way mirror with corelog from 2 PVs" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $(pv_ 1) $(pv_ 2) &&
+   mimages_are_redundant_ $vg $lv1 &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "create 3-way mirror with disklog from 4 PVs" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m2 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 4) $(pv_ 3):0-1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mirrorlog_is_on_ $vg/$lv1 $(pv_ 3) &&
+   check_and_cleanup_lvs_'
+
+# ---
+# convert
+
+test_expect_success "convert from linear to 2-way mirror" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -n $lv1 $vg $(pv_ 1) &&
+   lvconvert -m+1 $vg/$lv1 $(pv_ 2) $(pv_ 3):0-1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mirrorlog_is_on_ $vg/$lv1 $(pv_ 3) &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "convert from 2-way mirror to linear" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   lvconvert -m-1 $vg/$lv1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "convert from disklog to corelog" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   lvconvert --mirrorlog core $vg/$lv1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "convert from corelog to disklog" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $(pv_ 1) $(pv_ 2) &&
+   lvconvert --mirrorlog disk $vg/$lv1 $(pv_ 3):0-1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mirrorlog_is_on_ $vg/$lv1 $(pv_ 3) &&
+   check_and_cleanup_lvs_'
+
+# ---
+# resize
+
+test_expect_success "extend 2-way mirror" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   lvchange -an $vg/$lv1 &&
+   lvextend -l+2 $vg/$lv1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mimages_are_contiguous_ $vg $lv1 &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "reduce 2-way mirror" \
+  'prepare_lvs_ &&
+   lvcreate -l4 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   lvchange -an $vg/$lv1 &&
+   lvreduce -l-2 $vg/$lv1 &&
+   check_and_cleanup_lvs_'
+
+test_expect_success "extend 2-way mirror (cling if not contiguous)" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0-1 &&
+   lvcreate -l1 -n $lv2 $vg $(pv_ 1) &&
+   lvcreate -l1 -n $lv3 $vg $(pv_ 2) &&
+   lvchange -an $vg/$lv1 &&
+   lvextend -l+2 $vg/$lv1 &&
+   mimages_are_redundant_ $vg $lv1 &&
+   mimages_are_clung_ $vg $lv1 &&
+   check_and_cleanup_lvs_'
+
+# ---
+# failure cases
+
+test_expect_failure "create 2-way mirror with disklog from 2 PVs" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2)'
+test_expect_success "(cleanup previous test)" \
+  'check_and_cleanup_lvs_'
+
+test_expect_failure "convert linear to 2-way mirror with 1 PV" \
+  'prepare_lvs_ &&
+   lvcreate -l2 -n $lv1 $vg $(pv_ 1) &&
+   lvconvert -m+1 --mirrorlog core $vg/$lv1 $(pv_ 1)'
+test_expect_success "(cleanup previous test)" \
+  'check_and_cleanup_lvs_'
+
+# ---------------------------------------------------------------------
+
+test_done

/cvs/lvm2/LVM2/test/t-mirror-lvconvert.sh,v --> standard output revision 1.1

- renamed from test/t-mirror-lvconvert.sh +392 -0

392 lines not on this page · raw message

/cvs/lvm2/LVM2/test/t-pvmove-basic.sh,v --> standard output revision 1.1

- renamed from test/t-pvmove-basic.sh +428 -0

428 lines not on this page · raw message

test/lvm-utils.sh +2 -1
@@ -70,7 +70,8 @@
   # Detect support for the envvar.  If it's supported, the
   # following command will fail with the expected diagnostic.
   out=$(DM_DEV_DIR=j dmsetup version 2>&1)
-  test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value."
+  test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value." -o \
+       "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value."
 }
 
 # set up private /dev and /etc
test/Makefile.in +1 -0
@@ -56,6 +56,7 @@
 	for i in lvm $$(cat $(top_srcdir)/tools/.commands); do \
 	  ln -s ../lvm-wrapper bin/$$i; \
 	done
+	test -n "@DMDIR@" && ln -s "@DMDIR@/dmsetup/dmsetup" bin/dmsetup
 	touch $@
 
 lvm-wrapper: Makefile
test/t-vgmerge-usage.sh +24 -23

54 lines not on this page · raw message

test/t-vgsplit-operation.sh +26 -0
@@ -98,6 +98,32 @@
    vgremove $vg2 &&
    vgremove $vg1'
 
+test_expect_success \
+  'vgsplit rejects vg with active lv' \
+  'vgcreate $vg1 $d1 $d2 &&
+   vgcreate $vg2 $d3 $d4 &&
+   lvcreate -l 4 -n lv1 $vg1 &&
+   vgsplit $vg1 $vg2 $d1 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Logical volumes in \"$vg1\" must be inactive\$" err &&
+   vgremove -f $vg2 &&
+   vgremove -f $vg1'
+
+test_expect_success \
+  'vgsplit rejects split because max_lv is exceeded' \
+  'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
+   vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
+   lvcreate -l 4 -n lv1 $vg1 &&
+   lvcreate -l 4 -n lv2 $vg1 &&
+   lvcreate -l 4 -n lv3 $vg2 &&
+   vgchange -an $vg1 &&
+   vgchange -an $vg2 &&
+   vgsplit $vg1 $vg2 $d1 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Maximum number of logical volumes (2) exceeded" err &&
+   vgremove -f $vg2 &&
+   vgremove -f $vg1'
+
 test_done
 # Local Variables:
 # indent-tabs-mode: nil