1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33 34# 35# DESCRIPTION: 36# Executing 'zpool online' with valid parameters succeeds. 37# 38# STRATEGY: 39# 1. Create an array of correctly formed 'zpool online' options 40# 2. Execute each element of the array. 41# 3. Verify use of each option is successful. 42# 43 44verify_runnable "global" 45 46DISKLIST=$(get_disklist $TESTPOOL) 47 48set -A args "" 49 50function cleanup 51{ 52 # 53 # Ensure we don't leave disks in temporary online state (-t) 54 # 55 for disk in $DISKLIST; do 56 log_must zpool online $TESTPOOL $disk 57 check_state $TESTPOOL $disk "online" 58 if [[ $? != 0 ]]; then 59 log_fail "Unable to online $disk" 60 fi 61 62 done 63} 64 65log_assert "Executing 'zpool online' with correct options succeeds" 66 67log_onexit cleanup 68 69if [[ -z $DISKLIST ]]; then 70 log_fail "DISKLIST is empty." 71fi 72 73typeset -i i=0 74 75for disk in $DISKLIST; do 76 i=0 77 while [[ $i -lt ${#args[*]} ]]; do 78 log_must zpool offline $TESTPOOL $disk 79 check_state $TESTPOOL $disk "offline" 80 if [[ $? != 0 ]]; then 81 log_fail "$disk of $TESTPOOL did not match offline state" 82 fi 83 84 log_must zpool online ${args[$i]} $TESTPOOL $disk 85 check_state $TESTPOOL $disk "online" 86 if [[ $? != 0 ]]; then 87 log_fail "$disk of $TESTPOOL did not match online state" 88 fi 89 90 (( i = i + 1 )) 91 done 92done 93 94log_note "Issuing repeated 'zpool online' commands succeeds." 95 96typeset -i iters=20 97typeset -i index=0 98 99for disk in $DISKLIST; do 100 i=0 101 while [[ $i -lt $iters ]]; do 102 index=`expr $RANDOM % ${#args[*]}` 103 log_must zpool online ${args[$index]} $TESTPOOL $disk 104 check_state $TESTPOOL $disk "online" 105 if [[ $? != 0 ]]; then 106 log_fail "$disk of $TESTPOOL did not match online state" 107 fi 108 109 (( i = i + 1 )) 110 done 111done 112 113log_pass "'zpool online' with correct options succeeded" 114