-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'zpool split' coverage to the ZFS Test Suite
This change adds five new tests to the ZTS: * zpool_split_cliargs: verify command line options and arguments * zpool_split_devices: verify zpool split accepts a device list * zpool_split_encryption: verify zpool can split encrypted pools * zpool_split_props: verify zpool split can set property values * zpool_split_vdevs: verify vdev layout when splitting the pool Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7409
- Loading branch information
1 parent
8111eb4
commit 7fab636
Showing
12 changed files
with
529 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ SUBDIRS = \ | |
zpool_replace \ | ||
zpool_scrub \ | ||
zpool_set \ | ||
zpool_split \ | ||
zpool_status \ | ||
zpool_sync \ | ||
zpool_upgrade |
12 changes: 12 additions & 0 deletions
12
tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile.am
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include $(top_srcdir)/config/Rules.am | ||
|
||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_split | ||
|
||
dist_pkgdata_SCRIPTS = \ | ||
cleanup.ksh \ | ||
setup.ksh \ | ||
zpool_split_cliargs.ksh \ | ||
zpool_split_devices.ksh \ | ||
zpool_split_encryption.ksh \ | ||
zpool_split_props.ksh \ | ||
zpool_split_vdevs.ksh |
19 changes: 19 additions & 0 deletions
19
tests/zfs-tests/tests/functional/cli_root/zpool_split/cleanup.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
default_cleanup |
17 changes: 17 additions & 0 deletions
17
tests/zfs-tests/tests/functional/cli_root/zpool_split/setup.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib |
79 changes: 79 additions & 0 deletions
79
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_cliargs.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# 'zpool split' should only work with supported options and parameters. | ||
# | ||
# STRATEGY: | ||
# 1. Verify every supported option is accepted | ||
# 2. Verify other unsupported options raise an error | ||
# 3. Verify we cannot split a pool if the destination already exists | ||
# | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
destroy_pool $TESTPOOL | ||
destroy_pool $TESTPOOL2 | ||
rm -f $DEVICE1 $DEVICE2 $DEVICE3 | ||
} | ||
|
||
function setup_mirror | ||
{ | ||
truncate -s $SPA_MINDEVSIZE $DEVICE1 | ||
truncate -s $SPA_MINDEVSIZE $DEVICE2 | ||
log_must zpool create -f $TESTPOOL mirror $DEVICE1 $DEVICE2 | ||
} | ||
|
||
log_assert "'zpool split' should only work with supported options and parameters." | ||
log_onexit cleanup | ||
|
||
typeset goodopts=( | ||
"" "-g" "-L" "-n" "-P" "-o comment=ok" "-o ro -R /mnt" "-l -R /mnt" "-gLnP") | ||
typeset badopts=( | ||
"-f" "-h" "-x" "-Pp" "-l" "-G" "-o" "-o ro" "-o comment" "-R" "-R dir" "=") | ||
|
||
DEVICE1="$TEST_BASE_DIR/device-1" | ||
DEVICE2="$TEST_BASE_DIR/device-2" | ||
DEVICE3="$TEST_BASE_DIR/device-3" | ||
|
||
# 1. Verify every supported option and/or parameter is accepted | ||
for opt in "${goodopts[@]}" | ||
do | ||
setup_mirror | ||
log_must zpool split $opt $TESTPOOL $TESTPOOL2 | ||
cleanup | ||
done | ||
|
||
# 2. Verify other unsupported options and/or parameters raise an error | ||
setup_mirror | ||
for opt in "${badopts[@]}" | ||
do | ||
log_mustnot zpool split $opt $TESTPOOL $TESTPOOL2 | ||
done | ||
cleanup | ||
|
||
# 3. Verify we cannot split a pool if the destination already exists | ||
setup_mirror | ||
truncate -s $SPA_MINDEVSIZE $DEVICE3 | ||
log_must zpool create $TESTPOOL2 $DEVICE3 | ||
log_mustnot zpool split $TESTPOOL $TESTPOOL2 | ||
|
||
log_pass "'zpool split' only works with supported options and parameters." |
100 changes: 100 additions & 0 deletions
100
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# 'zpool split' should use the provided devices to split the pool | ||
# | ||
# STRATEGY: | ||
# 1. Create various (mirror-only) pools | ||
# 2. Verify 'zpool split' can provide a list of devices to be included in the | ||
# new pool. At most one disk from each mirror can be specified. | ||
# | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
destroy_pool $TESTPOOL | ||
destroy_pool $TESTPOOL2 | ||
rm -f $FILEDEV_PREFIX* | ||
} | ||
|
||
function setup_mirror # <conf> | ||
{ | ||
for filedev in "${fd[@]}"; do | ||
truncate -s $SPA_MINDEVSIZE "$filedev" | ||
done | ||
log_must zpool create -f $TESTPOOL $conf | ||
} | ||
|
||
log_assert "'zpool split' should use the provided devices to split the pool" | ||
log_onexit cleanup | ||
|
||
typeset altroot="$TESTDIR/altroot-$TESTPOOL2" | ||
typeset FILEDEV_PREFIX="$TEST_BASE_DIR/filedev" | ||
typeset -A fd | ||
fd[01]="$FILEDEV_PREFIX-01" | ||
fd[02]="$FILEDEV_PREFIX-02" | ||
fd[03]="$FILEDEV_PREFIX-03" | ||
fd[11]="$FILEDEV_PREFIX-11" | ||
fd[12]="$FILEDEV_PREFIX-12" | ||
fd[13]="$FILEDEV_PREFIX-13" | ||
|
||
# Base pool configurations | ||
typeset poolconfs=("mirror ${fd[01]} ${fd[02]}" | ||
"mirror ${fd[01]} ${fd[02]} ${fd[03]}" | ||
"mirror ${fd[01]} ${fd[02]} mirror ${fd[11]} ${fd[12]}" | ||
"mirror ${fd[01]} ${fd[02]} ${fd[03]} mirror ${fd[11]} ${fd[12]}" | ||
"mirror ${fd[01]} ${fd[02]} mirror ${fd[11]} ${fd[12]} ${fd[13]}" | ||
"mirror ${fd[01]} ${fd[02]} ${fd[03]} mirror ${fd[11]} ${fd[12]} ${fd[13]}" | ||
) | ||
# "good" device specifications | ||
typeset gooddevs=("${fd[01]}" | ||
"${fd[02]}" | ||
"${fd[02]} ${fd[11]}" | ||
"${fd[12]}" | ||
"${fd[02]}" | ||
"${fd[03]} ${fd[12]}" | ||
) | ||
# "bad" device specifications | ||
typeset baddevs=("${fd[01]} ${fd[02]}" | ||
"${fd[02]} ${fd[03]}" | ||
"${fd[02]} baddev" | ||
"baddev ${fd[11]}" | ||
"${fd[11]} ${fd[12]} ${fd[13]}" | ||
"${fd[01]} ${fd[02]} ${fd[13]}" | ||
) | ||
|
||
typeset -i i=0; | ||
while [ $i -lt "${#poolconfs[@]}" ] | ||
do | ||
typeset conf=${poolconfs[$i]} | ||
setup_mirror $conf | ||
log_mustnot zpool split $TESTPOOL $TESTPOOL2 ${baddevs[$i]} | ||
log_must zpool split -R $altroot $TESTPOOL $TESTPOOL2 ${gooddevs[$i]} | ||
# Verify "good" devices ended up in the new pool | ||
log_must poolexists $TESTPOOL2 | ||
for filedev in ${gooddevs[$i]}; do | ||
log_must check_vdev_state $TESTPOOL2 $filedev "" | ||
done | ||
cleanup | ||
((i = i + 1)) | ||
done | ||
|
||
log_pass "'zpool split' can use the provided devices to split the pool" |
58 changes: 58 additions & 0 deletions
58
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_encryption.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright 2018, loli10K <[email protected]>. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# 'zpool split' should be able to split encrypted pools | ||
# | ||
# STRATEGY: | ||
# 1. Create an encrypted pool | ||
# 2. Split and re-import the pool, verify altroot is mounted. | ||
# | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
destroy_pool $TESTPOOL | ||
destroy_pool $TESTPOOL2 | ||
rm -f $DEVICE1 $DEVICE2 | ||
} | ||
|
||
log_assert "'zpool split' should be able to split encrypted pools" | ||
log_onexit cleanup | ||
|
||
DEVICE1="$TEST_BASE_DIR/device-1" | ||
DEVICE2="$TEST_BASE_DIR/device-2" | ||
passphrase="password" | ||
altroot="$TESTDIR/zpool-split-$RANDOM" | ||
|
||
# 1. Create an encrypted pool | ||
truncate -s $SPA_MINDEVSIZE $DEVICE1 | ||
truncate -s $SPA_MINDEVSIZE $DEVICE2 | ||
log_must eval "echo "$passphrase" | zpool create -O encryption=aes-256-ccm " \ | ||
"-O keyformat=passphrase $TESTPOOL mirror $DEVICE1 $DEVICE2" | ||
|
||
# 2. Split and re-import the pool, verify altroot is mounted. | ||
log_must eval "echo "$passphrase" | zpool split -l -R $altroot " \ | ||
"$TESTPOOL $TESTPOOL2" | ||
log_must test "$(get_prop 'encryption' $TESTPOOL2)" == "aes-256-ccm" | ||
log_must test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot" | ||
log_must mounted $altroot/$TESTPOOL2 | ||
|
||
log_pass "'zpool split' can split encrypted pools" |
Oops, something went wrong.