5767 fix several problems with zfs test suite
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / online_offline / online_offline_003_neg.ksh
blob95d423c73e8d931f71dee7368a7fca548e2f05ef
1 #!/usr/bin/ksh -p
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2014 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
35 # DESCRIPTION:
36 # Offlining disks in a non-redundant pool should fail.
38 # STRATEGY:
39 # 1. Create a multidisk stripe and start some random I/O
40 # 2. zpool offline should fail on each disk.
43 verify_runnable "global"
45 function cleanup
47 if poolexists $TESTPOOL1; then
48 destroy_pool $TESTPOOL1
51 $KILL $killpid >/dev/null 2>&1
52 [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
55 log_assert "Offlining disks in a non-redundant pool should fail."
57 log_onexit cleanup
59 specials_list=""
60 for i in 0 1 2; do
61 $MKFILE 64m $TESTDIR/$TESTFILE1.$i
62 specials_list="$specials_list $TESTDIR/$TESTFILE1.$i"
63 done
64 disk=($specials_list)
66 create_pool $TESTPOOL1 $specials_list
67 log_must $ZFS create $TESTPOOL1/$TESTFS1
68 log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1
70 $FILE_TRUNC -f $((64 * 1024 * 1024)) -b 8192 -c 0 -r $TESTDIR/$TESTFILE1 &
71 typeset killpid="$! "
73 for i in 0 1 2; do
74 log_mustnot $ZPOOL offline $TESTPOOL1 ${disk[$i]}
75 check_state $TESTPOOL1 ${disk[$i]} "online"
76 done
78 log_must $KILL $killpid
79 $SYNC
81 log_pass