2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2008-08-12 14:04:31 +04:00
# Copyright (C) 2008 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
# 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-08-12 14:04:31 +04:00
2008-10-06 20:47:07 +04:00
# 'Test pvchange option values'
2008-08-12 14:04:31 +04:00
2018-05-24 17:49:48 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2008-08-12 14:04:31 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-03-28 14:38:50 +04:00
check_changed_uuid_( ) {
test " $1 " != " $( get pv_field " $2 " uuid) " || die "UUID has not changed!"
}
aux prepare_pvs 4
2008-08-12 14:04:31 +04:00
2014-07-07 15:58:42 +04:00
# check 'allocatable' pv attribute
2014-10-07 11:54:47 +04:00
pvcreate " $dev1 "
2016-02-26 18:46:37 +03:00
check pv_field " $dev1 " pv_attr ---
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev1 "
2016-02-26 18:46:37 +03:00
check pv_field " $dev1 " pv_attr a--
2014-07-07 15:58:42 +04:00
pvchange --allocatable n " $dev1 "
2016-02-26 18:46:37 +03:00
check pv_field " $dev1 " pv_attr u--
2014-07-07 15:58:42 +04:00
vgremove -ff $vg1
not pvchange --allocatable y " $dev1 "
pvremove -ff " $dev1 "
2012-03-16 17:00:05 +04:00
for mda in 0 1 2
2008-08-12 14:04:31 +04:00
do
2012-03-16 17:00:05 +04:00
# "setup pv with metadatacopies = $mda"
pvcreate --metadatacopies $mda " $dev1 "
2014-03-28 14:38:50 +04:00
# cannot change allocatability for orphan PVs
fail pvchange " $dev1 " -x y
fail pvchange " $dev1 " -x n
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev4 " " $dev1 "
2008-08-12 14:04:31 +04:00
2012-03-16 17:00:05 +04:00
# "pvchange adds/dels tag to pvs with metadatacopies = $mda "
pvchange " $dev1 " --addtag test$mda
check pv_field " $dev1 " pv_tags test$mda
pvchange " $dev1 " --deltag test$mda
check pv_field " $dev1 " pv_tags ""
2008-08-12 14:04:31 +04:00
2008-10-06 20:47:07 +04:00
# "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)"
2012-03-16 17:00:05 +04:00
pvchange " $dev1 " -x n
2014-03-27 14:23:08 +04:00
pvchange " $dev1 " -x n # already disabled
2016-02-26 18:46:37 +03:00
check pv_field " $dev1 " pv_attr u--
2012-03-16 17:00:05 +04:00
pvchange " $dev1 " -x y
2014-03-27 14:23:08 +04:00
pvchange " $dev1 " -x y # already enabled
2016-02-26 18:46:37 +03:00
check pv_field " $dev1 " pv_attr a--
2008-08-12 14:04:31 +04:00
2014-03-28 14:38:50 +04:00
# check we are able to change number of managed metadata areas
if test $mda -gt 0 ; then
pvchange --force --metadataignore y " $dev1 "
else
# already ignored
fail pvchange --metadataignore y " $dev1 "
fi
2008-10-06 20:47:07 +04:00
# 'remove pv'
2012-03-16 17:00:05 +04:00
vgremove $vg1
2014-03-28 14:38:50 +04:00
pvremove " $dev1 "
2008-08-12 14:04:31 +04:00
done
2008-10-06 20:47:07 +04:00
# "pvchange uuid"
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 0 " $dev1 "
pvcreate --metadatacopies 2 " $dev2 "
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev1 " " $dev2 "
2014-03-28 03:39:55 +04:00
2014-03-28 13:37:33 +04:00
# Checking for different UUID after pvchange
UUID1 = $( get pv_field " $dev1 " uuid)
2012-03-16 17:00:05 +04:00
pvchange -u " $dev1 "
2014-03-28 14:38:50 +04:00
check_changed_uuid_ " $UUID1 " " $dev1 "
2014-03-28 13:37:33 +04:00
UUID2 = $( get pv_field " $dev2 " uuid)
2012-03-16 17:00:05 +04:00
pvchange -u " $dev2 "
2014-03-28 14:38:50 +04:00
check_changed_uuid_ " $UUID2 " " $dev2 "
2014-03-28 13:37:33 +04:00
UUID1 = $( get pv_field " $dev1 " uuid)
UUID2 = $( get pv_field " $dev2 " uuid)
2010-03-17 20:02:01 +03:00
pvchange -u --all
2014-03-28 14:38:50 +04:00
check_changed_uuid_ " $UUID1 " " $dev1 "
check_changed_uuid_ " $UUID2 " " $dev2 "
2011-01-05 03:16:18 +03:00
check pvlv_counts $vg1 2 0 0
2008-10-06 20:47:07 +04:00
2014-03-28 14:38:50 +04:00
# some args are needed
invalid pvchange
2014-05-22 01:13:19 +04:00
# some PV needed
invalid pvchange --addtag tag
invalid pvchange --deltag tag
# some --all & PV can go together
invalid pvchange -a " $dev1 " --addtag tag
2014-03-28 03:39:55 +04:00
# '-a' needs more params
invalid pvchange -a
# '-a' is searching for devs, so specifying device is invalid
invalid pvchange -a " $dev1 "
fail pvchange -u " $dev1 -notfound "
# pvchange rejects uuid change under an active lv
2012-03-16 17:00:05 +04:00
lvcreate -l 16 -i 2 -n $lv --alloc anywhere $vg1
check pvlv_counts $vg1 2 1 0
not pvchange -u " $dev1 "
2008-08-12 14:04:31 +04:00
2014-03-28 03:39:55 +04:00
vgremove -f $vg1
2008-08-12 14:04:31 +04:00
2014-05-22 01:13:19 +04:00
# cannot change PV tag to PV that is not in VG"
fail pvchange " $dev1 " --addtag test
fail pvchange " $dev1 " --deltag test
2016-03-03 01:49:32 +03:00
if test -n " $LVM_TEST_LVM1 " ; then
2014-05-22 01:13:19 +04:00
# cannot add PV tag to lvm1 format
2012-03-16 17:00:05 +04:00
pvcreate -M1 " $dev1 "
2018-05-24 17:49:48 +03:00
vgcreate $SHARED -M1 $vg1 " $dev1 "
2014-05-22 01:13:19 +04:00
fail pvchange " $dev1 " --addtag test
2016-03-03 01:49:32 +03:00
fi