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 sync_pool $TESTPOOL 79 log_must zpool offline $TESTPOOL $disk 80 check_state $TESTPOOL $disk "offline" 81 if [[ $? != 0 ]]; then 82 log_fail "$disk of $TESTPOOL did not match offline state" 83 fi 84 85 log_must zpool online ${args[$i]} $TESTPOOL $disk 86 check_state $TESTPOOL $disk "online" 87 if [[ $? != 0 ]]; then 88 log_fail "$disk of $TESTPOOL did not match online state" 89 fi 90 91 (( i = i + 1 )) 92 done 93done 94 95log_note "Issuing repeated 'zpool online' commands succeeds." 96 97typeset -i iters=20 98typeset -i index=0 99 100for disk in $DISKLIST; do 101 i=0 102 while [[ $i -lt $iters ]]; do 103 index=`expr $RANDOM % ${#args[*]}` 104 log_must zpool online ${args[$index]} $TESTPOOL $disk 105 check_state $TESTPOOL $disk "online" 106 if [[ $? != 0 ]]; then 107 log_fail "$disk of $TESTPOOL did not match online state" 108 fi 109 110 (( i = i + 1 )) 111 done 112done 113 114log_pass "'zpool online' with correct options succeeded" 115