mirror_zfs/tests/zfs-tests/tests/functional/rsend/recv_dedup.ksh
Aleksa Sarai 669683c4cb
ZTS: switch to rsync for directory diffs
While "diff -r" is the most straightforward way of comparing directory
trees for differences, it has two major issues:

 * File metadata is not compared, which means that subtle bugs may be
   missed even if a test is written that exercises the buggy behaviour.
 * diff(1) doesn't know how to compare special files -- it assumes they
   are always different, which means that a test using diff(1) on
   special files will always fail (resulting in such tests not being
   added).

rsync can be used in a very similar manner to diff (with the -ni flags),
but has the additional benefit of being able to detect and resolve many
more differences between directory trees. In addition, rsync has a
standard set of features and flags while diffs feature set depends on
whether you're using GNU or BSD binutils.

Note that for several of the test cases we expect that file timestamps
will not match. For example, the ctime for a file creation or modify
event is stored in the intent log but not the mtime. Thus when replaying
the log the correct ctime is set but the current mtime is used. This is
the expected behavior, so to prevent these tests from failing, there's a
replay_directory_diff function which ignores those kinds of changes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Closes #12588
2022-03-01 10:05:32 -08:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#
#
# Copyright (c) 2020 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/rsend/rsend.kshlib
#
# DESCRIPTION:
# Verifies that we can receive a dedup send stream by processing it with
# "zstream redup".
#
verify_runnable "both"
function cleanup
{
destroy_dataset $TESTPOOL/recv "-r"
rm -r /$TESTPOOL/tar
rm $sendfile
}
log_onexit cleanup
log_assert "Verify zfs can receive dedup send streams with 'zstream redup'"
typeset sendfile_compressed=$STF_SUITE/tests/functional/rsend/dedup.zsend.bz2
typeset sendfile=/$TESTPOOL/dedup.zsend
typeset tarfile=$STF_SUITE/tests/functional/rsend/fs.tar.gz
log_must eval "bzcat <$sendfile_compressed >$sendfile"
log_must zfs create $TESTPOOL/recv
log_must eval "zstream redup $sendfile | zfs recv -d $TESTPOOL/recv"
log_must mkdir /$TESTPOOL/tar
log_must tar --directory /$TESTPOOL/tar -xzf $tarfile
# The recv'd filesystem is called "/fs", so only compare that subdirectory.
log_must directory_diff /$TESTPOOL/tar/fs /$TESTPOOL/recv/fs
log_pass "zfs can receive dedup send streams with 'zstream redup'"