Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 2017 22:12:45 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r323939 - in projects/zfsd/head/tests/sys/cddl/zfs/tests: cli_root/zpool_import hotspare
Message-ID:  <201709222212.v8MMCjRq081592@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Fri Sep 22 22:12:45 2017
New Revision: 323939
URL: https://svnweb.freebsd.org/changeset/base/323939

Log:
  Rewrite hotspare_replace_003_neg.
  
  This test case was overly complicated.  The new version is simpler and runs
  faster.  I also moved it into the zpool_import directory because it doesn't
  really have anything to do with hotspares.
  
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
  tests/sys/cddl/zfs/tests/hotspare/Makefile
  tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh
  tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh
  	Move hotspare_replace_003_neg to zpool_import_destroyed_002_neg and
  	simplify it.
  
  Sponsored by:	Spectra Logic Corp

Added:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh
     - copied, changed from r323938, projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh
Deleted:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh
Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile	Fri Sep 22 22:06:09 2017	(r323938)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile	Fri Sep 22 22:12:45 2017	(r323939)
@@ -15,6 +15,7 @@ ${PACKAGE}FILES+=	zpool_import_all_001_pos.ksh
 ${PACKAGE}FILES+=	zpool_import.cfg
 ${PACKAGE}FILES+=	zpool_import_corrupt_001_pos.ksh
 ${PACKAGE}FILES+=	zpool_import_destroyed_001_neg.ksh
+${PACKAGE}FILES+=	zpool_import_destroyed_002_neg.ksh
 ${PACKAGE}FILES+=	zpool_import_012_pos.ksh
 ${PACKAGE}FILES+=	zpool_import_013_neg.ksh
 ${PACKAGE}FILES+=	zpool_import_007_pos.ksh

Copied and modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh (from r323938, projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh)
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh	Fri Sep 22 22:06:09 2017	(r323938, copy source)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh	Fri Sep 22 22:12:45 2017	(r323939)
@@ -1,6 +1,6 @@
 #!/usr/local/bin/ksh93
 #
-# Copyright (c) 2010 Spectra Logic Corporation
+# Copyright (c) 2017 Spectra Logic Corporation
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -31,151 +31,29 @@
 # $FreeBSD$
 
 . $STF_SUITE/include/libtest.kshlib
-. $STF_SUITE/include/libsas.kshlib
-. $STF_SUITE/tests/hotspare/hotspare.kshlib
+set_disks
 
-# "zpool import" should not show destroyed pools, even if a non-destroyed label
-# is present.
+# "zpool import" will not show destroyed pools, even if out-of-date
+# non-destroyed label is present
 #
-# This situation arose when a user activated a spare, removed the spare disk,
-# destroyed the pool, reinserted the spare disk, and then tried to import the
-# pool.  Since the pool was destroyed, nothing should've happened.  But the
-# spare disk had a non-destroyed label, so zpool tried to import it.  A panic
-# ensued.
-#
-# To reproduce:
-# 1.  Create a 3 drive raid.
-# 2.  Disable a drive
-# 3.  Let a Spare take over
-# 4.  Disable that Spare when it is done rebuilding.
-# 5.  Let 2nd spare finish rebuilding
-# 6.  Enable the first spare
-# 7.  Enable the original drive
-# 8.  Destroy the pool.
+# This situation can happen any time the following things happen:
+# 1) A disk gets removed with its label intact
+# 2) The pool gets destroyed
+# 3) Somebody run "zpool import" to see importable pools
 
-cleanup() {
-	[[ $DISK0_PHY != 0 ]] && enable_sas_disk $DISK0_EXPANDER $DISK0_PHY
-	[[ $SPARE0_PHY != 0 ]] && enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY
-	[[ $SPARE1_PHY != 0 ]] && enable_sas_disk $SPARE1_EXPANDER $SPARE1_PHY
-	if poolexists $TESTPOOL; then
-		# Test failed, provide something useful.
-		log_note "For reference, here is the final $TESTPOOL status:"
-		zpool status $TESTPOOL
-		log_must destroy_pool $TESTPOOL
-	fi
-	cleanup_devices ${DISKS}
-}
+log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1}
 
-log_onexit cleanup
-trap cleanup TERM INT
+# Offline a disk so it's label won't get updated by the upcoming destroy
+log_must $ZPOOL offline $TESTPOOL ${DISK0}
 
-typeset -A MEMBERS
-typeset -A SPARES
-typeset DISK0_EXPANDER=0
-typeset DISK0_PHY=0
-typeset SPARE0_EXPANDER=0
-typeset SPARE0_PHY=0
-typeset SPARE1_EXPANDER=0
-typeset SPARE1_PHY=0
+# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed
+# state, leaving DISK0's label as the most recent non-destroyed label
+log_must $ZPOOL destroy $TESTPOOL
 
-for disk in $DISKS; do
-	if [[ $DISK0_PHY == 0 ]]; then
-		find_verify_sas_disk $disk
-		DISK0_PHY=$PHY
-		DISK0_EXPANDER=$EXPANDER
-		DISK0_NAME=$disk
-		set -A MEMBERS "${MEMBERS[@]}" $disk
-		continue
-	fi
-	if [[ $SPARE0_PHY == 0 ]]; then
-		find_verify_sas_disk $disk
-		SPARE0_PHY=$PHY
-		SPARE0_EXPANDER=$EXPANDER
-		SPARE0_NAME=$disk
-		set -A SPARES "${SPARES[@]}" $disk
-		continue
-	fi
-	if [[ $SPARE1_PHY == 0 ]]; then
-		find_verify_sas_disk $disk
-		SPARE1_PHY=$PHY
-		SPARE1_EXPANDER=$EXPANDER
-		SPARE1_NAME=$disk
-		set -A SPARES "${SPARES[@]}" $disk
-		continue
-	fi
-	# Already filled those positions?  Add disks to the raidz.
-	if [[ ${#DISKS[*]} -lt 3 ]]; then
-		find_verify_sas_disk $disk
-		[[ -z "$DISK1_NAME" ]] && DISK1_NAME=$disk
-		DISK1_LONG_NAME=`find_disks ${DISK1_NAME}`
-		DISK1_SHORT_NAME=${DISK1_LONG_NAME##/dev/}
-		set -A MEMBERS "${MEMBERS[@]}" $disk
-		continue
-	fi
-	break
-done
-
-# Remove labels etc. from all the disks we're about to use.
-poolexists && log_must destroy_pool $TESTPOOL
-cleanup_devices ${MEMBERS[*]} ${SPARES[*]}
-
-log_must $ZPOOL create -f $TESTPOOL raidz1 ${MEMBERS[@]} spare ${SPARES[@]}
-DISK0_GUID=$(get_disk_guid $DISK0_NAME)
-
-disable_sas_disk $DISK0_EXPANDER $DISK0_PHY
-log_must $ZPOOL replace $TESTPOOL $DISK0_GUID $SPARE0_NAME
-wait_until_resilvered
-SPARE0_GUID=$(get_disk_guid $SPARE0_NAME)
-
-disable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY
-log_must $ZPOOL replace $TESTPOOL $SPARE0_GUID $SPARE1_NAME
-wait_until_resilvered
-
-enable_sas_disk $DISK0_EXPANDER $DISK0_PHY
-enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY
-
-log_must destroy_pool $TESTPOOL
-
-# Screen scrape the 'zpool import' output to ensure that the pool doesn't
-# show up, since it's been destroyed.
-badpoolstate=0
-$ZPOOL import | \
-	while read word1 word2 rest; do
-		echo "$word1 $word2 $rest"
-		case "$word1 $word2" in
-			"pool: $TESTPOOL") (( badpoolstate += 1 )) ;;
-			"$DISK1_LONG_NAME ONLINE") (( badpoolstate += 2 )) ;;
-			"$DISK1_SHORT_NAME ONLINE") (( badpoolstate += 2 )) ;;
-			*) ;;
-		esac
-	done
-
-case $badpoolstate in
-	0)	log_pass ;;
-	1)	log_note "Destroyed pool visible, but probably another pool"
-		log_pass ;;
-	2)	log_fail "One of our disks is visible but pool is not?!" ;;
-	3)	log_fail "Destroyed pool visible!" ;;
-	*)	log_fail "Unexpected output.  Update the test" ;;
-esac
-
-# Bad output looks like this:
-#   pool: testpool.2358
-#     id: 5289863802080396071
-#  state: UNAVAIL
-# status: One or more devices are missing from the system.
-# action: The pool cannot be imported. Attach the missing
-#    devices and try again.
-#   see: http://illumos.org/msg/ZFS-8000-6X
-# config:
-#
-#    testpool.2358              UNAVAIL  missing device
-#      raidz1-0                 DEGRADED
-#        spare-0                UNAVAIL
-#          4564766431272474500  FAULTED  corrupted data
-#          1988887717739330825  FAULTED  corrupted data
-#        da4                    ONLINE
-#        da5                    ONLINE
-#    spares
-#      1988887717739330825
-#      da3
+# Now try to import the pool.  It should fail.
+if $ZPOOL import | $GREP -q $TESTPOOL; then
+	$ZPOOL import
+	log_fail "ERROR: Destroyed pool visible"
+else
+	log_pass
+fi

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh	Fri Sep 22 22:06:09 2017	(r323938)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh	Fri Sep 22 22:12:45 2017	(r323939)
@@ -518,8 +518,8 @@ zpool_import_corrupt_001_pos_cleanup()
 atf_test_case zpool_import_destroyed_001_neg cleanup
 zpool_import_destroyed_001_neg_head()
 {
-	atf_set "descr" "A destroyed pool cannot be imported even if an out-of-date non-destroyed label remains"
-	atf_set "require.progs"  zfs zpool
+	atf_set "descr" "'zpool import' will not show destroyed pools, even if an out-of-date non-destroyed label remains"
+	atf_set "require.progs"  zpool
 }
 zpool_import_destroyed_001_neg_body()
 {
@@ -532,10 +532,32 @@ zpool_import_destroyed_001_neg_cleanup()
 {
 	. $(atf_get_srcdir)/../../../include/default.cfg
 
+	destroy_pool "$TESTPOOL"
 	cleanup_devices "$DISKS"
 }
 
+atf_test_case zpool_import_destroyed_002_neg cleanup
+zpool_import_destroyed_002_neg_head()
+{
+	atf_set "descr" "'zpool import' will not show destroyed pools, even if an out-of-date non-destroyed label remains"
+	atf_set "require.progs"  zpool
+}
+zpool_import_destroyed_002_neg_body()
+{
+	. $(atf_get_srcdir)/../../../include/default.cfg
 
+	verify_disk_count "$DISKS" 2
+	ksh93 $(atf_get_srcdir)/zpool_import_destroyed_002_neg.ksh || atf_fail "Testcase failed"
+}
+zpool_import_destroyed_002_neg_cleanup()
+{
+	. $(atf_get_srcdir)/../../../include/default.cfg
+
+	destroy_pool "$TESTPOOL"
+	cleanup_devices "$DISKS"
+}
+
+
 atf_init_test_cases()
 {
 
@@ -561,4 +583,5 @@ atf_init_test_cases()
 	atf_add_test_case zpool_import_rename_001_pos
 	atf_add_test_case zpool_import_corrupt_001_pos
 	atf_add_test_case zpool_import_destroyed_001_neg
+	atf_add_test_case zpool_import_destroyed_002_neg
 }

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile	Fri Sep 22 22:06:09 2017	(r323938)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile	Fri Sep 22 22:12:45 2017	(r323939)
@@ -18,7 +18,6 @@ ${PACKAGE}FILES+=	hotspare_add_001_pos.ksh
 ${PACKAGE}FILES+=	hotspare_import_001_pos.ksh
 ${PACKAGE}FILES+=	hotspare_replace_002_neg.ksh
 ${PACKAGE}FILES+=	hotspare_clone_002_pos.ksh
-${PACKAGE}FILES+=	hotspare_replace_003_neg.ksh
 ${PACKAGE}FILES+=	hotspare_export_001_neg.ksh
 ${PACKAGE}FILES+=	hotspare_snapshot_001_pos.ksh
 ${PACKAGE}FILES+=	hotspare_remove_004_pos.ksh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh	Fri Sep 22 22:06:09 2017	(r323938)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh	Fri Sep 22 22:12:45 2017	(r323939)
@@ -597,33 +597,6 @@ hotspare_replace_002_neg_cleanup()
 }
 
 
-atf_test_case hotspare_replace_003_neg cleanup
-hotspare_replace_003_neg_head()
-{
-	atf_set "descr" "'zpool replace' of disabled hotspares should result in ignoring them after destroy."
-	atf_set "require.progs"  camcontrol zpool
-	atf_set "timeout" 3600
-}
-hotspare_replace_003_neg_body()
-{
-	. $(atf_get_srcdir)/../../include/default.cfg
-	. $(atf_get_srcdir)/hotspare.kshlib
-	. $(atf_get_srcdir)/hotspare.cfg
-
-	verify_disk_count "$DISKS" 5
-	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
-	ksh93 $(atf_get_srcdir)/hotspare_replace_003_neg.ksh || atf_fail "Testcase failed"
-}
-hotspare_replace_003_neg_cleanup()
-{
-	. $(atf_get_srcdir)/../../include/default.cfg
-	. $(atf_get_srcdir)/hotspare.kshlib
-	. $(atf_get_srcdir)/hotspare.cfg
-
-	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
-}
-
-
 atf_test_case hotspare_scrub_001_pos cleanup
 hotspare_scrub_001_pos_head()
 {
@@ -779,7 +752,6 @@ atf_init_test_cases()
 	atf_add_test_case hotspare_remove_004_pos
 	atf_add_test_case hotspare_replace_001_neg
 	atf_add_test_case hotspare_replace_002_neg
-	atf_add_test_case hotspare_replace_003_neg
 	atf_add_test_case hotspare_scrub_001_pos
 	atf_add_test_case hotspare_scrub_002_pos
 	atf_add_test_case hotspare_shared_001_pos



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