]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_005_pos.ksh
Add ashift validation when adding devices to a pool
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_add / zpool_add_005_pos.ksh
CommitLineData
6bb24f4d
BB
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
1d3ba0bf 10# or https://opensource.org/licenses/CDDL-1.0.
6bb24f4d
BB
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 2009 Sun Microsystems, Inc. All rights reserved.
25# Use is subject to license terms.
26#
2171eb71
JWK
27
28#
c1d9abf9 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
2171eb71
JWK
30#
31
6bb24f4d
BB
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.kshlib
34
35#
36# DESCRIPTION:
37# 'zpool add' should return fail if
38# 1. vdev is part of an active pool
39# 2. vdev is currently mounted
40# 3. vdev is in /etc/vfstab
41# 3. vdev is specified as the dedicated dump device
42#
43# STRATEGY:
44# 1. Create case scenarios
45# 2. For each scenario, try to add the device to the pool
46# 3. Verify the add operation get failed
47#
48
49verify_runnable "global"
50
51function cleanup
52{
f0410e98
RM
53 poolexists $TESTPOOL && destroy_pool $TESTPOOL
54 poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
6bb24f4d
BB
55
56 if [[ -n $saved_dump_dev ]]; then
d7164b27 57 log_must eval "dumpadm -u -d $saved_dump_dev > /dev/null"
6bb24f4d 58 fi
6bb24f4d
BB
59}
60
61log_assert "'zpool add' should fail with inapplicable scenarios."
62
63log_onexit cleanup
64
65mnttab_dev=$(find_mnttab_dev)
66vfstab_dev=$(find_vfstab_dev)
67saved_dump_dev=$(save_dump_dev)
f0410e98 68dump_dev=$DISK2
6bb24f4d 69
f0410e98
RM
70create_pool $TESTPOOL $DISK0
71log_must poolexists $TESTPOOL
6bb24f4d 72
f0410e98
RM
73create_pool $TESTPOOL1 $DISK1
74log_must poolexists $TESTPOOL1
6bb24f4d 75
2171eb71 76unset NOINUSE_CHECK
f0410e98 77log_mustnot zpool add -f $TESTPOOL $DISK1
b1e46f86 78log_mustnot zpool add --allow-in-use $TESTPOOL $DISK1
f0410e98 79log_mustnot zpool add -f $TESTPOOL $mnttab_dev
b1e46f86 80log_mustnot zpool add --allow-in-use $TESTPOOL $mnttab_dev
47770d30 81if is_linux; then
f0410e98 82 log_mustnot zpool add $TESTPOOL $vfstab_dev
47770d30 83else
f0410e98 84 log_mustnot zpool add -f $TESTPOOL $vfstab_dev
47770d30 85fi
6bb24f4d 86
d7164b27 87if is_illumos; then
7839c4b5 88 log_must eval "new_fs ${DEV_DSKDIR}/$dump_dev > /dev/null 2>&1"
d7164b27 89 log_must eval "dumpadm -u -d ${DEV_DSKDIR}/$dump_dev > /dev/null"
f0410e98 90 log_mustnot zpool add -f $TESTPOOL $dump_dev
8c54ddd3 91fi
6bb24f4d
BB
92
93log_pass "'zpool add' should fail with inapplicable scenarios."