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