xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_009_pos.ksh (revision df58e8b1506f241670be86a560fb6e8432043aee)
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, Intel Corporation.
17# Copyright (c) 2018, 2020 by Delphix. All rights reserved.
18#
19
20. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
21
22#
23# DESCRIPTION:
24#	Importing and exporting pool with special device succeeds.
25#
26claim="Import/export of pool with special device mirror succeeds."
27
28verify_runnable "global"
29
30log_assert $claim
31log_onexit cleanup
32
33log_must disk_setup
34
35typeset stype=""
36typeset sdisks=""
37typeset props=""
38
39for type in "" "mirror" "raidz" "draid"
40do
41	if [ "$type" = "mirror" ]; then
42		stype="mirror"
43		sdisks="${CLASS_DISK0} ${CLASS_DISK1} ${CLASS_DISK2}"
44		props="-o ashift=12"
45	elif [ "$type" = "raidz" ]; then
46		stype="mirror"
47		sdisks="${CLASS_DISK0} ${CLASS_DISK1}"
48	elif [ "$type" = "draid" ]; then
49		stype="raidz"
50		sdisks="${CLASS_DISK0} ${CLASS_DISK1} ${CLASS_DISK2}"
51	else
52		stype=""
53		sdisks="${CLASS_DISK0}"
54	fi
55
56	#
57	# 1/3 of the time add the special vdev after creating the pool
58	#
59	if [ $((RANDOM % 3)) -eq 0 ]; then
60		log_must zpool create ${props} $TESTPOOL $type $ZPOOL_DISKS
61		log_must zpool add ${props} $TESTPOOL special $stype $sdisks
62	else
63		log_must zpool create ${props} $TESTPOOL $type $ZPOOL_DISKS \
64		    special $stype $sdisks
65	fi
66
67	log_must zpool export $TESTPOOL
68	log_must zpool import -d $TEST_BASE_DIR -s $TESTPOOL
69	log_must display_status $TESTPOOL
70	log_must zpool destroy -f $TESTPOOL
71done
72
73log_pass $claim
74