From owner-svn-src-projects@freebsd.org Mon Jan 29 23:36:06 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97E71EB7362 for ; Mon, 29 Jan 2018 23:36:06 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4AB066CE4E; Mon, 29 Jan 2018 23:36:06 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4157F7227; Mon, 29 Jan 2018 23:36:06 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0TNa6O1059812; Mon, 29 Jan 2018 23:36:06 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0TNa5cf059809; Mon, 29 Jan 2018 23:36:05 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801292336.w0TNa5cf059809@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 29 Jan 2018 23:36:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r328570 - projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd X-SVN-Commit-Revision: 328570 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 23:36:06 -0000 Author: asomers Date: Mon Jan 29 23:36:05 2018 New Revision: 328570 URL: https://svnweb.freebsd.org/changeset/base/328570 Log: Add a regression test for PR 225547 zfsd(8) shouldn't add a spare to a replacing vdev tests/sys/cddl/zfs/tests/zfsd/Makefile tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_008_neg.ksh tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Add a test case to check that zfsd shouldn't activate a spare for a child of a replacing vdev. Fixing zfsd itself is still TODO. PR: 225547 Sponsored by: Spectra Logic Corp Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_008_neg.ksh Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile Mon Jan 29 23:20:29 2018 (r328569) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile Mon Jan 29 23:36:05 2018 (r328570) @@ -27,6 +27,7 @@ ${PACKAGE}FILES+= zfsd_hotspare_004_pos.ksh ${PACKAGE}FILES+= zfsd_hotspare_005_pos.ksh ${PACKAGE}FILES+= zfsd_hotspare_006_pos.ksh ${PACKAGE}FILES+= zfsd_hotspare_007_pos.ksh +${PACKAGE}FILES+= zfsd_hotspare_008_neg.ksh ${PACKAGE}FILES+= zfsd_import_001_pos.ksh ${PACKAGE}FILES+= zfsd_replace_001_pos.ksh ${PACKAGE}FILES+= zfsd_replace_002_pos.ksh Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_008_neg.ksh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_008_neg.ksh Mon Jan 29 23:36:05 2018 (r328570) @@ -0,0 +1,81 @@ +#!/usr/local/bin/ksh93 -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2017 Spectra Logic. All rights reserved. +# Use is subject to license terms. + +. $STF_SUITE/tests/hotspare/hotspare.kshlib + +verify_runnable "global" + +function cleanup +{ + $ZPOOL status $TESTPOOL + if poolexists $TESTPOOL ; then + destroy_pool $TESTPOOL + fi + + partition_cleanup +} + +function verify_assertion # damage_type +{ + typeset mntp=$(get_prop mountpoint $TESTPOOL) + + # Write some data to the pool so the replacing vdev doesn't complete + # immediately. + $TIMEOUT 60s $DD if=/dev/zero of=$mntp/zerofile bs=131072 + + log_must $ZINJECT -d $FAULT_DISK -A fault $TESTPOOL + log_must check_state $TESTPOOL $FAULT_DISK FAULTED + + # Replace the failed device. Realistically, the new device would have + # the same physical path as the failed one, but it doesn't matter for + # our purposes. + log_must $ZPOOL replace $TESTPOOL $FAULT_DISK $REPLACEMENT_DISK + + # Add the spare, and check that it does not activate + log_must $ZPOOL add $TESTPOOL spare $SDEV + + # Wait a few seconds before verifying the state + $SLEEP 10 + log_must check_state $TESTPOOL "$SDEV" "AVAIL" +} + +log_onexit cleanup + +log_assert "zfsd will not use newly added spares on replacing vdevs" + +ensure_zfsd_running + +typeset FAULT_DISK=$DISK0 +typeset REPLACEMENT_DISK=$DISK2 +typeset SDEV=$DISK3 +typeset POOLDEVS="$DISK0 $DISK1" +set -A MY_KEYWORDS "mirror" +for keyword in "${MY_KEYWORDS[@]}" ; do + log_must create_pool $TESTPOOL $keyword $POOLDEVS + verify_assertion + + destroy_pool "$TESTPOOL" +done Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Mon Jan 29 23:20:29 2018 (r328569) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Mon Jan 29 23:36:05 2018 (r328570) @@ -318,6 +318,37 @@ zfsd_hotspare_007_pos_cleanup() ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } +atf_test_case zfsd_hotspare_008_neg cleanup +zfsd_hotspare_008_neg_head() +{ + atf_set "descr" "zfsd will not use newly added spares on replacing vdevs" + atf_set "require.progs" zpool zfsd + atf_set "timeout" 3600 +} +zfsd_hotspare_008_neg_body() +{ + . $(atf_get_srcdir)/../../include/default.cfg + . $(atf_get_srcdir)/../hotspare/hotspare.kshlib + . $(atf_get_srcdir)/../hotspare/hotspare.cfg + + atf_expect_fail "PR 225547 zfsd shouldn't add a spare to a replacing vdev" + verify_disk_count "$DISKS" 4 + ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" + ksh93 $(atf_get_srcdir)/zfsd_hotspare_008_neg.ksh + if [[ $? != 0 ]]; then + save_artifacts + atf_fail "Testcase failed" + fi +} +zfsd_hotspare_008_neg_cleanup() +{ + . $(atf_get_srcdir)/../../include/default.cfg + . $(atf_get_srcdir)/../hotspare/hotspare.kshlib + . $(atf_get_srcdir)/../hotspare/hotspare.cfg + + ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" +} + atf_test_case zfsd_autoreplace_001_neg cleanup zfsd_autoreplace_001_neg_head() { @@ -536,6 +567,7 @@ atf_init_test_cases() atf_add_test_case zfsd_hotspare_005_pos atf_add_test_case zfsd_hotspare_006_pos atf_add_test_case zfsd_hotspare_007_pos + atf_add_test_case zfsd_hotspare_008_neg atf_add_test_case zfsd_autoreplace_001_neg atf_add_test_case zfsd_autoreplace_002_pos atf_add_test_case zfsd_autoreplace_003_pos