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 https://opensource.org/licenses/CDDL-1.0. 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# Copyright (c) 2016, 2017 by Intel Corporation. All rights reserved. 23# Copyright (c) 2019 by Delphix. All rights reserved. 24# Portions Copyright 2021 iXsystems, Inc. 25# 26 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/fault/fault.cfg 29 30# 31# DESCRIPTION: 32# Testing Fault Management Agent ZED Logic - Automated Auto-Online Test. 33# Now with partitioned vdevs. 34# 35# STRATEGY: 36# 1. Partition a scsi_debug device for simulating removal 37# 2. Create a pool 38# 3. Offline disk 39# 4. ZED polls for an event change for online disk to be automatically 40# added back to the pool. 41# 42verify_runnable "both" 43 44function cleanup 45{ 46 poolexists ${TESTPOOL} && destroy_pool ${TESTPOOL} 47 unload_scsi_debug 48} 49 50log_assert "Testing automated auto-online FMA test with partitioned vdev" 51 52log_onexit cleanup 53 54load_scsi_debug ${SDSIZE} ${SDHOSTS} ${SDTGTS} ${SDLUNS} '512b' 55SDDEVICE=$(get_debug_device) 56zpool labelclear -f ${SDDEVICE} 57partition_disk ${SDSIZE} ${SDDEVICE} 1 58part=${SDDEVICE}1 59host=$(get_scsi_host ${SDDEVICE}) 60 61block_device_wait /dev/${part} 62log_must zpool create -f ${TESTPOOL} raidz1 ${part} ${DISKS} 63 64# Add some data to the pool 65log_must mkfile ${FSIZE} /${TESTPOOL}/data 66 67remove_disk ${SDDEVICE} 68check_state ${TESTPOOL} "" "degraded" || \ 69 log_fail "${TESTPOOL} is not degraded" 70 71# Clear zpool events 72log_must zpool events -c 73 74# Online disk 75insert_disk ${SDDEVICE} ${host} 76 77log_note "Delay for ZED auto-online" 78typeset -i timeout=0 79until is_pool_resilvered ${TESTPOOL}; do 80 if ((timeout++ == MAXTIMEOUT)); then 81 log_fail "Timeout occurred" 82 fi 83 sleep 1 84done 85log_note "Auto-online of ${SDDEVICE} is complete" 86 87# Validate auto-online was successful 88sleep 1 89check_state ${TESTPOOL} "" "online" || \ 90 log_fail "${TESTPOOL} is not back online" 91 92log_must zpool destroy ${TESTPOOL} 93 94log_pass "Auto-online with partitioned vdev test successful" 95