xref: /freebsd/tools/test/stress2/misc/graid1_5.sh (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
1#!/bin/sh
2
3#
4# Copyright (c) 2017 Dell EMC Isilon
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26# SUCH DAMAGE.
27#
28
29# Mirror tests with gnop(8) errors introduced in 2 out of three partitions.
30
31# https://people.freebsd.org/~pho/stress/log/graid1_5-2.txt
32# Fixed by r327698
33
34[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
35
36. ../default.cfg
37
38gmirror load > /dev/null 2>&1 && unload=1
39gmirror status > /dev/null || exit 0
40
41gnop load > /dev/null && unload2=1;
42gnop status > /dev/null || exit 0
43
44[ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; }
45old=`sysctl -n kern.geom.mirror.debug`
46sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 ||
47	sysctl kern.geom.mirror.debug=$old > /dev/null
48
49u1=$mdstart
50u2=$((mdstart + 1))
51u3=$((mdstart + 2))
52s=0
53for u in $u1 $u2 $u3; do
54	[ -c /dev/md$u ] && mdconfig -d -u $u
55	mdconfig -a -t swap -s 341m -u $u
56	gpart create -s GPT md$u
57done > /dev/null
58
59set -e
60(
61gpart add -t freebsd-ufs -s 340m md$u1
62gpart add -t freebsd-ufs -s 340m md$u2
63gpart add -t freebsd-ufs -s 340m md$u3
64) > /dev/null
65gnop create md$u2
66gnop create md$u3
67gmirror label test md${u1}p1 md$u2.nopp1 md$u3.nopp1
68[ "`sysctl -in kern.geom.mirror.launch_mirror_before_timeout`" = "0" ] &&
69    sleep $((`sysctl -n kern.geom.mirror.timeout` + 1))
70[ -c /dev/mirror/test ] || exit 1
71
72newfs /dev/mirror/test > /dev/null
73mount /dev/mirror/test $mntpoint
74set +e
75chmod 777 $mntpoint
76
77export runRUNTIME=5m
78export RUNDIR=$mntpoint/stressX
79rm -rf /tmp/stressX.control
80
81su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 &
82pid=$!
83
84gnop configure -r 0 -w 1 md$u2.nop
85gnop configure -r 0 -w 1 md$u3.nop
86while kill -0 $pid > /dev/null 2>&1; do
87	if ! gmirror status test | grep -q md$u2.nopp1; then
88		gmirror forget test
89		gmirror remove test md$u2.nopp1 2>/dev/null
90		gmirror insert test md$u2.nopp1 2>/dev/null
91	fi
92	if ! gmirror status test | grep -q md$u3.nopp1; then
93		gmirror forget test
94		gmirror remove test md$u3.nopp1 2>/dev/null
95		gmirror insert test md$u3.nopp1 2>/dev/null
96	fi
97	sleep 1
98done
99wait
100
101while mount | grep $mntpoint | grep -q /mirror/; do
102	umount $mntpoint || sleep 5
103done
104while gmirror status test | grep -q SYNCHRONIZING; do sleep 10; done
105for i in `jot 10`; do
106	gmirror stop test && break || sleep 30
107done
108[ $i -eq 10 ] && s=1
109gmirror destroy test 2>/dev/null
110[ $unload ] && gmirror unload
111
112for u in $u1 $u2 $u3; do
113	mdconfig -d -u $u || s=3
114done
115[ $unload2 ] && gnop unload
116exit $s
117