fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 561
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test generic/561
6 #
7 # Dedup & random I/O race test, do multi-threads fsstress and dedupe on
8 # same directory/files
9 #
10 . ./common/preamble
11 _begin_fstest auto stress dedupe
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         rm -f $tmp.*
18         end_test
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/reflink
24
25 # real QA test starts here
26 _supported_fs generic
27 _require_scratch_duperemove
28 _require_command "$KILLALL_PROG" killall
29
30 _scratch_mkfs > $seqres.full 2>&1
31 _scratch_mount >> $seqres.full 2>&1
32
33 function end_test()
34 {
35         local f=1
36
37         # stop duperemove running
38         if [ -e $dupe_run ]; then
39                 rm -f $dupe_run
40                 $KILLALL_PROG -q $DUPEREMOVE_PROG > /dev/null 2>&1
41                 wait $dedup_pids
42         fi
43
44         # Make sure all fsstress get killed
45         while [ $f -ne 0 ]; do
46                 $KILLALL_PROG -q $FSSTRESS_PROG > /dev/null 2>&1
47                 sleep 1
48                 f=`ps -eLf | grep $FSSTRESS_PROG | grep -v "grep" | wc -l`
49         done
50 }
51
52 sleep_time=$((50 * TIME_FACTOR))
53
54 # Start fsstress
55 testdir="$SCRATCH_MNT/dir"
56 mkdir $testdir
57 fsstress_opts="-r -n 1000 -p $((5 * LOAD_FACTOR))"
58 $FSSTRESS_PROG $fsstress_opts -d $testdir -l 0 >> $seqres.full 2>&1 &
59 dedup_pids=""
60 dupe_run=$TEST_DIR/${seq}-running
61 # Start several dedupe processes on same directory
62 touch $dupe_run
63 for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do
64         while [ -e $dupe_run ]; do
65                 $DUPEREMOVE_PROG -dr --dedupe-options=same $testdir \
66                         >>$seqres.full 2>&1
67         done 2>&1 | sed -e '/Terminated/d' &
68         dedup_pids="$! $dedup_pids"
69 done
70
71 # End the test after $sleep_time seconds
72 sleep $sleep_time
73 end_test
74
75 # umount and mount again, verify pagecache contents don't mutate and a fresh
76 # read from the disk also doesn't show mutations.
77 find $testdir -type f -exec md5sum {} \; > ${tmp}.md5sum
78 _scratch_cycle_mount
79 md5sum -c --quiet ${tmp}.md5sum
80
81 echo "Silence is golden"
82 status=0
83 exit