]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_010_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / zpool_import_010_pos.ksh
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 http://www.opensolaris.org/os/licensing.
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
23 #
24 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
34
35 #
36 # DESCRIPTION:
37 #       'zpool -D -a' can import all the specified directories destroyed pools.
38 #
39 # STRATEGY:
40 #       1. Create a 5 ways mirror pool A with dev0/1/2/3/4, then destroy it.
41 #       2. Create a stripe pool B with dev1. Then destroy it.
42 #       3. Create a raidz2 pool C with dev2/3/4. Then destroy it.
43 #       4. Create a raidz pool D with dev3/4. Then destroy it.
44 #       5. Create a stripe pool E with dev4. Then destroy it.
45 #       6. Verify 'zpool import -D -a' recover all the pools.
46 #
47
48 verify_runnable "global"
49
50 function cleanup
51 {
52         typeset dt
53         for dt in $poolE $poolD $poolC $poolB $poolA; do
54                 destroy_pool $dt
55         done
56
57         log_must rm -rf $DEVICE_DIR/*
58         typeset i=0
59         while (( i < $MAX_NUM )); do
60                 log_must mkfile $FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i
61                 ((i += 1))
62         done
63 }
64
65 log_assert "'zpool -D -a' can import all the specified directories " \
66         "destroyed pools."
67 log_onexit cleanup
68
69 poolA=poolA.$$; poolB=poolB.$$; poolC=poolC.$$; poolD=poolD.$$; poolE=poolE.$$
70
71 log_must zpool create $poolA mirror $VDEV0 $VDEV1 $VDEV2 $VDEV3 $VDEV4
72 log_must zpool destroy $poolA
73
74 log_must zpool create $poolB $VDEV1
75 log_must zpool destroy $poolB
76
77 log_must zpool create $poolC raidz2 $VDEV2 $VDEV3 $VDEV4
78 log_must zpool destroy $poolC
79
80 log_must zpool create $poolD raidz $VDEV3 $VDEV4
81 log_must zpool destroy $poolD
82
83 log_must zpool create $poolE $VDEV4
84 log_must zpool destroy $poolE
85
86 log_must zpool import -d $DEVICE_DIR -D -f -a
87
88 for dt in $poolA $poolB $poolC $poolD $poolE; do
89         log_must datasetexists $dt
90 done
91
92 log_pass "'zpool -D -a' test passed."