1#! /usr/bin/ksh -p 2# 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright 2016 Nexenta Systems, Inc. 16# 17 18. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg 19 20# DESCRIPTION: 21# Check that zpool labelclear will refuse to clear the label 22# on ACTIVE vdevs of exported pool without -f, and will succeeded with -f. 23# 24# STRATEGY: 25# 1. Create a pool with log device. 26# 2. Export the pool. 27# 3. Check that zpool labelclear returns non-zero when trying to 28# clear the label on ACTIVE vdevs, and succeeds with -f. 29# 4. Add auxilary vdevs (cache/spare). 30# 5. Check that zpool labelclear succeeds on auxilary vdevs of 31# exported pool. 32 33verify_runnable "global" 34 35function cleanup 36{ 37 poolexists $TESTPOOL && destroy_pool $TESTPOOL 38} 39 40log_onexit cleanup 41log_assert "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \ 42 "succeed with -f" 43 44for vdevtype in "" "cache" "spare"; do 45 # Create simple pool, skip any mounts 46 log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2 47 # Add auxilary vdevs (cache/spare) 48 if [[ -n $vdevtype ]]; then 49 log_must zpool add $TESTPOOL $vdevtype $disk3 50 fi 51 # Export the pool 52 log_must zpool export $TESTPOOL 53 54 # Check that labelclear will fail without -f 55 log_mustnot $LABELCLEAR $disk1 56 log_must $LABELREAD $disk1 57 log_mustnot $LABELCLEAR $disk2 58 log_must $LABELREAD $disk2 59 60 # Check that labelclear will succeed with -f 61 log_must $LABELCLEAR -f $disk1 62 log_mustnot $LABELREAD $disk1 63 log_must $LABELCLEAR -f $disk2 64 log_mustnot $LABELREAD $disk2 65 66 # Check that labelclear on auxilary vdevs will succeed 67 if [[ -n $vdevtype ]]; then 68 log_must $LABELCLEAR $disk3 69 log_mustnot $LABELREAD $disk3 70 fi 71done 72 73log_pass "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \ 74 "succeed with -f" 75