1*6f793812SPavel Zakharov#!/usr/bin/ksh -p 2*6f793812SPavel Zakharov 3*6f793812SPavel Zakharov# 4*6f793812SPavel Zakharov# This file and its contents are supplied under the terms of the 5*6f793812SPavel Zakharov# Common Development and Distribution License ("CDDL"), version 1.0. 6*6f793812SPavel Zakharov# You may only use this file in accordance with the terms of version 7*6f793812SPavel Zakharov# 1.0 of the CDDL. 8*6f793812SPavel Zakharov# 9*6f793812SPavel Zakharov# A full copy of the text of the CDDL should have accompanied this 10*6f793812SPavel Zakharov# source. A copy of the CDDL is also available via the Internet at 11*6f793812SPavel Zakharov# http://www.illumos.org/license/CDDL. 12*6f793812SPavel Zakharov# 13*6f793812SPavel Zakharov 14*6f793812SPavel Zakharov# 15*6f793812SPavel Zakharov# Copyright (c) 2016 by Delphix. All rights reserved. 16*6f793812SPavel Zakharov# 17*6f793812SPavel Zakharov 18*6f793812SPavel Zakharov. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib 19*6f793812SPavel Zakharov 20*6f793812SPavel Zakharov# 21*6f793812SPavel Zakharov# DESCRIPTION: 22*6f793812SPavel Zakharov# A pool should be importable using an outdated cachefile that misses a 23*6f793812SPavel Zakharov# mirror that was attached. 24*6f793812SPavel Zakharov# 25*6f793812SPavel Zakharov# STRATEGY: 26*6f793812SPavel Zakharov# 1. Create a pool with some devices and an alternate cachefile. 27*6f793812SPavel Zakharov# 2. Backup the cachefile. 28*6f793812SPavel Zakharov# 3. Attach a mirror to one of the devices in the pool. 29*6f793812SPavel Zakharov# 4. Export the pool. 30*6f793812SPavel Zakharov# 5. Verify that we can import the pool using the backed-up cachefile. 31*6f793812SPavel Zakharov# 32*6f793812SPavel Zakharov 33*6f793812SPavel Zakharovverify_runnable "global" 34*6f793812SPavel Zakharov 35*6f793812SPavel Zakharovlog_onexit cleanup 36*6f793812SPavel Zakharov 37*6f793812SPavel Zakharovfunction test_attach_vdev 38*6f793812SPavel Zakharov{ 39*6f793812SPavel Zakharov typeset poolcreate="$1" 40*6f793812SPavel Zakharov typeset attachto="$2" 41*6f793812SPavel Zakharov typeset attachvdev="$3" 42*6f793812SPavel Zakharov typeset poolcheck="$4" 43*6f793812SPavel Zakharov 44*6f793812SPavel Zakharov log_note "$0: pool '$poolcreate', attach $attachvdev to $attachto." 45*6f793812SPavel Zakharov 46*6f793812SPavel Zakharov log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $poolcreate 47*6f793812SPavel Zakharov 48*6f793812SPavel Zakharov log_must cp $CPATH $CPATHBKP 49*6f793812SPavel Zakharov 50*6f793812SPavel Zakharov log_must zpool attach $TESTPOOL1 $attachto $attachvdev 51*6f793812SPavel Zakharov 52*6f793812SPavel Zakharov log_must zpool export $TESTPOOL1 53*6f793812SPavel Zakharov 54*6f793812SPavel Zakharov log_must zpool import -c $CPATHBKP $TESTPOOL1 55*6f793812SPavel Zakharov log_must check_pool_config $TESTPOOL1 "$poolcheck" 56*6f793812SPavel Zakharov 57*6f793812SPavel Zakharov # Cleanup 58*6f793812SPavel Zakharov log_must zpool destroy $TESTPOOL1 59*6f793812SPavel Zakharov log_must rm -f $CPATH $CPATHBKP 60*6f793812SPavel Zakharov 61*6f793812SPavel Zakharov log_note "" 62*6f793812SPavel Zakharov} 63*6f793812SPavel Zakharov 64*6f793812SPavel Zakharovtest_attach_vdev "$VDEV0" "$VDEV0" "$VDEV4" "mirror $VDEV0 $VDEV4" 65*6f793812SPavel Zakharovtest_attach_vdev "$VDEV0 $VDEV1" "$VDEV1" "$VDEV4" \ 66*6f793812SPavel Zakharov "$VDEV0 mirror $VDEV1 $VDEV4" 67*6f793812SPavel Zakharovtest_attach_vdev "mirror $VDEV0 $VDEV1" "$VDEV0" "$VDEV4" \ 68*6f793812SPavel Zakharov "mirror $VDEV0 $VDEV1 $VDEV4" 69*6f793812SPavel Zakharovtest_attach_vdev "$VDEV0 log $VDEV1" "$VDEV1" "$VDEV4" \ 70*6f793812SPavel Zakharov "$VDEV0 log mirror $VDEV1 $VDEV4" 71*6f793812SPavel Zakharov 72*6f793812SPavel Zakharovlog_pass "zpool import -c cachefile_unaware_of_attach passed." 73