129a4668aa8b37a141f6cbd54f17e2d303c1f77a
[xfstests-dev.git] / tests / generic / 051
1 #!/bin/bash
2 # FS QA Test No. 051
3 #
4 # Basic log recovery stress test - do lots of stuff, shut down in the middle of
5 # it and check that recovery runs to completion and everything can be
6 # successfully removed afterwards..
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38
39 _cleanup()
40 {
41         cd /
42         _scratch_unmount 2>/dev/null
43         rm -f $tmp.*
44 }
45 trap "_cleanup; exit \$status" 0 1 2 3 15
46
47 # real QA test starts here
48 _supported_fs generic
49 _supported_os Linux
50
51 _require_scratch
52 _require_scratch_shutdown
53 _require_command "$KILLALL_PROG" killall
54
55 rm -f $seqres.full
56
57 _scratch_mkfs > $seqres.full 2>&1
58 _require_metadata_journaling $SCRATCH_DEV
59 _scratch_mount
60
61 SLEEP_TIME=$((30 * $TIME_FACTOR))
62 PROCS=$((2 * LOAD_FACTOR))
63
64 load_dir=$SCRATCH_MNT/test
65
66 # let this run for a while
67 $FSSTRESS_PROG $FSSTRESS_AVOID -n10000000 -p $PROCS -d $load_dir >> $seqres.full 2>&1 &
68 sleep $SLEEP_TIME
69 $KILLALL_PROG -q $FSSTRESS_PROG
70 wait
71 sync
72 _scratch_unmount
73
74 # now mount again, run the load again, this time with a shutdown.
75 _scratch_mount
76 $XFS_FSR_PROG -v $load_dir >> $seqres.full 2>&1
77 $FSSTRESS_PROG -n10000000 -p $PROCS -d $load_dir >> $seqres.full 2>&1 &
78 sleep $SLEEP_TIME
79 sync
80
81 # now shutdown and unmount
82 sleep 5
83 _scratch_shutdown
84 $KILLALL_PROG -q $FSSTRESS_PROG
85 wait
86
87 # for some reason fsstress processes manage to live on beyond the wait?
88 sleep 5
89 _scratch_unmount
90
91 # now recover, check the filesystem for consistency
92 _scratch_mount
93 _scratch_unmount
94 _check_scratch_fs
95
96 # now clean up.
97 _scratch_mount
98 for d in $load_dir/*; do
99         rm -rf $d > /dev/null 2>&1 &
100 done
101 wait
102 _scratch_unmount
103
104 echo "No output is good. Failures are loud."
105
106 status=0
107 exit