1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg 19 20# 21# DESCRIPTION: 22# 'zpool split' should use the provided devices to split the pool 23# 24# STRATEGY: 25# 1. Create various (mirror-only) pools 26# 2. Verify 'zpool split' can provide a list of devices to be included in the 27# new pool. At most one disk from each mirror can be specified. 28# 29 30verify_runnable "both" 31 32function cleanup 33{ 34 destroy_pool $TESTPOOL 35 destroy_pool $TESTPOOL2 36 rm -fd $FILEDEV_PREFIX* $altroot 37} 38 39function setup_mirror # <conf> 40{ 41 for filedev in "${fd[@]}"; do 42 truncate -s $SPA_MINDEVSIZE "$filedev" 43 done 44 log_must zpool create -f $TESTPOOL $conf 45} 46 47log_assert "'zpool split' should use the provided devices to split the pool" 48log_onexit cleanup 49 50typeset altroot="$TESTDIR/altroot-$TESTPOOL2" 51typeset FILEDEV_PREFIX="$TEST_BASE_DIR/filedev" 52typeset -A fd 53fd[01]="$FILEDEV_PREFIX-01" 54fd[02]="$FILEDEV_PREFIX-02" 55fd[03]="$FILEDEV_PREFIX-03" 56fd[11]="$FILEDEV_PREFIX-11" 57fd[12]="$FILEDEV_PREFIX-12" 58fd[13]="$FILEDEV_PREFIX-13" 59 60# Base pool configurations 61typeset poolconfs=("mirror ${fd[01]} ${fd[02]}" 62 "mirror ${fd[01]} ${fd[02]} ${fd[03]}" 63 "mirror ${fd[01]} ${fd[02]} mirror ${fd[11]} ${fd[12]}" 64 "mirror ${fd[01]} ${fd[02]} ${fd[03]} mirror ${fd[11]} ${fd[12]}" 65 "mirror ${fd[01]} ${fd[02]} mirror ${fd[11]} ${fd[12]} ${fd[13]}" 66 "mirror ${fd[01]} ${fd[02]} ${fd[03]} mirror ${fd[11]} ${fd[12]} ${fd[13]}" 67) 68# "good" device specifications 69typeset gooddevs=("${fd[01]}" 70 "${fd[02]}" 71 "${fd[02]} ${fd[11]}" 72 "${fd[12]}" 73 "${fd[02]}" 74 "${fd[03]} ${fd[12]}" 75) 76# "bad" device specifications 77typeset baddevs=("${fd[01]} ${fd[02]}" 78 "${fd[02]} ${fd[03]}" 79 "${fd[02]} baddev" 80 "baddev ${fd[11]}" 81 "${fd[11]} ${fd[12]} ${fd[13]}" 82 "${fd[01]} ${fd[02]} ${fd[13]}" 83) 84 85typeset -i i=0; 86while [ $i -lt "${#poolconfs[@]}" ] 87do 88 typeset conf=${poolconfs[$i]} 89 setup_mirror $conf 90 log_mustnot zpool split $TESTPOOL $TESTPOOL2 ${baddevs[$i]} 91 log_must zpool split -R $altroot $TESTPOOL $TESTPOOL2 ${gooddevs[$i]} 92 # Verify "good" devices ended up in the new pool 93 log_must poolexists $TESTPOOL2 94 for filedev in ${gooddevs[$i]}; do 95 log_must check_vdev_state $TESTPOOL2 $filedev "ONLINE" 96 done 97 cleanup 98 ((i = i + 1)) 99done 100 101log_pass "'zpool split' can use the provided devices to split the pool" 102