]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_encryption.ksh
Add 'zpool split' coverage to the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_split / zpool_split_encryption.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18
19 #
20 # DESCRIPTION:
21 # 'zpool split' should be able to split encrypted pools
22 #
23 # STRATEGY:
24 # 1. Create an encrypted pool
25 # 2. Split and re-import the pool, verify altroot is mounted.
26 #
27
28 verify_runnable "both"
29
30 function cleanup
31 {
32 destroy_pool $TESTPOOL
33 destroy_pool $TESTPOOL2
34 rm -f $DEVICE1 $DEVICE2
35 }
36
37 log_assert "'zpool split' should be able to split encrypted pools"
38 log_onexit cleanup
39
40 DEVICE1="$TEST_BASE_DIR/device-1"
41 DEVICE2="$TEST_BASE_DIR/device-2"
42 passphrase="password"
43 altroot="$TESTDIR/zpool-split-$RANDOM"
44
45 # 1. Create an encrypted pool
46 truncate -s $SPA_MINDEVSIZE $DEVICE1
47 truncate -s $SPA_MINDEVSIZE $DEVICE2
48 log_must eval "echo "$passphrase" | zpool create -O encryption=aes-256-ccm " \
49 "-O keyformat=passphrase $TESTPOOL mirror $DEVICE1 $DEVICE2"
50
51 # 2. Split and re-import the pool, verify altroot is mounted.
52 log_must eval "echo "$passphrase" | zpool split -l -R $altroot " \
53 "$TESTPOOL $TESTPOOL2"
54 log_must test "$(get_prop 'encryption' $TESTPOOL2)" == "aes-256-ccm"
55 log_must test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot"
56 log_must mounted $altroot/$TESTPOOL2
57
58 log_pass "'zpool split' can split encrypted pools"