2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-05-03 01:29:06 +03:00
# Copyright (C) 2011-2015 Red Hat, Inc. All rights reserved.
2011-09-25 23:37:00 +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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2011-09-25 23:37:00 +04:00
2011-09-26 11:51:23 +04:00
# set before test's clvmd is started, so it's passed in environ
export LVM_CLVMD_BINARY = clvmd
export LVM_BINARY = lvm
2011-09-25 23:37:00 +04:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 02:45:37 +03:00
SKIP_WITHOUT_CLVMD = 1
SKIP_WITH_LVMPOLLD = 1
2014-06-06 19:40:04 +04:00
. lib/inittest
2011-09-25 23:37:00 +04:00
# only clvmd based test, skip otherwise
2011-09-26 11:51:23 +04:00
read LOCAL_CLVMD < LOCAL_CLVMD
2011-09-25 23:37:00 +04:00
2015-05-03 01:29:06 +03:00
# TODO read from build, for now hardcoded
CLVMD_SOCKET = "/var/run/lvm/clvmd.sock"
2011-09-25 23:37:00 +04:00
2015-05-03 01:29:06 +03:00
restart_clvmd_( ) {
" $LVM_CLVMD_BINARY " -S
2017-07-10 11:40:09 +03:00
ls -la " $CLVMD_SOCKET " || true
2015-05-03 01:29:06 +03:00
for i in $( seq 1 20) ; do
test -S " $CLVMD_SOCKET " && break
sleep .1
done
# restarted clvmd has the same PID (no fork, only execvp)
NEW_LOCAL_CLVMD = $( pgrep clvmd)
test " $LOCAL_CLVMD " -eq " $NEW_LOCAL_CLVMD "
}
aux prepare_vg
2011-09-25 23:37:00 +04:00
lvcreate -an --zero n -n $lv1 -l1 $vg
lvcreate -an --zero n -n $lv2 -l1 $vg
lvcreate -l1 $vg
lvchange -aey $vg /$lv1
lvchange -aey $vg /$lv2
2015-05-03 01:29:06 +03:00
restart_clvmd_
2011-09-26 11:51:23 +04:00
# try restart once more
2015-05-03 01:29:06 +03:00
restart_clvmd_
2011-09-25 23:37:00 +04:00
# FIXME: Hmm - how could we test exclusivity is preserved in singlenode ?
lvchange -an $vg /$lv1
2013-04-21 12:37:52 +04:00
lvchange -aey $vg /$lv1
lvcreate -s -l3 -n snap $vg /$lv1
2011-09-25 23:37:00 +04:00
2011-09-26 11:51:23 +04:00
" $LVM_CLVMD_BINARY " -R
2011-09-25 23:37:00 +04:00
2013-04-21 12:37:52 +04:00
vgchange -an $vg
# Test what happens after 'reboot'
kill " $LOCAL_CLVMD "
2015-05-03 01:29:06 +03:00
while test -e " $CLVMD_PIDFILE " ; do echo -n .; sleep .1; done # wait for the pid removal
2013-04-21 12:37:52 +04:00
aux prepare_clvmd
vgchange -ay $vg
lvremove -f $vg /snap
2011-09-25 23:37:00 +04:00
vgremove -ff $vg