2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2012-03-16 17:00:05 +04:00
# Copyright (C) 2007-2011 Red Hat, Inc. All rights reserved.
2008-03-04 22:48:32 +03:00
#
# 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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2008-03-04 22:48:32 +03:00
2008-09-30 19:20:09 +04:00
# Test vgsplit command options for validity
2008-03-04 22:48:32 +03:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2008-03-04 22:48:32 +03:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2008-09-30 19:20:09 +04:00
aux prepare_devs 5
2008-03-04 22:48:32 +03:00
2016-03-03 01:49:32 +03:00
if test -n " $LVM_TEST_LVM1 " ; then
mdatypes = '1 2'
else
mdatypes = '2'
fi
for mdatype in $mdatypes
2008-07-17 07:17:01 +04:00
do
2008-09-30 19:20:09 +04:00
2011-01-05 03:16:18 +03:00
pvcreate -M$mdatype $( cat DEVICES)
2008-09-30 19:20:09 +04:00
2009-09-02 22:31:11 +04:00
# ensure name order does not matter
2009-09-02 23:38:53 +04:00
# NOTE: if we're using lvm1, we must use -M on vgsplit
2011-01-05 03:16:18 +03:00
vgcreate -M$mdatype $vg1 $( cat DEVICES)
2012-03-16 17:00:05 +04:00
vgsplit -M$mdatype $vg1 $vg2 " $dev1 "
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2011-01-05 03:16:18 +03:00
vgcreate -M$mdatype $vg2 $( cat DEVICES)
2012-03-16 17:00:05 +04:00
vgsplit -M$mdatype $vg2 $vg1 " $dev1 "
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2009-09-02 22:31:11 +04:00
2008-09-30 19:20:09 +04:00
# vgsplit accepts new vg as destination of split
2008-11-10 15:43:35 +03:00
# lvm1 -- bz244792
2011-01-05 03:16:18 +03:00
vgcreate -M$mdatype $vg1 $( cat DEVICES)
2012-03-16 17:00:05 +04:00
vgsplit $vg1 $vg2 " $dev1 " 1>err
grep " New volume group \" $vg2 \" successfully split from \" $vg1 \" " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit accepts existing vg as destination of split
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype $vg2 " $dev3 " " $dev4 "
vgsplit $vg1 $vg2 " $dev1 " 1>err
grep " Existing volume group \" $vg2 \" successfully split from \" $vg1 \" " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit accepts --maxphysicalvolumes 128 on new VG
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
vgsplit --maxphysicalvolumes 128 $vg1 $vg2 " $dev1 "
check vg_field $vg2 max_pv 128
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit accepts --maxlogicalvolumes 128 on new VG
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
vgsplit --maxlogicalvolumes 128 $vg1 $vg2 " $dev1 "
check vg_field $vg2 max_lv 128
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit rejects split because max_pv of destination would be exceeded
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 " $dev3 " " $dev4 "
not vgsplit $vg1 $vg2 " $dev1 " 2>err;
grep "Maximum number of physical volumes (2) exceeded" err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit rejects split because maxphysicalvolumes given with existing vg
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 " $dev3 " " $dev4 "
not vgsplit --maxphysicalvolumes 2 $vg1 $vg2 " $dev1 " 2>err;
grep " Volume group \" $vg2 \" exists, but new VG option specified " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit rejects split because maxlogicalvolumes given with existing vg
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 " $dev3 " " $dev4 "
not vgsplit --maxlogicalvolumes 2 $vg1 $vg2 " $dev1 " 2>err
grep " Volume group \" $vg2 \" exists, but new VG option specified " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
2008-10-01 01:43:55 +04:00
# vgsplit rejects split because alloc given with existing vg
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --alloc cling $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --alloc cling $vg2 " $dev3 " " $dev4 "
not vgsplit --alloc cling $vg1 $vg2 " $dev1 " 2>err;
grep " Volume group \" $vg2 \" exists, but new VG option specified " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
2008-10-01 01:43:55 +04:00
# vgsplit rejects split because clustered given with existing vg
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --clustered n $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --clustered n $vg2 " $dev3 " " $dev4 "
not vgsplit --clustered n $vg1 $vg2 " $dev1 " 2>err
grep " Volume group \" $vg2 \" exists, but new VG option specified " err
2011-03-28 15:35:20 +04:00
vgremove $vg1 $vg2
2008-09-30 19:20:09 +04:00
2008-10-01 01:43:55 +04:00
# vgsplit rejects vg with active lv
2012-03-16 17:00:05 +04:00
pvcreate -M$mdatype -ff " $dev3 " " $dev4 "
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype $vg2 " $dev3 " " $dev4 "
lvcreate -l 4 -n $lv1 $vg1
not vgsplit $vg1 $vg2 " $dev1 " 2>err;
grep " Logical volumes in \" $vg1 \" must be inactive\$ " err
2011-03-28 15:35:20 +04:00
vgremove -f $vg1 $vg2
2008-09-30 19:20:09 +04:00
2008-10-01 01:43:55 +04:00
# vgsplit rejects split because max_lv is exceeded
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 " $dev3 " " $dev4 "
lvcreate -l 4 -n $lv1 $vg1
lvcreate -l 4 -n $lv2 $vg1
lvcreate -l 4 -n $lv3 $vg2
2011-03-28 15:35:20 +04:00
vgchange -an $vg1 $vg2
2012-03-16 17:00:05 +04:00
not vgsplit $vg1 $vg2 " $dev1 " 2>err;
grep "Maximum number of logical volumes (2) exceeded" err
2011-03-28 15:35:20 +04:00
vgremove -f $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit verify default - max_lv attribute from new VG is same as source VG" \
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
lvcreate -l 4 -n $lv1 $vg1
vgchange -an $vg1
vgsplit $vg1 $vg2 " $dev1 "
check compare_vg_field $vg1 $vg2 max_lv
2011-03-28 15:35:20 +04:00
vgremove -f $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit verify default - max_pv attribute from new VG is same as source VG" \
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
lvcreate -l 4 -n $lv1 $vg1
vgchange -an $vg1
vgsplit $vg1 $vg2 " $dev1 "
check compare_vg_field $vg1 $vg2 max_pv
2011-03-28 15:35:20 +04:00
vgremove -f $vg1 $vg2
2008-09-30 19:20:09 +04:00
# vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
lvcreate -l 4 -n $lv1 $vg1
vgchange -an $vg1
vgsplit $vg1 $vg2 " $dev1 "
check compare_vg_field $vg1 $vg2 vg_fmt
2011-03-28 15:35:20 +04:00
vgremove -f $vg2 $vg1
2008-09-30 19:20:09 +04:00
2008-10-01 01:43:55 +04:00
# vgsplit rejects split because PV not in VG
2012-03-16 17:00:05 +04:00
vgcreate -M$mdatype $vg1 " $dev1 " " $dev2 "
vgcreate -M$mdatype $vg2 " $dev3 " " $dev4 "
lvcreate -l 4 -n $lv1 $vg1
lvcreate -l 4 -n $lv2 $vg1
vgchange -an $vg1
not vgsplit $vg1 $vg2 " $dev3 " 2>err;
2011-03-28 15:35:20 +04:00
vgremove -f $vg2 $vg1
2016-04-25 22:22:42 +03:00
# Restart clvm because using the same
# devs as lvm1 and then lvm2 causes problems.
if test -e LOCAL_CLVMD ; then
2017-07-10 11:40:09 +03:00
kill " $( < LOCAL_CLVMD) "
2016-04-25 22:22:42 +03:00
for i in $( seq 1 100) ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
pgrep clvmd || break
sleep .1
done # wait for the pid removal
aux prepare_clvmd
fi
2008-08-28 14:59:10 +04:00
done
2016-04-25 22:22:42 +03:00
if test -z " $LVM_TEST_LVM1 " ; then
2008-09-30 19:20:09 +04:00
# ONLY LVM2 metadata
# setup PVs" '
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 0 " $dev5 "
2008-09-30 19:20:09 +04:00
# vgsplit rejects to give away pv with the last mda copy
2012-03-16 17:00:05 +04:00
vgcreate $vg1 " $dev5 " " $dev2 "
lvcreate -l 10 -n $lv1 $vg1
lvchange -an $vg1 /$lv1
check pvlv_counts $vg1 2 1 0
not vgsplit $vg1 $vg2 " $dev5 " ;
check pvlv_counts $vg1 2 1 0
vgremove -f $vg1
2008-09-30 19:20:09 +04:00
# vgsplit rejects split because metadata types differ
2012-03-16 17:00:05 +04:00
pvcreate -ff -M1 " $dev3 " " $dev4 "
pvcreate -ff " $dev1 " " $dev2 "
vgcreate -M1 $vg1 " $dev3 " " $dev4 "
vgcreate $vg2 " $dev1 " " $dev2 "
not vgsplit $vg1 $vg2 " $dev3 " 2>err;
grep "Metadata types differ" err
vgremove -f $vg1 $vg2
2016-03-03 01:49:32 +03:00
fi