From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] btrfs-progs: misc-tests: add test case for receive --clone-fallback
Date: Thu, 30 Sep 2021 08:00:42 +0800 [thread overview]
Message-ID: <20210930000042.10147-3-wqu@suse.com> (raw)
In-Reply-To: <20210930000042.10147-1-wqu@suse.com>
The new test case will create two send streams:
- parent_stream
A full send stream.
Contains one file, as clone source.
- clone_stream
An incremental send stream.
Contains one clone operation.
Then we will receive the parent_stream with default mount options, while
try to receive the clone_stream with nodatasum mount option.
This should result clone failure due to nodatasum flag mismatch.
Then check if the receive can continue with --clone-fallback option.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
.../049-receive-clone-fallback/test.sh | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100755 tests/misc-tests/049-receive-clone-fallback/test.sh
diff --git a/tests/misc-tests/049-receive-clone-fallback/test.sh b/tests/misc-tests/049-receive-clone-fallback/test.sh
new file mode 100755
index 000000000000..d383c0e08a68
--- /dev/null
+++ b/tests/misc-tests/049-receive-clone-fallback/test.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Verify that btrfs receive can fallback to buffered copy when clone
+# failed
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+setup_root_helper
+prepare_test_dev
+
+tmp=$(mktemp -d --tmpdir btrfs-progs-send-stream.XXXXXX)
+
+# Create two send stream, one as the parent and the other as an incremental
+# stream with one clone operation.
+run_check_mkfs_test_dev
+run_check_mount_test_dev -o datacow,datasum
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv"
+run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=1 of="$TEST_MNT/subv/file1"
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/subv" \
+ "$TEST_MNT/snap1"
+run_check $SUDO_HELPER cp --reflink=always "$TEST_MNT/subv/file1" \
+ "$TEST_MNT/subv/file2"
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r "$TEST_MNT/subv" \
+ "$TEST_MNT/snap2"
+
+run_check $SUDO_HELPER "$TOP/btrfs" send -f "$tmp/parent_stream" \
+ "$TEST_MNT/snap1"
+run_check $SUDO_HELPER "$TOP/btrfs" send -f "$tmp/clone_stream" \
+ -p "$TEST_MNT/snap1" "$TEST_MNT/snap2"
+
+run_check_umount_test_dev
+run_check_mkfs_test_dev
+
+# Now we have the needed stream, try to receive them with different mount
+# options
+run_check_mount_test_dev -o datacow -o datasum
+
+# Receiving the full stream should not fail
+run_check $SUDO_HELPER "$TOP/btrfs" receive -f "$tmp/parent_stream" "$TEST_MNT"
+
+# No remount helper, so here we manually unmoutn and re-mount with different
+# nodatasum option
+run_check_umount_test_dev
+run_check_mount_test_dev -o datacow,nodatasum
+
+# Receiving incremental send stream without --clone-fallback should fail.
+# As the clone source and destination have different NODATASUM flags
+run_mustfail "receiving clone with different NODATASUM should fail" \
+ $SUDO_HELPER "$TOP/btrfs" receive -f "$tmp/clone_stream" "$TEST_MNT"
+
+# Firstly we need to cleanup the partially received subvolume
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT/snap2"
+
+# With --clone-fallback specified, the receive should finish without problem
+run_check $SUDO_HELPER "$TOP/btrfs" receive --clone-fallback \
+ -f "$tmp/clone_stream" "$TEST_MNT"
+run_check_umount_test_dev
+
+rm -rf -- "$tmp"
--
2.33.0
next prev parent reply other threads:[~2021-09-30 0:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 0:00 [PATCH 0/2] btrfs-progs: receive: introduce new --clone-fallback option Qu Wenruo
2021-09-30 0:00 ` [PATCH 1/2] btrfs-progs: receive: fallback to buffered copy if clone failed Qu Wenruo
2021-09-30 9:39 ` Filipe Manana
2021-09-30 0:00 ` Qu Wenruo [this message]
2021-09-30 10:03 ` [PATCH 2/2] btrfs-progs: misc-tests: add test case for receive --clone-fallback Filipe Manana
2021-09-30 10:18 ` Qu Wenruo
2021-09-30 10:30 ` Filipe Manana
2021-09-30 10:42 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210930000042.10147-3-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox