summaryrefslogtreecommitdiff
path: root/test/shell/lvchange-raid-transient-failures.sh
blob: 35b4898022f7244ae390f93fa22add5e7ed39a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash

# Copyright (C) 2016 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,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


SKIP_WITH_LVMPOLLD=1

. lib/inittest

aux have_raid 1 10 1 || skip
aux prepare_vg 6

#
# FIXME: add multi-segment leg tests
#

function _check_raid
{
	local vg=$1
	shift
	local lv=$1
	shift
	local fail=$1
	shift
	local good=$1
	shift
	local devs=( "$@" )

	aux wait_for_sync $vg $lv
	aux disable_dev --error --silent "${devs[@]}"
	mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
	fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv"
	check raid_leg_status $vg $lv "$fail"
	aux enable_dev --silent "${devs[@]}"
	lvs -a -o +devices $vg | tee out
	not grep unknown out
	lvchange --refresh $vg/$lv
	fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv"
	aux wait_for_sync $vg $lv
	fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv"
	check raid_leg_status $vg $lv "$good"
}

# raid1 with transiently failing devices
lv=4way
lvcreate -aey --type raid1 -m 3 --ignoremonitoring -L 1 -n $lv $vg
_check_raid $vg $lv "ADAD" "AAAA" "$dev2" "$dev4"
lvremove -y $vg/$lv

# raid6 with transiently failing devices
lv=6way
lvcreate -aey --type raid6 -i 4 --ignoremonitoring -L 1 -n $lv $vg
_check_raid $vg $lv "ADADAA" "AAAAAA" "$dev2" "$dev4"
lvremove -y $vg/$lv

# raid10 with transiently failing devices
lv=6way
lvcreate -aey --type raid10 -i 3 -m 1 --ignoremonitoring -L 1 -n $lv $vg
_check_raid $vg $lv "ADADDA" "AAAAAA" "$dev2" "$dev4" "$dev5"
lvremove -y $vg/$lv

vgremove -f $vg