1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/test/shell/process-each-pv.sh

1286 lines
27 KiB
Bash
Raw Normal View History

2014-10-07 04:08:03 +04:00
#!/bin/sh
2014-10-07 11:54:47 +04:00
# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
2014-10-07 04:08:03 +04: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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
test_description='Exercise toollib process_each_pv'
. lib/inittest
test -e LOCAL_LVMPOLLD && skip
2014-10-07 04:08:03 +04:00
aux prepare_devs 14
#
# process_each_pv is used by a number of pv commands:
# pvdisplay
# pvresize
# pvs
# vgreduce
#
# process-each-pvresize.sh covers pvresize,
# the others are covered here.
#
#
# set up
#
# use use dev10 instead of dev1 because simple grep for
# dev1 matchines dev10,dev11,etc
#
vgcreate $vg1 "$dev10"
vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5"
vgcreate $vg3 "$dev6" "$dev7" "$dev8" "$dev9"
pvchange --addtag V2D3 "$dev3"
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
pvchange --addtag V3 "$dev6" "$dev7" "$dev8" "$dev9"
pvchange --addtag V3D9 "$dev9"
# orphan
pvcreate "$dev11"
# dev (a non-pv device)
pvcreate "$dev12"
pvremove "$dev12"
# dev13 is intentionally untouched so we can
# test that it is handled appropriately as a non-pv
# orphan
pvcreate "$dev14"
#
# test pvdisplay
#
# pv in vg
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev10" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv not in vg (one orphan)
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# dev is not a pv
2014-10-07 11:54:47 +04:00
not pvdisplay -s "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# two pvs in different vgs
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev10" "$dev2" | tee err
grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# -a is invalid when used alone
2014-10-07 11:54:47 +04:00
not pvdisplay -a | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one pv and one orphan
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev10" "$dev11" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one pv and one dev (dev refers to a non-pv device)
2014-10-07 11:54:47 +04:00
not pvdisplay -s "$dev10" "$dev12" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one orphan and one dev
2014-10-07 11:54:47 +04:00
not pvdisplay -s "$dev11" "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all pvs (pvs in vgs and orphan pvs)
2014-10-07 11:54:47 +04:00
pvdisplay -s | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all devs (pvs in vgs, orphan pvs, and devs)
2014-10-07 11:54:47 +04:00
pvdisplay -a -C | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
grep "$dev12" err
grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv and orphan and dev
2014-10-07 11:54:47 +04:00
not pvdisplay -s "$dev9" "$dev11" "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# -s option not allowed with -a -C
2014-10-07 11:54:47 +04:00
not pvdisplay -s -a -C | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv and all (all ignored)
2014-10-07 11:54:47 +04:00
pvdisplay -a -C "$dev9" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan and all (all ignored)
2014-10-07 11:54:47 +04:00
pvdisplay -a -C "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one tag
2014-10-07 11:54:47 +04:00
pvdisplay -s @V2D3 | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# two tags
2014-10-07 11:54:47 +04:00
pvdisplay -s @V2D3 @V2D45 | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and pv
2014-10-07 11:54:47 +04:00
pvdisplay -s @V2D3 "$dev4" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and orphan
2014-10-07 11:54:47 +04:00
pvdisplay -s @V2D3 "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and dev
2014-10-07 11:54:47 +04:00
not pvdisplay -s @V2D3 "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and all (all ignored)
2014-10-07 11:54:47 +04:00
pvdisplay @V2D3 -a -C | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and pv redundant
2014-10-07 11:54:47 +04:00
pvdisplay -s @V2D3 "$dev3" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
#
# test pvs
#
# pv in vg
2014-10-07 11:54:47 +04:00
pvs "$dev10" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv not in vg (one orphan)
2014-10-07 11:54:47 +04:00
pvs "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# dev is not a pv
2014-10-07 11:54:47 +04:00
not pvs "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# two pvs in different vgs
2014-10-07 11:54:47 +04:00
pvs "$dev10" "$dev2" | tee err
grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one pv and one orphan
2014-10-07 11:54:47 +04:00
pvs "$dev10" "$dev11" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one pv and one dev
2014-10-07 11:54:47 +04:00
not pvs "$dev10" "$dev12" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one orphan and one dev
2014-10-07 11:54:47 +04:00
not pvs "$dev11" "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all pvs (pvs in vgs and orphan pvs)
2014-10-07 11:54:47 +04:00
pvs | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all devs (pvs in vgs, orphan pvs, and devs)
2014-10-07 11:54:47 +04:00
pvs -a | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
grep "$dev12" err
grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv and orphan and dev
2014-10-07 11:54:47 +04:00
not pvs "$dev9" "$dev11" "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv and all (all ignored)
2014-10-07 11:54:47 +04:00
pvs -a "$dev9" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan and all (all ignored)
2014-10-07 11:54:47 +04:00
pvs -a "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# one tag
2014-10-07 11:54:47 +04:00
pvs @V2D3 | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# two tags
2014-10-07 11:54:47 +04:00
pvs @V2D3 @V2D45 | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and pv
2014-10-07 11:54:47 +04:00
pvs @V2D3 "$dev4" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and orphan
2014-10-07 11:54:47 +04:00
pvs @V2D3 "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and dev
2014-10-07 11:54:47 +04:00
not pvs @V2D3 "$dev12" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and all (all ignored)
2014-10-07 11:54:47 +04:00
pvs @V2D3 -a | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag and pv redundant
2014-10-07 11:54:47 +04:00
pvs @V2D3 "$dev3" | tee err
not grep "$dev10" err
not grep "$dev2" err
grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
#
# test vgreduce
#
# fail without dev
not vgreduce $vg2
# fail with dev and -a
2014-10-07 11:54:47 +04:00
not vgreduce $vg2 "$dev2" -a
check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# remove one pv
2014-10-07 11:54:47 +04:00
vgreduce $vg2 "$dev2"
not check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev2"
2014-10-07 04:08:03 +04:00
# remove two pvs
2014-10-07 11:54:47 +04:00
vgreduce $vg2 "$dev2" "$dev3"
not check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev2" "$dev3"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D3 "$dev3"
# remove one pv with tag
vgreduce $vg2 @V2D3
2014-10-07 11:54:47 +04:00
check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev3"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D3 "$dev3"
# remove two pvs, each with different tag
vgreduce $vg2 @V2D3 @V2D4
2014-10-07 11:54:47 +04:00
check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
not check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev3" "$dev4"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D3 "$dev3"
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
# remove two pvs, both with same tag
vgreduce $vg2 @V2D45
2014-10-07 11:54:47 +04:00
check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
not check pv_field "$dev4" vg_name $vg2
not check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev4" "$dev5"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
# remove two pvs, one by name, one by tag
2014-10-07 11:54:47 +04:00
vgreduce $vg2 "$dev2" @V2D3
not check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev2" "$dev3"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D3 "$dev3"
# remove one pv by tag, where another vg has a pv with same tag
pvchange --addtag V2D5V3D9 "$dev5"
pvchange --addtag V2D5V3D9 "$dev9"
vgreduce $vg2 @V2D5V3D9
2014-10-07 11:54:47 +04:00
check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
not check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev5"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
# fail to remove last pv (don't know which will be last)
not vgreduce -a $vg2
# reset
vgremove $vg2
vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5"
pvchange --addtag V2D3 "$dev3"
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
# lvcreate on one pv to make it used
# remove all unused pvs
2014-10-07 11:54:47 +04:00
lvcreate -n $lv1 -l 2 $vg2 "$dev2"
2014-10-07 04:08:03 +04:00
not vgreduce -a $vg2
2014-10-07 11:54:47 +04:00
check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
not check pv_field "$dev4" vg_name $vg2
not check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev3" "$dev4" "$dev5"
2014-10-07 04:08:03 +04:00
pvchange --addtag V2D3 "$dev3"
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
lvchange -an $vg2/$lv1
lvremove $vg2/$lv1
#
# tests including pvs without mdas
#
# remove old config
vgremove $vg1
vgremove $vg2
vgremove $vg3
2014-10-07 11:54:47 +04:00
pvremove "$dev11"
pvremove "$dev14"
2014-10-07 04:08:03 +04:00
# new config with some pvs that have zero mdas
# for vg1
2014-10-07 11:54:47 +04:00
pvcreate "$dev10"
2014-10-07 04:08:03 +04:00
# for vg2
2014-10-07 11:54:47 +04:00
pvcreate "$dev2" --metadatacopies 0
pvcreate "$dev3"
pvcreate "$dev4"
pvcreate "$dev5"
2014-10-07 04:08:03 +04:00
# for vg3
2014-10-07 11:54:47 +04:00
pvcreate "$dev6" --metadatacopies 0
pvcreate "$dev7" --metadatacopies 0
pvcreate "$dev8" --metadatacopies 0
pvcreate "$dev9"
2014-10-07 04:08:03 +04:00
# orphan with mda
pvcreate "$dev11"
# orphan without mda
pvcreate "$dev14" --metadatacopies 0
# non-pv devs
# dev12
# dev13
vgcreate $vg1 "$dev10"
vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5"
vgcreate $vg3 "$dev6" "$dev7" "$dev8" "$dev9"
pvchange --addtag V2D3 "$dev3"
pvchange --addtag V2D4 "$dev4"
pvchange --addtag V2D45 "$dev4"
pvchange --addtag V2D5 "$dev5"
pvchange --addtag V2D45 "$dev5"
pvchange --addtag V3 "$dev6" "$dev7" "$dev8" "$dev9"
pvchange --addtag V3D8 "$dev8"
pvchange --addtag V3D9 "$dev9"
#
# pvdisplay including pvs without mdas
#
# pv with mda
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev10" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv without mda
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev2" | tee err
not grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan with mda
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan without mda
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev14" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv with mda, pv without mda, orphan with mda, orphan without mda
2014-10-07 11:54:47 +04:00
pvdisplay -s "$dev10" "$dev2" "$dev11" "$dev14" | tee err
grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag refering to pv with mda and pv without mda
2014-10-07 11:54:47 +04:00
pvdisplay -s @V3 | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag refering to one pv without mda
2014-10-07 11:54:47 +04:00
pvdisplay -s @V3D8 | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all pvs (pvs in vgs and orphan pvs)
2014-10-07 11:54:47 +04:00
pvdisplay -s | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all devs (pvs in vgs, orphan pvs, and devs)
2014-10-07 11:54:47 +04:00
pvdisplay -a -C | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
grep "$dev12" err
grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
#
# pvs including pvs without mdas
#
# pv with mda
2014-10-07 11:54:47 +04:00
pvs "$dev10" | tee err
grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv without mda
2014-10-07 11:54:47 +04:00
pvs "$dev2" | tee err
not grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan with mda
2014-10-07 11:54:47 +04:00
pvs "$dev11" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# orphan without mda
2014-10-07 11:54:47 +04:00
pvs "$dev14" | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# pv with mda, pv without mda, orphan with mda, orphan without mda
2014-10-07 11:54:47 +04:00
pvs "$dev10" "$dev2" "$dev11" "$dev14" | tee err
grep "$dev10" err
grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
not grep "$dev8" err
not grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag refering to pv with mda and pv without mda
2014-10-07 11:54:47 +04:00
pvs @V3 | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# tag refering to one pv without mda
2014-10-07 11:54:47 +04:00
pvs @V3D8 | tee err
not grep "$dev10" err
not grep "$dev2" err
not grep "$dev3" err
not grep "$dev4" err
not grep "$dev5" err
not grep "$dev6" err
not grep "$dev7" err
grep "$dev8" err
not grep "$dev9" err
not grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
not grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all pvs (pvs in vgs and orphan pvs)
2014-10-07 11:54:47 +04:00
pvs | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
not grep "$dev12" err
not grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
# all devs (pvs in vgs, orphan pvs, and devs)
2014-10-07 11:54:47 +04:00
pvs -a | tee err
grep "$dev10" err
grep "$dev2" err
grep "$dev3" err
grep "$dev4" err
grep "$dev5" err
grep "$dev6" err
grep "$dev7" err
grep "$dev8" err
grep "$dev9" err
grep "$dev11" err
grep "$dev12" err
grep "$dev13" err
grep "$dev14" err
2014-10-07 04:08:03 +04:00
#
# vgreduce including pvs without mdas
#
# remove pv without mda
2014-10-07 11:54:47 +04:00
vgreduce $vg2 "$dev2"
not check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev2"
2014-10-07 04:08:03 +04:00
# remove pv with mda and pv without mda
2014-10-07 11:54:47 +04:00
vgreduce $vg2 "$dev2" "$dev3"
not check pv_field "$dev2" vg_name $vg2
not check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg2 "$dev2"
vgextend $vg2 "$dev3"
2014-10-07 04:08:03 +04:00
# fail to remove only pv with mda
2014-10-07 11:54:47 +04:00
not vgreduce $vg3 "$dev9"
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
2014-10-07 04:08:03 +04:00
# remove by tag a pv without mda
vgreduce $vg3 @V3D8
2014-10-07 11:54:47 +04:00
check pv_field "$dev6" vg_name $vg3
check pv_field "$dev7" vg_name $vg3
not check pv_field "$dev8" vg_name $vg3
check pv_field "$dev9" vg_name $vg3
check pv_field "$dev2" vg_name $vg2
check pv_field "$dev3" vg_name $vg2
check pv_field "$dev4" vg_name $vg2
check pv_field "$dev5" vg_name $vg2
2014-10-07 04:08:03 +04:00
# reset
2014-10-07 11:54:47 +04:00
vgextend $vg3 "$dev8"