Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2015 00:00:57 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r292297 - projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy
Message-ID:  <201512160000.tBG00vPv041841@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Dec 16 00:00:57 2015
New Revision: 292297
URL: https://svnweb.freebsd.org/changeset/base/292297

Log:
  Add zpool_destroy_004_pos test case.
  
  This test targets the ability of 'zpool destroy -f' to tear down the pool
  even if there is activity on it.  In particular, this tests a background zfs
  send | zfs receive.
  
  zpool_destroy_004_pos tests the following combinations:
  
    - Data size of 1GB: sleep times 0.1 0.3 0.5 0.75 1 2 3
      The goal is to test the race conditions at various points during the
      process of 'zfs send' and 'zfs receive', with respect to when the 'zpool
      destroy -f' takes place.
    - Data size of 4/3 physical memory: sleep time 15
      The goal is to validate that the destroy process teardown time is
      orthagonal to the send stream size.
  
  Each test point above looks like this:
  
    for sleeptime in <sleep times>; do
      Run the tests where the sender and receiver are the same pool
      Run the tests where they differ; destroy the sender
      Run the tests where they differ; destroy the receiver
    done
  
  The tests in each step above perform the following:
  
    - Create the sender pool (and receiver pool if applicable)
    - Create a dataset on the sender, populate it, then snapshot it
    - Start the send | receive in the background
    - Sleep $sleeptime seconds
    - Do the forced destroy of the target pool, must succeed
    - Wait for the background subshell to exit non-zero
    - Verify that the target pool is indeed no longer visible
  
  Submitted by:	Will
  Sponsored by:	Spectra Logic Corp

Added:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh
Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_test.sh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/Makefile	Tue Dec 15 23:56:57 2015	(r292296)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/Makefile	Wed Dec 16 00:00:57 2015	(r292297)
@@ -13,5 +13,6 @@ FILES+=	zpool_destroy.cfg
 FILES+=	zpool_destroy_001_pos.ksh
 FILES+=	zpool_destroy_002_pos.ksh
 FILES+=	zpool_destroy_003_neg.ksh
+FILES+=	zpool_destroy_004_pos.ksh
 
 .include <bsd.test.mk>

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh	Wed Dec 16 00:00:57 2015	(r292297)
@@ -0,0 +1,119 @@
+#!/usr/local/bin/ksh93 -p
+#
+# Copyright 2015 Spectra Logic Corporation.
+#
+
+. $STF_SUITE/include/libtest.kshlib
+
+################################################################################
+#
+# __stc_assertion_start
+#
+# ID: zpool_destroy_004_pos
+#
+# DESCRIPTION: 
+#	'zpool destroy -f <pool>' can forcibly destroy the specified pool,
+#       even if that pool has running zfs send or receive activity.
+#
+# STRATEGY:
+#	1. Create a storage pool
+#       2. For each sleep time in a set:
+#       2a. For each destroy type (same pool, sender only, receiver only):
+#	    - Create a dataset with some amount of data
+#           - Run zfs send | zfs receive in the background.
+#           - Sleep the amount of time specified for this run.
+#	    - 'zpool destroy -f' the pool.
+#	    - Wait for the send|receive to exit.  It must not be killed in
+#	      order to ensure that the destroy takes care of doing so.
+#	    - Verify the pool destroyed successfully
+#
+# __stc_assertion_end
+#
+###############################################################################
+
+verify_runnable "global"
+
+function cleanup
+{
+	poolexists $TESTPOOL && destroy_pool $TESTPOOL
+	poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
+}
+
+function create_sender
+{
+	cleanup
+	create_pool "$TESTPOOL" "$DISK0"
+	log_must $ZFS create $TESTPOOL/$TESTFS
+	log_must $MKDIR -p $TESTDIR
+	log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
+	log_must dd if=/dev/zero of=$TESTDIR/f0 bs=1024k count=$datasz
+	log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap1
+}
+
+function create_sender_and_receiver
+{
+	create_sender
+	create_pool "$TESTPOOL1" "$DISK1"
+}
+
+function send_recv_destroy
+{
+	sleeptime=$1
+	recv=$2
+	to_destroy=$3
+
+	( $ZFS send -RP $TESTPOOL/$TESTFS@s0 | $ZFS receive -Fu $recv/d1 ) &
+	sendrecvpid=$!
+
+	log_must sleep $sleeptime
+	destroy_start=$(date '+%s')
+	log_must $ZPOOL destroy -f $to_destroy
+	destroy_end=$(date '+%s')
+	dtime=$(expr ${destroy_end} - ${destroy_start})
+	log_note "Destroy took ${dtime} seconds."
+
+	log_note "If this wait returns 0, it means send or receive succeeded."
+	log_mustnot wait $sendrecvpid
+	wait_end=$(date '+%s')
+	wtime=$(expr ${wait_end} - ${destroy_end})
+	log_note "send|receive took ${wtime} seconds to finish."
+
+	log_mustnot $ZPOOL list $to_destroy
+}
+
+function run_tests
+{
+	log_note "TEST: send|receive to the same pool"
+	create_sender
+	send_recv_destroy $sleeptime $TESTPOOL $TESTPOOL
+
+	log_note "TEST: send|receive to different pools, destroy sender"
+	create_sender_and_receiver
+	send_recv_destroy $sleeptime $TESTPOOL1 $TESTPOOL
+
+	log_note "TEST: send|receive to different pools, destroy receiver"
+	create_sender_and_receiver
+	send_recv_destroy $sleeptime $TESTPOOL1 $TESTPOOL1
+}
+
+log_assert "'zpool destroy -f <pool>' can force destroy active pool"
+log_onexit cleanup
+set_disks
+
+# Faster tests using 1GB data size
+datasz=1000
+log_note "Running fast tests with 1000MB of data"
+for sleeptime in 0.1 0.3 0.5 0.75 1 2 3; do
+	run_tests
+done
+
+# A longer test that simulates a more realistic send|receive that exceeds
+# the size of physical memory by 1/3 and gets interrupted a decent amount of
+# time after the start of the run.
+physmem=$(sysctl -n hw.physmem)
+datasz=$(expr ${physmem} / 1048576 \* 4 / 3)
+log_note "Running longer test with ${datasz}MB of data"
+sleeptime=15
+run_tests
+
+log_pass "'zpool destroy -f <pool>' successful with active pools."

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_test.sh	Tue Dec 15 23:56:57 2015	(r292296)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_test.sh	Wed Dec 16 00:00:57 2015	(r292297)
@@ -98,10 +98,37 @@ zpool_destroy_003_neg_cleanup()
 }
 
 
+atf_test_case zpool_destroy_004_pos cleanup
+zpool_destroy_004_pos_head()
+{
+	atf_set "descr" "'zpool destroy -f' should work on active pools."
+	atf_set "require.progs" zfs zpool
+	atf_set "require.config" at_least_2_disks
+	atf_set "timeout" 2000
+}
+zpool_destroy_004_pos_body()
+{
+	export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ")
+	. $(atf_get_srcdir)/../../../include/default.cfg
+	. $(atf_get_srcdir)/zpool_destroy.cfg
+
+	ksh93 $(atf_get_srcdir)/zpool_destroy_004_pos.ksh || atf_fail "Testcase failed"
+}
+zpool_destroy_004_pos_cleanup()
+{
+	export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ")
+	. $(atf_get_srcdir)/../../../include/default.cfg
+	. $(atf_get_srcdir)/zpool_destroy.cfg
+
+	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
+}
+
+
 atf_init_test_cases()
 {
 
 	atf_add_test_case zpool_destroy_001_pos
 	atf_add_test_case zpool_destroy_002_pos
 	atf_add_test_case zpool_destroy_003_neg
+	atf_add_test_case zpool_destroy_004_pos
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512160000.tBG00vPv041841>