15cabbc6bSPrashanth Sreenivasa#! /bin/ksh -p
25cabbc6bSPrashanth Sreenivasa#
35cabbc6bSPrashanth Sreenivasa# CDDL HEADER START
45cabbc6bSPrashanth Sreenivasa#
55cabbc6bSPrashanth Sreenivasa# This file and its contents are supplied under the terms of the
65cabbc6bSPrashanth Sreenivasa# Common Development and Distribution License ("CDDL"), version 1.0.
75cabbc6bSPrashanth Sreenivasa# You may only use this file in accordance with the terms of version
85cabbc6bSPrashanth Sreenivasa# 1.0 of the CDDL.
95cabbc6bSPrashanth Sreenivasa#
105cabbc6bSPrashanth Sreenivasa# A full copy of the text of the CDDL should have accompanied this
115cabbc6bSPrashanth Sreenivasa# source.  A copy of the CDDL is also available via the Internet at
125cabbc6bSPrashanth Sreenivasa# http://www.illumos.org/license/CDDL.
135cabbc6bSPrashanth Sreenivasa#
145cabbc6bSPrashanth Sreenivasa# CDDL HEADER END
155cabbc6bSPrashanth Sreenivasa#
165cabbc6bSPrashanth Sreenivasa
175cabbc6bSPrashanth Sreenivasa#
18d8cfd210SPrashanth Sreenivasa# Copyright (c) 2014, 2018 by Delphix. All rights reserved.
195cabbc6bSPrashanth Sreenivasa#
205cabbc6bSPrashanth Sreenivasa
215cabbc6bSPrashanth Sreenivasa. $STF_SUITE/include/libtest.shlib
225cabbc6bSPrashanth Sreenivasa. $STF_SUITE/tests/functional/removal/removal.kshlib
235cabbc6bSPrashanth Sreenivasa
24*8ac4d283SToomas SoomeTMPDIR=${TMPDIR:-$TEST_BASE_DIR}
255cabbc6bSPrashanth Sreenivasalog_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk1
265cabbc6bSPrashanth Sreenivasalog_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk2
275cabbc6bSPrashanth Sreenivasalog_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk3
28d8cfd210SPrashanth SreenivasaDISKS="$TMPDIR/dsk1 $TMPDIR/dsk2 $TMPDIR/dsk3"
29d8cfd210SPrashanth SreenivasaVDEVS="$TMPDIR/dsk1 mirror $TMPDIR/dsk2 $TMPDIR/dsk3"
305cabbc6bSPrashanth Sreenivasa
315cabbc6bSPrashanth Sreenivasafunction cleanup
325cabbc6bSPrashanth Sreenivasa{
335cabbc6bSPrashanth Sreenivasa	default_cleanup_noexit
345cabbc6bSPrashanth Sreenivasa	log_must rm -f $DISKS
355cabbc6bSPrashanth Sreenivasa}
365cabbc6bSPrashanth Sreenivasa
37d8cfd210SPrashanth Sreenivasalog_must default_setup_noexit "$VDEVS"
385cabbc6bSPrashanth Sreenivasalog_onexit cleanup
395cabbc6bSPrashanth Sreenivasa
405cabbc6bSPrashanth Sreenivasa# Attempt to remove the non mirrored disk.
415cabbc6bSPrashanth Sreenivasalog_must zpool remove $TESTPOOL $TMPDIR/dsk1
42d8cfd210SPrashanth Sreenivasalog_must wait_for_removal $TESTPOOL
435cabbc6bSPrashanth Sreenivasa
445cabbc6bSPrashanth Sreenivasa# Attempt to remove one of the disks in the mirror.
455cabbc6bSPrashanth Sreenivasalog_mustnot zpool remove $TESTPOOL $TMPDIR/dsk2
465cabbc6bSPrashanth Sreenivasa
475cabbc6bSPrashanth Sreenivasa# Add back the first disk.
485cabbc6bSPrashanth Sreenivasalog_must zpool add $TESTPOOL $TMPDIR/dsk1
495cabbc6bSPrashanth Sreenivasa
505cabbc6bSPrashanth Sreenivasa# Now attempt to remove the mirror.
515cabbc6bSPrashanth Sreenivasalog_must zpool remove $TESTPOOL mirror-1
525cabbc6bSPrashanth Sreenivasa
535cabbc6bSPrashanth Sreenivasalog_pass "Removal will succeed for top level vdev(s)."
54