2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
# Copyright (C) 2007-2017 Red Hat, Inc. All rights reserved.
2008-01-31 15:19:36 +03:00
# Copyright (C) 2007-2008 NEC Corporation
#
# 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-01-31 15:19:36 +03:00
test_description = "check namings of mirrored LV"
2018-06-01 00:18:53 +03:00
2016-02-23 01:13:42 +03:00
2014-06-06 19:40:04 +04:00
. lib/inittest
2008-01-31 15:19:36 +03:00
# ---------------------------------------------------------------------
# Utilities
2008-10-06 20:47:07 +04:00
lv_devices_( ) {
2012-03-16 17:00:05 +04:00
local d
2017-07-03 21:36:27 +03:00
local i
2012-03-16 17:00:05 +04:00
local lv = $1
shift
2017-07-03 21:36:27 +03:00
local devices = ( " $@ " )
2014-06-30 22:04:24 +04:00
local devs
devs = $( get lv_devices " $lv " )
2012-03-16 17:00:05 +04:00
for d in $devs ; do
2017-07-03 21:36:27 +03:00
( echo " ${ devices [@] } " | grep " $d " ) || return 1
for i in " ${ !devices[@] } " ; do
if [ " ${ devices [i] } " = " $d " ] ; then
unset "devices[i]"
fi
done
2012-03-16 17:00:05 +04:00
done
2017-07-03 21:36:27 +03:00
test " ${# devices [@] } " -eq 0 ||
die "Left devices " " ${ devices [@] } "
2008-01-31 15:19:36 +03:00
}
2008-10-06 20:47:07 +04:00
lv_mirror_log_( ) {
2017-07-03 21:36:27 +03:00
get lv_field " $1 " mirror_log | tr -d [ ]
2008-01-31 15:19:36 +03:00
}
2008-10-06 20:47:07 +04:00
lv_convert_lv_( ) {
2017-07-03 21:36:27 +03:00
get lv_field " $1 " convert_lv | tr -d [ ]
2008-01-31 15:19:36 +03:00
}
# ---------------------------------------------------------------------
# Common environment setup/cleanup for each sub testcases
2008-10-06 20:47:07 +04:00
check_and_cleanup_lvs_( ) {
2012-03-16 17:00:05 +04:00
lvs -a -o+devices $vg
lvremove -ff $vg
2012-03-28 15:10:08 +04:00
( dm_table | not grep $vg ) || \
die "ERROR: lvremove did leave some some mappings in DM behind!"
2008-01-31 15:19:36 +03:00
}
2012-03-16 17:00:05 +04:00
# ---------------------------------------------------------------------
# Initialize PVs and VGs
aux prepare_vg 5 80
2008-10-06 20:47:07 +04:00
check_and_cleanup_lvs_
2008-01-31 15:19:36 +03:00
# ---------------------------------------------------------------------
# basic
2012-03-16 17:00:05 +04:00
#COMM "init: lvcreate"
2008-01-31 15:19:36 +03:00
2008-10-06 20:47:07 +04:00
#COMM "mirror images are ${lv1}_mimage_x"
2013-08-08 00:48:31 +04:00
lvcreate -an -Zn -l2 --type mirror -m1 -n $lv1 $vg
2012-03-16 17:00:05 +04:00
lv_devices_ $vg /$lv1 ${ lv1 } _mimage_0 ${ lv1 } _mimage_1
2008-01-31 15:19:36 +03:00
2008-10-06 20:47:07 +04:00
#COMM "mirror log is ${lv1}_mlog"
2017-07-03 21:36:27 +03:00
test " $( lv_mirror_log_ $vg /$lv1 ) " = " ${ lv1 } _mlog "
2008-01-31 15:19:36 +03:00
2012-03-16 17:00:05 +04:00
# "cleanup"
2008-11-10 15:41:52 +03:00
check_and_cleanup_lvs_
#COMM "mirror with name longer than 22 characters (bz221322)"
name = "LVwithanamelogerthan22characters_butidontwonttocounthem"
2013-08-08 00:48:31 +04:00
lvcreate -an -Zn --type mirror -m1 -l2 -n $name $vg
2012-03-16 17:00:05 +04:00
lvs $vg /$name
2008-10-06 20:47:07 +04:00
check_and_cleanup_lvs_
2008-01-31 15:19:36 +03:00
# ---------------------------------------------------------------------
# lvrename
2012-03-16 17:00:05 +04:00
#COMM "init: lvrename"
2008-01-31 15:19:36 +03:00
2012-03-16 17:00:05 +04:00
#COMM "renamed mirror names: $lv1 to $lv2"
2013-08-08 00:48:31 +04:00
lvcreate -an -Zn -l2 --type mirror -m1 -n $lv1 $vg
2012-03-16 17:00:05 +04:00
lvrename $vg /$lv1 $vg /$lv2
lv_devices_ $vg /$lv2 ${ lv2 } _mimage_0 ${ lv2 } _mimage_1
lv_mirror_log_ $vg /$lv2 ${ lv2 } _mlog
2008-01-31 15:19:36 +03:00
2012-03-16 17:00:05 +04:00
#COMM "cleanup"
2008-10-06 20:47:07 +04:00
check_and_cleanup_lvs_
2008-01-31 15:19:36 +03:00
# ---------------------------------------------------------------------
# lvconvert
2012-03-16 17:00:05 +04:00
#COMM "init: lvconvert"
2008-10-06 20:47:07 +04:00
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
2013-08-08 00:48:31 +04:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg
2018-05-12 19:04:06 +03:00
# Use large enough polling interval so mirror is keeping mimagetmp
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+1 -i+40 -b $vg /$lv1
2018-11-18 23:38:56 +03:00
#
# TODO: lvmpolld is not 'preserving' -i interval setting from
# lvconvert initiating command - so there is not much to test
# if the lvconvert is already finished at this point
# and lvmpolld cleaned metadata and refreshed DM table
#
# It' unclear if this is undocumented feature of bug.
#
if test ! -f LOCAL_LVMPOLLD ; then
2018-11-12 17:28:45 +03:00
for i in $( seq 1 10) ; do
# check if background process already started
# this is recognized by presence of LV1_mimage_2
check lvl $vg /${ lv1 } _mimage_2 && break
sleep .1
done
2012-03-16 17:00:05 +04:00
convlv = $( lv_convert_lv_ $vg /$lv1 )
2017-07-03 21:36:27 +03:00
test " $convlv " = " ${ lv1 } _mimagetmp_2 "
2012-03-16 17:00:05 +04:00
lv_devices_ $vg /$lv1 $convlv ${ lv1 } _mimage_2
lv_devices_ $vg /$convlv ${ lv1 } _mimage_0 ${ lv1 } _mimage_1
lv_mirror_log_ $vg /$convlv ${ lv1 } _mlog
2018-05-12 19:04:06 +03:00
check lv_exists $vg ${ lv1 } _mimagetmp_2
2008-10-06 20:47:07 +04:00
2017-07-03 21:36:27 +03:00
#COMM "mirror log name after re-adding is ${lv1}_mlog"
2013-06-15 13:21:03 +04:00
lvconvert -f --mirrorlog core $vg /$lv1
2012-03-16 17:00:05 +04:00
lvconvert --mirrorlog disk $vg /$lv1
convlv = $( lv_convert_lv_ $vg /$lv1 )
lv_devices_ $vg /$lv1 $convlv ${ lv1 } _mimage_2
lv_devices_ $vg /$convlv ${ lv1 } _mimage_0 ${ lv1 } _mimage_1
lv_mirror_log_ $vg /$convlv ${ lv1 } _mlog
2008-10-06 20:47:07 +04:00
2017-07-03 21:36:27 +03:00
#COMM "renamed converting mirror names: $lv1 to $lv2"
2012-03-16 17:00:05 +04:00
lvrename $vg /$lv1 $vg /$lv2
convlv = $( lv_convert_lv_ $vg /$lv2 )
lv_devices_ $vg /$lv2 $convlv ${ lv2 } _mimage_2
lv_devices_ $vg /$convlv ${ lv2 } _mimage_0 ${ lv2 } _mimage_1
lv_mirror_log_ $vg /$convlv ${ lv2 } _mlog
2018-11-18 23:38:56 +03:00
fi # ! -f LOCAL_LVMPOLLD
2012-03-16 17:00:05 +04:00
#COMM "cleanup"
2008-10-06 20:47:07 +04:00
check_and_cleanup_lvs_
2008-01-31 15:19:36 +03:00
# Temporary mirror log should have "_mlogtmp_<n>" suffix
# but currently lvconvert doesn't have an option to add the log.
# If such feature is added in future, a test for that should
# be added.
# ---------------------------------------------------------------------