2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2008-08-28 14:24:55 +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-28 14:24:55 +04: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-08-28 14:24:55 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2008-09-30 17:19:56 +04:00
aux prepare_devs 3
2012-03-16 17:00:05 +04:00
pvcreate " $dev1 "
pvcreate --metadatacopies 0 " $dev2 "
pvcreate --metadatacopies 2 " $dev3 "
2014-03-24 13:01:25 +04:00
# Fails without give argument
not pvremove
2012-03-16 17:00:05 +04:00
pvremove " $dev2 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# failing, but still removing everything what can be removed
# is somewhat odd as default, what do we have -f for?
2012-03-16 17:00:05 +04:00
pvs | not grep " $dev2 "
2014-06-12 13:31:21 +04:00
pvs -a | grep " $dev2 "
# bz1108394 no crash on nonPV label listing
pvs -a -o+devices
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 0 " $dev2 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# check pvremove refuses to remove pv in a vg
2013-05-31 23:11:51 +04:00
vgcreate $vg " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
not pvremove " $dev2 " " $dev3 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
for mdacp in 0 1 2; do
# check pvremove truly wipes the label (pvscan wont find) (---metadatacopies $mdacp)
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev3 "
pvremove " $dev3 "
2009-07-14 23:35:35 +04:00
# try to remove agail - should fail cleanly
2012-03-16 17:00:05 +04:00
not pvremove " $dev3 "
pvscan | not grep " $dev3 "
2008-08-28 14:24:55 +04:00
2008-11-10 15:41:52 +03:00
# bz179473 refuse to wipe non-PV device without -f
2012-03-16 17:00:05 +04:00
not pvremove " $dev3 "
pvremove -f " $dev3 "
2008-11-10 15:41:52 +03:00
2008-09-30 17:19:56 +04:00
# reset setup
vgremove -ff $vg
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 "
pvcreate " $dev2 "
vgcreate $vg " $dev1 " " $dev2 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# pvremove -f fails when pv in a vg (---metadatacopies $mdacp)
2016-02-23 16:38:26 +03:00
not pvremove -f " $dev1 " 2>& 1 | tee out
2016-02-25 23:12:08 +03:00
grep "is used" out
2012-03-16 17:00:05 +04:00
pvs " $dev1 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# pvremove -ff fails without confirmation when pv in a vg (---metadatacopies $mdacp)
2016-02-23 16:38:26 +03:00
not pvremove -ff " $dev1 " 2>& 1 | tee out
2016-02-25 23:12:08 +03:00
grep "is used" out
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# pvremove -ff succeds with confirmation when pv in a vg (---metadatacopies $mdacp)
2016-02-23 16:38:26 +03:00
pvremove -ffy " $dev1 " 2>& 1 | tee out
2016-02-25 23:12:08 +03:00
grep "is used" out
2012-03-16 17:00:05 +04:00
not pvs " $dev1 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
vgreduce --removemissing $vg
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 "
vgextend $vg " $dev1 "
2008-08-28 14:24:55 +04:00
2008-09-30 17:19:56 +04:00
# pvremove -ff -y is sufficient when pv in a vg (---metadatacopies $mdacp)" '
2012-03-16 17:00:05 +04:00
pvremove -ff -y " $dev1 "
2008-09-30 17:19:56 +04:00
vgreduce --removemissing $vg
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 "
vgextend $vg " $dev1 "
2008-09-30 17:19:56 +04:00
done
2014-02-27 02:25:30 +04:00
vgremove -ff $vg