1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14 15# 16# Copyright (c) 2017 Open-E, Inc. All Rights Reserved. 17# 18 19. $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib 20 21# 22# DESCRIPTION: 23# Test if zpool reopen with pool name as argument works correctly. 24# 25# STRATEGY: 26# 1. Create a pool. 27# 2. Remove a disk. 28# 3. Reopen a pool and verify if removed disk is marked as unavailable. 29# 4. "Plug back" disk. 30# 5. Reopen a pool and verify if removed disk is marked online again. 31# 6. Check if reopen caused resilver start. 32# 33 34verify_runnable "global" 35 36function cleanup 37{ 38 # bring back removed disk online for further tests 39 insert_disk $REMOVED_DISK $scsi_host 40 poolexists $TESTPOOL && destroy_pool $TESTPOOL 41 clear_labels $REMOVED_DISK $DISK2 42} 43 44log_assert "Testing zpool reopen with no arguments" 45log_onexit cleanup 46 47set_removed_disk 48scsi_host=$(get_scsi_host $REMOVED_DISK) 49 50# 1. Create a pool. 51default_mirror_setup_noexit $REMOVED_DISK_ID $DISK2 52# 2. Remove a disk. 53remove_disk $REMOVED_DISK 54# 3. Reopen a pool and verify if removed disk is marked as unavailable. 55log_must zpool reopen $TESTPOOL 56log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "unavail" 57# Write some data to the pool 58log_must generate_random_file /$TESTPOOL/data $SMALL_FILE_SIZE 59sync_pool $TESTPOOL 60# 4. "Plug back" disk. 61insert_disk $REMOVED_DISK $scsi_host 62# 5. Reopen a pool and verify if removed disk is marked online again. 63log_must zpool reopen $TESTPOOL 64log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "online" 65# 6. Check if reopen caused resilver start. 66log_must wait_for_resilver_end $TESTPOOL $MAXTIMEOUT 67 68# clean up 69log_must zpool destroy $TESTPOOL 70clear_labels $REMOVED_DISK $DISK2 71 72log_pass "Zpool reopen with no arguments test passed" 73