Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: functional: switch to rsync for directory diffs #12588

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

cyphar
Copy link
Contributor

@cyphar cyphar commented Sep 24, 2021

This has been split off from #12209 so that it can be reviewed separately and the ZFS test failures (which appear to be real bugs in ZFS or the test suite) can be resolved separately to the renameat2 patchset.

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.

Signed-off-by: Aleksa Sarai cyphar@cyphar.com

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@cyphar cyphar mentioned this pull request Sep 24, 2021
13 tasks
@behlendorf
Copy link
Contributor

@cyphar the causes of the failures here is that rsync is detecting a change in mtime. The replay tests are a good example, the ZIL record only contains the create time which is set correctly, but the current mtime is used during replay. We could change this in the code, but since it's the expected long standing behavior I'd rather update the tests to handle it.

I'd suggest pulling commit 06947ea in to this PR (or something like it) to resolve these failures. Locally the failing tests pass for me with this change applied.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Sep 27, 2021
@ghost ghost self-requested a review September 27, 2021 21:21
@cyphar
Copy link
Contributor Author

cyphar commented Sep 28, 2021

the causes of the failures here is that rsync is detecting a change in mtime. The replay tests are a good example, the ZIL record only contains the create time which is set correctly, but the current mtime is used during replay. We could change this in the code, but since it's the expected long standing behavior I'd rather update the tests to handle it.

Ah okay, I assumed that replay would recover the mtime as well as the ctime. That makes a lot of sense. I am a bit confused why rsync reports that there are different xattrs under FreeBSD but I'll apply the commit you mentioned (or try to figure out a slightly cleaner way of doing it -- I think rsync should have a flag that ignores mtimes).

@ghost
Copy link

ghost commented Sep 28, 2021

The failure is reproducible. listing the contents of each dir right before the rsync comparison in slog_replay_fs_001 is a bit more readable than the itemized changes for me. I notice the size differences, but I don't know why they're different.
original:

total 10273
drwxr-xr-x  3 root  wheel       19 Sep 28 19:51 .
drwxr-xr-x  3 root  wheel        3 Sep 28 19:51 ..
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 b
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 c
lrwxr-xr-x  1 root  wheel       18 Sep 28 19:51 d -> /testpool/testfs/c
-rw-r--r--  2 root  wheel        0 Sep 28 19:51 e
-rw-r--r--  2 root  wheel        0 Sep 28 19:51 f
-rw-r--r--  1 root  wheel   262144 Sep 28 19:51 holes.1
-rw-r--r--  1 root  wheel   524288 Sep 28 19:51 holes.2
-rw-r--r--  1 root  wheel  1048576 Sep 28 19:51 holes.3
-rw-r--r--  1 root  wheel  8388608 Sep 28 19:51 large
-rw-r--r--  1 root  wheel  1048576 Sep 28 19:51 link_and_unlink
-rw-r--r--  1 root  wheel     8192 Sep 28 19:51 payload
-r-xrw-rwx  1 root  wheel        0 Nov 27  2013 setattr
-rw-r--r--  1 root  wheel      512 Sep 28 19:51 small_file
-rw-r--r--  1 root  wheel        1 Sep 28 19:51 sync
-rw------T  1 root  wheel        0 Sep 28 19:51 truncated_file
drwxr-xr-x  2 root  wheel        2 Sep 28 19:51 xattr.dir
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 xattr.file

copy:

total 11172
drwxr-xr-x  3 root  wheel      512 Sep 28 19:51 .
drwxr-xr-x  3 root  wheel      512 Sep 28 19:51 ..
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 b
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 c
lrwxr-xr-x  1 root  wheel       18 Sep 28 19:51 d -> /testpool/testfs/c
-rw-r--r--  2 root  wheel        0 Sep 28 19:51 e
-rw-r--r--  2 root  wheel        0 Sep 28 19:51 f
-rw-r--r--  1 root  wheel   262144 Sep 28 19:51 holes.1
-rw-r--r--  1 root  wheel   524288 Sep 28 19:51 holes.2
-rw-r--r--  1 root  wheel  1048576 Sep 28 19:51 holes.3
-rw-r--r--  1 root  wheel  8388608 Sep 28 19:51 large
-rw-r--r--  1 root  wheel  1048576 Sep 28 19:51 link_and_unlink
-rw-r--r--  1 root  wheel     8192 Sep 28 19:51 payload
-r-xrw-rwx  1 root  wheel        0 Nov 27  2013 setattr
-rw-r--r--  1 root  wheel      512 Sep 28 19:51 small_file
-rw-r--r--  1 root  wheel        1 Sep 28 19:51 sync
-rw------T  1 root  wheel        0 Sep 28 19:51 truncated_file
drwxr-xr-x  2 root  wheel      512 Sep 28 19:51 xattr.dir
-rw-r--r--  1 root  wheel        0 Sep 28 19:51 xattr.file

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice the size differences, but I don't know why they're different.

Interestingly after spot checking a few of the builders I only saw the size differences on FreeBSD. Most of this code is common so that's a bit surprising, I'm not sure what's going on there either.

or try to figure out a slightly cleaner way of doing it

I'm all for it! Although I couldn't find a way myself, it also looks like perhaps --no-times isn't quite sufficient based on the latest CI results.

tests/zfs-tests/include/libtest.shlib Outdated Show resolved Hide resolved
@behlendorf
Copy link
Contributor

@cyphar to move this forward we're going to need to somehow suppress the mtime/crtime warnings. Those are expected. The size warnings on FreeBSD for the directories are interesting but not harmful so let's update the test for now to ignore them as well.

@ghost
Copy link

ghost commented Nov 9, 2021

Agreed, the test change seems good and the failure it exposes can be investigated separately.

@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch from d2fb618 to 648b512 Compare February 17, 2022 06:54
@cyphar
Copy link
Contributor Author

cyphar commented Feb 17, 2022

Sorry, I was busy and only just got back to this now. I've rebased it and cleaned up the ignore_mtimes usage so it's more clear what's going on in the handful of places that use it.

Based on some quick tests, different sized directories aren't detected by rsync at all so that shouldn't matter (likely because it can't change directory sizes so it's just ignored). The other issue I saw on FreeBSD was that there were xattr changes mentioned by rsync in the ZIL replays tests, and I couldn't quite figure out how to debug them (maybe I should spin up a FreeBSD VM...).

@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch 3 times, most recently from 0a164e8 to 377e5ac Compare February 21, 2022 09:00
@cyphar
Copy link
Contributor Author

cyphar commented Feb 22, 2022

@behlendorf @freqlabs We are now ignoring all timestamp errors (Linux tests still seem to fail but they seem unrelated since those tests don't use directory_diff and there are no directory_diff failures under Linux). However (as I mentioned above), it appears that on FreeBSD, xattrs are being changed after a ZIL replay:

13:21:25.81 NOTE: Verify working set diff:
13:21:25.81 note: this rsync package does not support --crtimes
13:21:25.87 .f........x. xattr.file
13:21:25.87 .d........x. xattr.dir/
13:21:25.88 
13:21:25.88 ERROR: replay_directory_diff /mnt/testdir/copy /testpool/testfs exited 1

I will need to investigate this a bit more, but this seems to be something we shouldn't ignore? If you'd like me to ignore xattr errors specifically for this test, I can do that too. I'll spin up a FreeBSD VM to figure out what the difference is.

@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch from 377e5ac to e402f69 Compare February 22, 2022 05:42
@cyphar
Copy link
Contributor Author

cyphar commented Feb 22, 2022

I just tried to reproduce the xattr issue in a FreeBSD 13-RELEASE VM, and I couldn't get it to work.

% truncate 10G disk
% mdconfig -a -t vnode -f disk
md0
% zpool create tank md0
% zfs create tank/fs
% sync if=/dev/zero of=/tank/fs/sync bs=1 count=1 conv=fsync,fdatasync
...
% zpool freeze tank
% touch /tank/fs/xattr.file
% mkdir /tank/fs/xattr.dir
% setextattr user fileattr HelloWorldFile /tank/fs/xattr.file
% setextattr user fileattr HelloWorldDir /tank/fs/xattr.dir
% setextattr user tmpattr HelloWorld /tank/fs/xattr.file
% setextattr user tmpattr HelloWorld /tank/fs/xattr.dir
% rmextattr user tmpattr /tank/fs/xattr.file
% rmextattr user tmpattr /tank/fs/xattr.dir
% rsync -aAHX /tank/fs/ /tankfs-backup/
% zfs unmount tank/fs
% zpool export tank
% zpool import -f tank
% rsync -ni -aAHX /tank/fs/ /tankfs-backup/
.d..t....... ./

I'm really not sure why this is failing within the tests -- the xattrs are actually identical when I try to reproduce the issue locally.

This was done with the built-in ZFS on FreeBSD -- I'm not familiar enough with FreeBSD to compile a custom kernel module to try the latest version of OpenZFS. If someone else could take a look at this, I'd really appreciate it.

@ghost
Copy link

ghost commented Feb 22, 2022

Sure, I'll take a look.

@behlendorf
Copy link
Contributor

Linux tests still seem to fail but they seem unrelated since those tests don't use directory_diff and there are no directory_diff failures under Linux

Perhaps this comment was for a previous run, but the latest CI results show the Linux bots failing on these tests which were modified to use directory-diff. For reference we do still get CI failures, but normally it's just one or two of the bots.

    FAIL cli_root/zfs_snapshot/zfs_snapshot_009_pos (expected PASS)
    FAIL rsend/recv_dedup (expected PASS)
    FAIL slog/slog_replay_fs_001 (expected PASS)
    FAIL slog/slog_replay_fs_002 (expected PASS)

@cyphar
Copy link
Contributor Author

cyphar commented Feb 23, 2022

@behlendorf Ah, I was looking at the Debian tests (which aren't failing in any of the directory_diff users). But they are failing on CentOS -- I suspect it's got to do with SELinux because all of the differences are xattr-related. We need to filter out non-user.* extended attributes (we're running rsync as root and in that case it tries to copy system-level xattrs as well as user ones).

There's also a separate issue with zfs_snapshot_009_pos...

@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch 2 times, most recently from 1806ada to 1d90061 Compare February 23, 2022 13:35
@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch 3 times, most recently from d6591a3 to 16ac85e Compare February 25, 2022 12:30
@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch 2 times, most recently from 4b1b40e to d3f12a2 Compare February 26, 2022 05:43
@cyphar
Copy link
Contributor Author

cyphar commented Feb 27, 2022

@behlendorf After many many many test fixes, all the tests are passing now. 😸

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.
This fix was suggested by Brian Behlendorf.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
@cyphar cyphar force-pushed the zfstest-rsync-directory-diff branch from 8758401 to 9326492 Compare February 28, 2022 02:21
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for sorting out all of those additional test case fixes so we can get this integrated. You probably already saw, but the two FreeBSD failures are known unrelated issues so no need to worry about this.

    FAIL cli_root/zfs_receive/receive-o-x_props_override (expected PASS)
    FAIL largest_pool/largest_pool_001_pos (expected PASS)

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Feb 28, 2022
@behlendorf behlendorf merged commit 669683c into openzfs:master Mar 1, 2022
@cyphar cyphar deleted the zfstest-rsync-directory-diff branch March 2, 2022 07:36
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
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 openzfs#12588
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Aug 30, 2022
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 openzfs#12588
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 1, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
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 openzfs#12588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants