2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2014-03-31 13:44:39 +04:00
# Copyright (C) 2008-2014 Red Hat, Inc. All rights reserved.
2008-11-11 18:29:24 +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-11-11 18:29:24 +03:00
#
# tests functionality of lvs, pvs, vgs, *display tools
#
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-11-11 18:29:24 +03:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2008-11-11 18:29:24 +03:00
aux prepare_devs 5
2014-06-04 15:55:13 +04:00
get_devs
2008-11-11 18:29:24 +03:00
2014-03-31 13:44:39 +04:00
# Check there is no PV
pvscan | tee out
grep "No matching" out
2013-07-29 21:15:31 +04:00
pvcreate --uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE --norestorefile " $dev1 "
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 0 " $dev2 "
pvcreate --metadatacopies 0 " $dev3 "
pvcreate " $dev4 "
pvcreate --metadatacopies 0 " $dev5 "
2008-11-11 18:29:24 +03:00
#COMM bz195276 -- pvs doesn't show PVs until a VG is created
2014-06-04 15:55:13 +04:00
pvs --noheadings " ${ DEVICES [@] } "
2017-07-10 11:40:09 +03:00
test " $( pvs --noheadings " ${ DEVICES [@] } " | wc -l) " -eq 5
2014-03-31 01:15:16 +04:00
pvdisplay
2008-11-11 18:29:24 +03:00
2009-04-21 16:59:18 +04:00
#COMM pvs with segment attributes works even for orphans
2017-07-10 11:40:09 +03:00
test " $( pvs --noheadings -o seg_all,pv_all,lv_all,vg_all " ${ DEVICES [@] } " | wc -l) " -eq 5
2009-04-21 16:59:18 +04:00
2014-06-04 15:55:13 +04:00
vgcreate $vg " ${ DEVICES [@] } "
2008-11-11 18:29:24 +03:00
2014-03-20 02:32:25 +04:00
check pv_field " $dev1 " pv_uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
2013-07-29 21:15:31 +04:00
2008-11-11 18:29:24 +03:00
#COMM pvs and vgs report mda_count, mda_free (bz202886, bz247444)
2014-06-04 15:55:13 +04:00
pvs -o +pv_mda_count,pv_mda_free " ${ DEVICES [@] } "
2012-03-16 17:00:05 +04:00
for I in " $dev2 " " $dev3 " " $dev5 " ; do
2014-06-04 15:55:13 +04:00
check pv_field " $I " pv_mda_count 0
check pv_field " $I " pv_mda_free 0
2008-11-11 18:29:24 +03:00
done
vgs -o +vg_mda_count,vg_mda_free $vg
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_count 2
2008-11-11 18:29:24 +03:00
#COMM pvs doesn't display --metadatacopies 0 PVs as orphans (bz409061)
2012-03-16 17:00:05 +04:00
pvdisplay " $dev2 " | grep " VG Name.* $vg "
check pv_field " $dev2 " vg_name $vg
2008-11-11 18:29:24 +03:00
#COMM lvs displays snapshots (bz171215)
2013-05-31 23:11:51 +04:00
lvcreate -aey -l4 -n $lv1 $vg
2008-11-11 18:29:24 +03:00
lvcreate -l4 -s -n $lv2 $vg /$lv1
2017-07-10 11:40:09 +03:00
test " $( lvs --noheadings $vg | wc -l) " -eq 2
2008-11-11 18:29:24 +03:00
# should lvs -a display cow && real devices? (it doesn't)
2017-07-10 11:40:09 +03:00
test " $( lvs -a --noheadings $vg | wc -l) " -eq 2
2014-03-20 02:32:25 +04:00
dmsetup ls | grep " $PREFIX " | grep -v "LVMTEST.*pv."
2008-11-11 18:29:24 +03:00
lvremove -f $vg /$lv2
#COMM lvs -a displays mirror legs and log
2014-04-28 13:57:42 +04:00
lvcreate -aey -l2 --type mirror -m2 -n $lv3 $vg
2017-07-10 11:40:09 +03:00
test " $( lvs --noheadings $vg | wc -l) " -eq 2
test " $( lvs -a --noheadings $vg | wc -l) " -eq 6
2014-06-04 15:55:13 +04:00
dmsetup ls | grep " $PREFIX " | grep -v "LVMTEST.*pv."
2014-05-13 12:28:55 +04:00
2014-11-26 19:09:47 +03:00
# Check we parse /dev/mapper/vg-lv
lvdisplay " $DM_DEV_DIR /mapper/ $vg - $lv3 "
# Check we parse /dev/vg/lv
lvdisplay " $DM_DEV_DIR / $vg / $lv3 "
2014-04-28 13:57:42 +04:00
lvcreate -l2 -s $vg /$lv3
lvcreate -l1 -s -n inval $vg /$lv3
lvcreate -l4 -I4 -i2 -n stripe $vg
# Invalidate snapshot
not dd if = /dev/zero of = " $DM_DEV_DIR / $vg /inval " bs = 4K
invalid lvscan " $dev1 "
lvdisplay --maps
2014-04-30 12:16:35 +04:00
lvscan --all
2008-11-11 18:29:24 +03:00
#COMM vgs with options from pvs still treats arguments as VGs (bz193543)
vgs -o pv_name,vg_name $vg
# would complain if not
2014-03-31 13:44:39 +04:00
vgs -o all $vg
2008-11-11 18:29:24 +03:00
#COMM pvdisplay --maps feature (bz149814)
2014-06-04 15:55:13 +04:00
pvdisplay " ${ DEVICES [@] } " >out
pvdisplay --maps " ${ DEVICES [@] } " >out2
2008-11-11 18:29:24 +03:00
not diff out out2
2013-11-18 01:36:13 +04:00
2014-03-20 02:32:25 +04:00
aux disable_dev " $dev1 "
2013-11-18 01:36:13 +04:00
pvs -o +pv_uuid | grep BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
2014-03-28 03:37:39 +04:00
aux enable_dev " $dev1 "
2014-03-31 13:44:39 +04:00
pvscan --uuid
pvscan -e
pvscan -s
pvscan --novolumegroup
vgscan --mknodes
2014-05-24 01:34:00 +04:00
vgmknodes --refresh
2014-03-31 13:44:39 +04:00
lvscan
lvmdiskscan
invalid pvscan " $dev1 "
invalid pvscan -aay
invalid pvscan --major 254
invalid pvscan --minor 0
invalid pvscan --novolumegroup -e
invalid vgscan $vg
invalid lvscan $vg
2014-03-28 03:37:39 +04:00
if aux have_readline; then
cat <<EOF | lvm
2014-03-31 13:44:39 +04:00
vgdisplay --units k $vg
2014-03-28 03:37:39 +04:00
vgdisplay -c $vg
vgdisplay -C $vg
vgdisplay -s $vg
2014-03-31 13:44:39 +04:00
vgdisplay -v $vg
2014-03-28 03:37:39 +04:00
lvdisplay -c $vg
lvdisplay -C $vg
lvdisplay -m $vg
2014-03-31 13:44:39 +04:00
lvdisplay --units g $vg
2014-03-28 03:37:39 +04:00
EOF
else
pvdisplay -c " $dev1 "
pvdisplay -s " $dev1 "
2014-03-31 13:44:39 +04:00
vgdisplay --units k $vg
2014-03-28 03:37:39 +04:00
vgdisplay -c $vg
vgdisplay -C $vg
vgdisplay -s $vg
2014-03-31 13:44:39 +04:00
vgdisplay -v $vg
2014-03-28 03:37:39 +04:00
lvdisplay -c $vg
lvdisplay -C $vg
lvdisplay -m $vg
2014-03-31 13:44:39 +04:00
lvdisplay --units g $vg
2014-06-04 15:55:13 +04:00
fi
pvdisplay -c " $dev1 "
pvdisplay -s " $dev1 "
2014-03-28 03:37:39 +04:00
for i in h b s k m g t p e H B S K M G T P E; do
pvdisplay --units $i " $dev1 "
done
invalid lvdisplay -C -m $vg
2014-03-31 13:44:39 +04:00
invalid lvdisplay -c -m $vg
2014-03-28 03:37:39 +04:00
invalid lvdisplay --aligned $vg
invalid lvdisplay --noheadings $vg
invalid lvdisplay --options lv_name $vg
invalid lvdisplay --separator : $vg
invalid lvdisplay --sort size $vg
invalid lvdisplay --unbuffered $vg
invalid vgdisplay -C -A
invalid vgdisplay -C -c
invalid vgdisplay -C -s
invalid vgdisplay -c -s
2014-03-31 13:44:39 +04:00
invalid vgdisplay --aligned
invalid vgdisplay --noheadings
invalid vgdisplay --options
invalid vgdisplay --separator :
invalid vgdisplay --sort size
invalid vgdisplay --unbuffered
2014-03-28 03:37:39 +04:00
invalid vgdisplay -A $vg1
2014-02-27 02:25:30 +04:00
2014-03-31 01:15:16 +04:00
invalid pvdisplay -C -A
invalid pvdisplay -C -c
invalid pvdisplay -C -m
invalid pvdisplay -C -s
invalid pvdisplay -c -m
invalid pvdisplay -c -s
2014-03-31 13:44:39 +04:00
invalid pvdisplay --aligned
2014-03-31 01:15:16 +04:00
invalid pvdisplay --all
invalid pvdisplay --noheadings
invalid pvdisplay --options
invalid pvdisplay --separator :
invalid pvdisplay --sort size
invalid pvdisplay --unbuffered
invalid pvdisplay -A $vg1
# Check exported VG listing
vgchange -an $vg
vgexport -a
2014-03-31 13:44:39 +04:00
pvscan
2014-03-31 01:15:16 +04:00
pvdisplay --noheadings -C -o attr,name | tee out
not grep -v "ax-" out
vgimport -a
pvdisplay --noheadings -C -o attr,name | tee out
grep -v "ax-" out
2014-02-27 02:25:30 +04:00
vgremove -ff $vg
2014-03-28 03:37:39 +04:00
#test vgdisplay -A to select only active VGs
# all LVs active - VG considered active
pvcreate " $dev1 " " $dev2 " " $dev3 "
vgcreate $vg1 " $dev1 "
lvcreate -l1 $vg1
lvcreate -l1 $vg1
# at least one LV active - VG considered active
vgcreate $vg2 " $dev2 "
lvcreate -l1 $vg2
lvcreate -l1 -an -Zn $vg2
# no LVs active - VG considered inactive
vgcreate $vg3 " $dev3 "
lvcreate -l1 -an -Zn $vg3
lvcreate -l1 -an -Zn $vg3
vgdisplay -s -A | grep $vg1
vgdisplay -s -A | grep $vg2
vgdisplay -s -A | not grep $vg3
vgremove -f $vg1 $vg2 $vg3