[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH vgsplit 4/4] Update vgsplit tests to cover LVs on the cmdline.



--- a/test/lvm-utils.sh
+++ b/test/lvm-utils.sh
@@ -63,7 +63,7 @@ check_vg_field_()
 {
 if test "$verbose" = "t"
 then
-  echo "check_vg_field_ actual: `vgs --noheadings -o $2 $1` expected $3"
+  echo "check_vg_field_ VG: $1 actual: `vgs --noheadings -o $2 $1` expected $3"
 fi
   return $(test $(vgs --noheadings -o $2 $1) == $3)
 }
@@ -72,7 +72,7 @@ check_pv_field_()
 {
 if test "$verbose" = "t"
 then
-  echo "check_pv_field_ actual: `pvs --noheadings -o $2 $1` expected $3"
+  echo "check_pv_field_ PV: $1 actual: `pvs --noheadings -o $2 $1` expected $3"
 fi
   return $(test $(pvs --noheadings -o $2 $1) == $3)
 }
@@ -81,7 +81,7 @@ check_lv_field_()
 {
 if test "$verbose" = "t"
 then
-  echo "check_lv_field_ actual: `lvs --noheadings -o $2 $1` expected $3"
+  echo "check_lv_field_ LV: $1 actual: `lvs --noheadings -o $2 $1` expected $3"
 fi
   return $(test $(lvs --noheadings -o $2 $1) == $3)
 }
diff --git a/test/t-vgsplit-operation.sh b/test/t-vgsplit-operation.sh
index b8ef45b..5947740 100755
--- a/test/t-vgsplit-operation.sh
+++ b/test/t-vgsplit-operation.sh
@@ -56,15 +56,24 @@ test_expect_success \
 #
 for i in new existing
 do
+#
+# We can have PVs or LVs on the cmdline
+#
+for j in PV LV
+do
 test_expect_success \
-  "vgsplit correctly splits single linear LV into $i VG" \
+  "vgsplit correctly splits single linear LV into $i VG ($j args)" \
   'vgcreate $vg1 $d1 $d2 &&
    if [ $i == existing ]; then
       vgcreate $vg2 $d3 $d4
    fi &&
    lvcreate -l 4 -n $lv1 $vg1 $d1 &&
    vgchange -an $vg1 &&
-   vgsplit $vg1 $vg2 $d1 &&
+   if [ $j == PV ]; then
+     vgsplit --force $vg1 $vg2 $d1
+   else
+     vgsplit --force $vg1 $vg2 $lv1
+   fi &&
    vg_validate_pvlv_counts_ $vg1 1 0 0 &&
    if [ $i == existing ]; then
       vg_validate_pvlv_counts_ $vg2 3 1 0
@@ -76,14 +85,18 @@ test_expect_success \
    vgremove -f $vg1'
 
 test_expect_success \
-  "vgsplit correctly splits single striped LV into $i VG" \
+  "vgsplit correctly splits single striped LV into $i VG ($j args)" \
   'vgcreate $vg1 $d1 $d2 &&
    if [ $i == existing ]; then
       vgcreate $vg2 $d3 $d4
    fi &&
    lvcreate -l 4 -i 2 -n $lv1 $vg1 $d1 $d2 &&
    vgchange -an $vg1 &&
-   vgsplit $vg1 $vg2 $d1 $d2 &&
+   if [ $j == PV ]; then
+     vgsplit --force $vg1 $vg2 $d1 $d2
+   else
+     vgsplit --force $vg1 $vg2 $lv1
+   fi &&
    if [ $i == existing ]; then
      vg_validate_pvlv_counts_ $vg2 4 1 0
    else
@@ -93,7 +106,7 @@ test_expect_success \
    vgremove -f $vg2'
 
 test_expect_success \
-  "vgsplit correctly splits origin and snapshot LV into $i VG" \
+  "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" \
   'vgcreate $vg1 $d1 $d2 &&
    if [ $i == existing ]; then
      vgcreate $vg2 $d3 $d4
@@ -101,7 +114,11 @@ test_expect_success \
    lvcreate -l 64 -i 2 -n $lv1 $vg1 $d1 $d2 &&
    lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 &&
    vgchange -an $vg1 &&
-   vgsplit $vg1 $vg2 $d1 $d2 &&
+   if [ $j == PV ]; then
+     vgsplit --force $vg1 $vg2 $d1 $d2
+   else
+     vgsplit --force $vg1 $vg2 $lv1 $lv2
+   fi &&
    if [ $i == existing ]; then
      vg_validate_pvlv_counts_ $vg2 4 1 1
    else
@@ -112,14 +129,18 @@ test_expect_success \
    vgremove -f $vg2'
 
 test_expect_success \
-  "vgsplit correctly splits mirror LV into $i VG" \
+  "vgsplit correctly splits mirror LV into $i VG ($j args)" \
   'vgcreate $vg1 $d1 $d2 $d3 &&
    if [ $i == existing ]; then
      vgcreate $vg2 $d4
    fi &&
    lvcreate -l 64 -m1 -n $lv1 $vg1 $d1 $d2 $d3 &&
    vgchange -an $vg1 &&
-   vgsplit $vg1 $vg2 $d1 $d2 $d3 &&
+   if [ $j == PV ]; then
+     vgsplit --force $vg1 $vg2 $d1 $d2 $d3
+   else
+     vgsplit --force $vg1 $vg2 $lv1
+   fi &&
    if [ $i == existing ]; then
      vg_validate_pvlv_counts_ $vg2 4 4 0
    else
@@ -128,8 +149,91 @@ test_expect_success \
    lvremove -f $vg2/$lv1 &&
    vgremove -f $vg2'
 done
+done
+
+#
+# Test more complex setups where the code has to find associated PVs and
+# LVs to split the VG correctly
+# 
+test_expect_success \
+  "vgsplit correctly splits 3 striped LVs into VG when only 1 LV specified" \
+  'vgcreate $vg1 $d1 $d2 $d3 $d4 &&
+   lvcreate -l 4 -n $lv1 -i 2 $vg1 $d1 $d2 &&
+   lvcreate -l 4 -n $lv2 -i 2 $vg1 $d2 $d3 &&
+   lvcreate -l 4 -n $lv3 -i 2 $vg1 $d3 $d4 &&
+   vgchange -an $vg1 &&
+   vgsplit --force $vg1 $vg2 $lv1 &&
+   vg_validate_pvlv_counts_ $vg2 4 3 0 &&
+   lvremove -f $vg2/$lv1 &&
+   lvremove -f $vg2/$lv2 &&
+   lvremove -f $vg2/$lv3 &&
+   vgremove -f $vg2'
+
+test_expect_success \
+  "vgsplit correctly splits one LV with 2 snapshots, only origin LV specified" \
+  'vgcreate $vg1 $d1 $d2 $d3 $d4 &&
+   lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 &&
+   lvcreate -l 4 -n $lv2 -s $vg1/$lv1 &&
+   lvcreate -l 4 -n $lv3 -s $vg1/$lv1 &&
+   vg_validate_pvlv_counts_ $vg1 4 1 2 &&
+   vgchange -an $vg1 &&
+   vgsplit --force $vg1 $vg2 $lv1 &&
+   vg_validate_pvlv_counts_ $vg1 1 0 0 &&
+   vg_validate_pvlv_counts_ $vg2 3 1 2 &&
+   lvremove -f $vg2/$lv2 &&
+   lvremove -f $vg2/$lv3 &&
+   lvremove -f $vg2/$lv1 &&
+   vgremove -f $vg1 &&
+   vgremove -f $vg2'
+
+test_expect_success \
+  "vgsplit correctly splits one LV with 2 snapshots, only snapshot LV specified" \
+  'vgcreate $vg1 $d1 $d2 $d3 $d4 &&
+   lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 &&
+   lvcreate -l 4 -n $lv2 -s $vg1/$lv1 &&
+   lvcreate -l 4 -n $lv3 -s $vg1/$lv1 &&
+   vg_validate_pvlv_counts_ $vg1 4 1 2 &&
+   vgchange -an $vg1 &&
+   vgsplit --force $vg1 $vg2 $lv2 &&
+   vg_validate_pvlv_counts_ $vg1 1 0 0 &&
+   vg_validate_pvlv_counts_ $vg2 3 1 2 &&
+   lvremove -f $vg2/$lv2 &&
+   lvremove -f $vg2/$lv3 &&
+   lvremove -f $vg2/$lv1 &&
+   vgremove -f $vg1 &&
+   vgremove -f $vg2'
+
+test_expect_success \
+  "vgsplit correctly splits one mirror LV, only one PV specified" \
+  'vgcreate $vg1 $d1 $d2 $d3 $d4 &&
+   lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 &&
+   vg_validate_pvlv_counts_ $vg1 4 4 0 &&
+   vgchange -an $vg1 &&
+   vgsplit --force $vg1 $vg2 $d2 &&
+   vg_validate_pvlv_counts_ $vg1 1 0 0 &&
+   vg_validate_pvlv_counts_ $vg2 3 4 0 &&
+   lvremove -f $vg2/$lv1 &&
+   vgremove -f $vg1 &&
+   vgremove -f $vg2'
+
+test_expect_success \
+  "vgsplit correctly splits 1 mirror + 1 striped LV, only striped LV specified" \
+  'vgcreate $vg1 $d1 $d2 $d3 $d4 &&
+   lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 &&
+   lvcreate -l 16 -n $lv2 -i 2 $vg1 $d3 $d4 &&
+   vg_validate_pvlv_counts_ $vg1 4 5 0 &&
+   vgchange -an $vg1 &&
+   vgsplit --force $vg1 $vg2 $lv2 &&
+   vg_validate_pvlv_counts_ $vg2 4 5 0 &&
+   lvremove -f $vg2/$lv1 &&
+   lvremove -f $vg2/$lv2 &&
+   vgremove -f $vg2'
 
 test_done
+
+#vgssplit_test_complex_splits_()
+# vgssplit_test_basic_splits_()
+
 # Local Variables:
 # indent-tabs-mode: nil
 # End:
diff --git a/tools/commands.h b/tools/commands.h
index 6b51582..b03cc96 100644

-- 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]