Skip to content

Commit

Permalink
Add tests for forcibly unmount filesystem while receiving stream.
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
  • Loading branch information
oshogbo committed Feb 17, 2020
1 parent f7d6aa4 commit a8b7f6e
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ tags = ['functional', 'cli_root', 'zfs_rollback']
[tests/functional/cli_root/zfs_send]
tests = ['zfs_send_001_pos', 'zfs_send_002_pos', 'zfs_send_003_pos',
'zfs_send_004_neg', 'zfs_send_005_pos', 'zfs_send_006_pos',
'zfs_send_007_pos', 'zfs_send_encrypted', 'zfs_send_raw',
'zfs_send_sparse', 'zfs_send-b']
'zfs_send_007_pos', 'zfs_send_008', 'zfs_send_encrypted',
'zfs_send_raw', 'zfs_send_sparse', 'zfs_send-b']
tags = ['functional', 'cli_root', 'zfs_send']

[tests/functional/cli_root/zfs_set]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dist_pkgdata_SCRIPTS = \
zfs_send_005_pos.ksh \
zfs_send_006_pos.ksh \
zfs_send_007_pos.ksh \
zfs_send_008.ksh \
zfs_send_encrypted.ksh \
zfs_send_raw.ksh \
zfs_send_sparse.ksh \
Expand Down
102 changes: 102 additions & 0 deletions tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_008.ksh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/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 Mariusz Zaborski <oshogbo@FreeBSD.org>.

#
# DESCRIPTION:
# Verify 'zfs recv' can forcibly unmount filesystem while receiving
# stream.
#
# STRATEGY:
# 1. Create snapshot of file system
# 2. Make a zfs filesystem mountpoint busy
# 3. Recife filesystem with force flag.
# 4. Verify that stream was received or failed on Linux.
#

. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
. $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg

verify_runnable "both"

function cleanup
{
for snap in $init_snap $inc_snap $rst_snap $rst_inc_snap; do
snapexists $snap && \
log_must zfs destroy -f $snap
done

datasetexists $rst_root && \
log_must zfs destroy -Rf $rst_root

for file in $full_bkup $inc_bkup \
$init_data $inc_data
do
[[ -e $file ]] && \
log_must rm -f $file
done

[[ -d $TESTDIR1 ]] && \
log_must rm -rf $TESTDIR1

cd $curpath
}

log_assert "Verify 'zfs recv' can forcibly unmount busy filesystem."
log_onexit cleanup

curpath=`dirname $0`
init_snap=$TESTPOOL/$TESTFS@init_snap
inc_snap=$TESTPOOL/$TESTFS@inc_snap
full_bkup=$TEST_BASE_DIR/fullbkup.$$
inc_bkup=$TEST_BASE_DIR/incbkup.$$
init_data=$TESTDIR/$TESTFILE1
inc_data=$TESTDIR/$TESTFILE2
orig_sum=""
rst_sum=""
rst_root=$TESTPOOL/rst_ctr
rst_snap=$rst_root/$TESTFS@init_snap
rst_inc_snap=$rst_root/$TESTFS@inc_snap
rst_data=$TESTDIR1/$TESTFS/$TESTFILE1
rst_inc_data=$TESTDIR1/$TESTFS/$TESTFILE2

log_note "Verify 'zfs recv' can forcible unmount busy filesystem."

#Pre-paration
log_must zfs create $rst_root
[[ ! -d $TESTDIR1 ]] && \
log_must mkdir -p $TESTDIR1
log_must zfs set mountpoint=$TESTDIR1 $rst_root

file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT

log_must zfs snapshot $init_snap
zfs send $init_snap > $full_bkup
(( $? != 0 )) && \
log_fail "'zfs send' fails to create full send"

log_note "Verify the send stream is valid to receive."

cd $TESTDIR1
if is_linux; then
log_mustnot zfs receive -M $rst_snap <$full_bkup
else
log_must zfs receive -M $rst_snap <$full_bkup
receive_check $rst_snap ${rst_snap%%@*}
compare_cksum $init_data $rst_data
fi

log_pass "The busy filesystem was unmounted or busy as expected."

0 comments on commit a8b7f6e

Please sign in to comment.