Date: Mon, 29 Jan 2018 23:20:29 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r328569 - in projects/zfsd/head/tests/sys/cddl/zfs: include tests/cli_root/zpool_add Message-ID: <201801292320.w0TNKTmO050240@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Mon Jan 29 23:20:29 2018 New Revision: 328569 URL: https://svnweb.freebsd.org/changeset/base/328569 Log: Add a regression test for PR 225546 If a pool contains a replacing vdev with a spare child, then any "zpool add" command will fail. It doesn't matter whether you're adding a regular vdev, log, cache, or spare vdev. The bug is in get_replication in zpool_vdev.c in the zpool command. tests/sys/cddl/zfs/tests/cli_root/zpool_add/Makefile tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_pos.ksh tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh Add a test case that creates a pool with replacing vdev that has a spare child, then attempts to add another spare. tests/sys/cddl/zfs/include/commands.txt Add an alias for /usr/bin/timeout PR: 225546 Sponsored by: Spectra Logic Corp Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_pos.ksh Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/commands.txt projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/Makefile projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/commands.txt ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/commands.txt Mon Jan 29 22:50:44 2018 (r328568) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/commands.txt Mon Jan 29 23:20:29 2018 (r328569) @@ -151,6 +151,7 @@ /bin/sync /usr/bin/tar /usr/bin/tail +/usr/bin/timeout /usr/bin/touch /usr/bin/tr /usr/bin/true Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/Makefile ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/Makefile Mon Jan 29 22:50:44 2018 (r328568) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/Makefile Mon Jan 29 23:20:29 2018 (r328569) @@ -8,18 +8,19 @@ FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= zpool_add_test -${PACKAGE}FILES+= zpool_add_002_pos.ksh -${PACKAGE}FILES+= zpool_add_006_pos.ksh -${PACKAGE}FILES+= zpool_add_007_neg.ksh ${PACKAGE}FILES+= cleanup.ksh -${PACKAGE}FILES+= zpool_add_003_pos.ksh +${PACKAGE}FILES+= setup.ksh ${PACKAGE}FILES+= zpool_add.cfg +${PACKAGE}FILES+= zpool_add.kshlib ${PACKAGE}FILES+= zpool_add_001_pos.ksh +${PACKAGE}FILES+= zpool_add_002_pos.ksh +${PACKAGE}FILES+= zpool_add_003_pos.ksh +${PACKAGE}FILES+= zpool_add_004_pos.ksh ${PACKAGE}FILES+= zpool_add_005_pos.ksh +${PACKAGE}FILES+= zpool_add_006_pos.ksh +${PACKAGE}FILES+= zpool_add_007_neg.ksh ${PACKAGE}FILES+= zpool_add_008_neg.ksh -${PACKAGE}FILES+= setup.ksh -${PACKAGE}FILES+= zpool_add_004_pos.ksh -${PACKAGE}FILES+= zpool_add.kshlib ${PACKAGE}FILES+= zpool_add_009_neg.ksh +${PACKAGE}FILES+= zpool_add_010_pos.ksh .include <bsd.test.mk> Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_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_add/zpool_add_010_pos.ksh Mon Jan 29 23:20:29 2018 (r328569) @@ -0,0 +1,54 @@ +#!/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 Corp. All rights reserved. +# Use is subject to license terms. +# +. $STF_SUITE/include/libtest.kshlib +. $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib + +verify_runnable "global" + +function cleanup +{ + poolexists $TESTPOOL && \ + destroy_pool $TESTPOOL + + partition_cleanup +} + +log_assert "'zpool add' can add devices, even if a replacing vdev with a spare child is present" + +log_onexit cleanup + +create_pool $TESTPOOL mirror ${DISK0} ${DISK1} +# A replacing vdev will automatically detach the older member when resilvering +# is complete. We don't want that to happen during this test, so write some +# data just to slow down resilvering. +$TIMEOUT 60s $DD if=/dev/zero of=/$TESTPOOL/zerofile bs=128k +log_must $ZPOOL replace $TESTPOOL ${DISK0} ${DISK2} +log_must $ZPOOL add $TESTPOOL spare ${DISK3} +log_must $ZPOOL replace $TESTPOOL ${DISK0} ${DISK3} +log_must $ZPOOL add $TESTPOOL spare ${DISK4} + +log_pass "'zpool add <pool> <vdev> ...' executes successfully, even when a replacing vdev with a spare child is present" Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh Mon Jan 29 22:50:44 2018 (r328568) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh Mon Jan 29 23:20:29 2018 (r328569) @@ -54,7 +54,7 @@ zpool_add_001_pos_cleanup() atf_test_case zpool_add_002_pos cleanup zpool_add_002_pos_head() { - atf_set "descr" "'zpool add -f <pool> <vdev> ...' can successfully adddevices to the pool in some cases." + atf_set "descr" "'zpool add -f <pool> <vdev> ...' can successfully add devices to the pool in some cases." atf_set "require.config" disks_are_physical atf_set "require.progs" zpool atf_set "timeout" 2400 @@ -81,7 +81,7 @@ zpool_add_002_pos_cleanup() atf_test_case zpool_add_003_pos cleanup zpool_add_003_pos_head() { - atf_set "descr" "'zpool add -n <pool> <vdev> ...' can display the configurationwithout actually adding devices to the pool." + atf_set "descr" "'zpool add -n <pool> <vdev> ...' can display the configuration without actually adding devices to the pool." atf_set "require.config" disks_are_physical atf_set "require.progs" zpool atf_set "timeout" 2400 @@ -267,7 +267,35 @@ zpool_add_009_neg_cleanup() ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } +# Regression test for PR 225546. "zpool add" asserts if the pool contains a +# replacing vdev with a spare child. +# Assertion failed: (nvlist_lookup_string(cnv, "path", &path) == 0), file /usr/home/alans/freebsd/head/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c, line 694. /usr/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_pos.ksh[54]: log_must[69]: log_pos: line 206: 27710: Abort(coredump) +atf_test_case zpool_add_010_pos cleanup +zpool_add_010_pos_head() +{ + atf_set "descr" "'zpool add' can add devices, even if a replacing vdev with a spare child is present" + atf_set "require.progs" zpool +} +zpool_add_010_pos_body() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + . $(atf_get_srcdir)/zpool_add.kshlib + . $(atf_get_srcdir)/zpool_add.cfg + atf_expect_fail "PR 225546 zpool add crashes in the presence of a replacing vdev with a spare child" + verify_disk_count "$DISKS" 5 + ksh93 $(atf_get_srcdir)/zpool_add_010_pos.ksh || atf_fail "Testcase failed" +} +zpool_add_010_pos_cleanup() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + . $(atf_get_srcdir)/zpool_add.kshlib + . $(atf_get_srcdir)/zpool_add.cfg + + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" +} + + atf_init_test_cases() { @@ -280,4 +308,5 @@ atf_init_test_cases() atf_add_test_case zpool_add_007_neg atf_add_test_case zpool_add_008_neg atf_add_test_case zpool_add_009_neg + atf_add_test_case zpool_add_010_pos }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801292320.w0TNKTmO050240>