summaryrefslogtreecommitdiff
path: root/tests/generic/560
blob: e3f28667ab039b9b2a73d9a2c03d28737e1e0de8 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
#
# FS QA Test generic/560
#
# Iterate dedupe integrity test. Copy an original data0 several
# times (d0 -> d1, d1 -> d2, ... dn-1 -> dn), dedupe dataN everytime
# before copy. At last, verify dataN same with data0.
#
. ./common/preamble
_begin_fstest auto stress dedupe

# Import common functions.
. ./common/filter
. ./common/reflink

# real QA test starts here
_supported_fs generic
_require_scratch_duperemove

_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1

function iterate_dedup_verify()
{
	local src=$srcdir
	local dest=$dupdir/1

	for ((index = 1; index <= times; index++)); do
		cp -a $src $dest
		find $dest -type f -exec md5sum {} \; \
			> $md5file$index
		# Make some noise
		$FSSTRESS_PROG $fsstress_opts -d $noisedir \
			       -n 200 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
		# Too many output, so only save error output
		$DUPEREMOVE_PROG -dr --dedupe-options=same $dupdir \
			>/dev/null 2>$seqres.full
		md5sum -c --quiet $md5file$index
		src=$dest
		dest=$dupdir/$((index + 1))
	done
}

srcdir=$SCRATCH_MNT/src
dupdir=$SCRATCH_MNT/dup
noisedir=$dupdir/noise
mkdir $srcdir $dupdir
mkdir $dupdir/noise

md5file=${tmp}.md5sum

fsstress_opts="-w -r"
# Create some files to be original data
$FSSTRESS_PROG $fsstress_opts -d $srcdir \
	       -n 500 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1

# Calculate how many test cycles will be run
src_size=`du -ks $srcdir | awk '{print $1}'`
free_size=`df -kP $SCRATCH_MNT | grep -v Filesystem | awk '{print $4}'`
times=$((free_size / src_size))
if [ $times -gt $((4 * TIME_FACTOR)) ]; then
	times=$((4 * TIME_FACTOR))
fi

echo "= Do dedup and verify ="
iterate_dedup_verify

# Use the last checksum file to verify the original data
sed -e s#dup/$times#src#g $md5file$times > $md5file
echo "= Backwords verify ="
md5sum -c --quiet $md5file

# read from the disk also doesn't show mutations.
_scratch_cycle_mount
echo "= Verify after cycle mount ="
for ((index = 1; index <= times; index++)); do
	md5sum -c --quiet $md5file$index
done

status=0
exit