2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-03-05 23:00:44 +03:00
# Copyright (C) 2008-2012 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
2015-03-05 23:00:44 +03:00
test_description = 'Set up things to run tests with sanlock'
. lib/inittest
[ -z " $LVM_TEST_LOCK_TYPE_SANLOCK " ] && skip;
# Create a device and a VG that are both outside the scope of
# the standard lvm test suite so that they will not be removed
# and will remain in place while all the tests are run.
#
# Use this VG to hold the sanlock global lock which will be used
# by lvmlockd during other tests.
#
# This script will be run before any standard tests are run.
# After all the tests are run, another script will be run
# to remove this VG and device.
GL_DEV = "/dev/mapper/GL_DEV"
GL_FILE = " $PWD /gl_file.img "
2015-08-21 00:10:36 +03:00
dmsetup remove GL_DEV || true
2015-03-05 23:00:44 +03:00
rm -f " $GL_FILE "
dd if = /dev/zero of = " $GL_FILE " bs = $(( 1024 * 1024 )) count = 1024 2> /dev/null
GL_LOOP = $( losetup -f " $GL_FILE " --show)
2017-07-10 11:38:55 +03:00
echo " 0 $( blockdev --getsize $GL_LOOP linear $GL_LOOP 0) " | dmsetup create GL_DEV
2015-03-05 23:00:44 +03:00
2016-02-23 22:58:22 +03:00
aux prepare_sanlock
aux prepare_lvmlockd
2015-03-05 23:00:44 +03:00
2015-08-18 22:50:45 +03:00
vgcreate --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' --lock-type sanlock glvg $GL_DEV
2015-03-05 23:00:44 +03:00
vgs --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' -o+locktype,lockargs glvg