bootfs_006_pos.ksh revision 4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c
2N/A#!/usr/bin/ksh -p
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A
2N/A#
2N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A# Use is subject to license terms.
2N/A#
2N/A
2N/A#
2N/A# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
2N/A#
2N/A
2N/A. $STF_SUITE/include/libtest.shlib
2N/A
2N/A#
2N/A# DESCRIPTION:
2N/A#
2N/A# Pools of correct vdev types accept boot property
2N/A#
2N/A# STRATEGY:
2N/A# 1. create pools of each vdev type (raid, raidz, raidz2, mirror + hotspares)
2N/A# 2. verify we can set bootfs on each pool type according to design
2N/A#
2N/A
2N/Averify_runnable "global"
2N/A
2N/A
2N/A$ZPOOL set 2>&1 | $GREP bootfs > /dev/null
2N/Aif [ $? -ne 0 ]
2N/Athen
2N/A log_unsupported "bootfs pool property not supported on this release."
2N/Afi
2N/A
2N/AVDEV1=/bootfs_006_pos_a.$$.dat
2N/AVDEV2=/bootfs_006_pos_b.$$.dat
2N/AVDEV3=/bootfs_006_pos_c.$$.dat
2N/AVDEV4=/bootfs_006_pos_d.$$.dat
2N/A
2N/Afunction verify_bootfs { # $POOL
2N/A POOL=$1
2N/A log_must $ZFS create $POOL/$TESTFS
2N/A
2N/A log_must $ZPOOL set bootfs=$POOL/$TESTFS $POOL
2N/A VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
2N/A if [ $VAL != "$POOL/$TESTFS" ]
2N/A then
2N/A log_must $ZPOOL status -v $POOL
2N/A log_fail \
2N/A "set/get failed on $POOL - expected $VAL == $POOL/$TESTFS"
2N/A fi
2N/A log_must $ZPOOL destroy $POOL
2N/A}
2N/A
2N/Afunction verify_no_bootfs { # $POOL
2N/A POOL=$1
2N/A log_must $ZFS create $POOL/$TESTFS
2N/A log_mustnot $ZPOOL set bootfs=$POOL/$TESTFS $POOL
2N/A VAL=$($ZPOOL get bootfs $POOL | $TAIL -1 | $AWK '{print $3}' )
2N/A if [ $VAL == "$POOL/$TESTFS" ]
2N/A then
2N/A log_must $ZPOOL status -v $POOL
2N/A log_fail "set/get unexpectedly failed $VAL != $POOL/$TESTFS"
2N/A fi
2N/A log_must $ZPOOL destroy $POOL
2N/A}
2N/A
2N/Afunction cleanup {
2N/A if poolexists $TESTPOOL
2N/A then
2N/A log_must $ZPOOL destroy $TESTPOOL
2N/A fi
2N/A log_must $RM $VDEV1 $VDEV2 $VDEV3 $VDEV4
2N/A}
2N/A
2N/Alog_assert "Pools of correct vdev types accept boot property"
2N/A
2N/A
2N/A
2N/Alog_onexit cleanup
2N/Alog_must $MKFILE $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3 $VDEV4
2N/A
2N/A
2N/A## the following configurations are supported bootable pools
2N/A
2N/A# normal
2N/Alog_must $ZPOOL create $TESTPOOL $VDEV1
2N/Averify_bootfs $TESTPOOL
2N/A
2N/A# normal + hotspare
2N/Alog_must $ZPOOL create $TESTPOOL $VDEV1 spare $VDEV2
2N/Averify_bootfs $TESTPOOL
2N/A
2N/A# mirror
2N/Alog_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2
2N/Averify_bootfs $TESTPOOL
2N/A
2N/A# mirror + hotspare
2N/Alog_must $ZPOOL create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3
2N/Averify_bootfs $TESTPOOL
2N/A
2N/A## the following configurations are not supported as bootable pools
2N/A
2N/A# stripe
2N/Alog_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/A# stripe + hotspare
2N/Alog_must $ZPOOL create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/A# raidz
2N/Alog_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/A# raidz + hotspare
2N/Alog_must $ZPOOL create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/A# raidz2
2N/Alog_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/A# raidz2 + hotspare
2N/Alog_must $ZPOOL create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4
2N/Averify_no_bootfs $TESTPOOL
2N/A
2N/Alog_pass "Pools of correct vdev types accept boot property"
2N/A