]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_scrub / zpool_scrub_encrypted_unloaded.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
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 # CDDL HEADER END
15 #
16
17 #
18 # Copyright (c) 2017 Datto, Inc. All rights reserved.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 # Scrubs must work on an encrypted dataset with an unloaded key.
26 #
27 # STRATEGY:
28 # 1. Create an encrypted dataset
29 # 2. Generate data on the dataset
30 # 3. Unmount the encrypted dataset and unload its key
31 # 4. Start a scrub
32 # 5. Wait for the scrub to complete
33 # 6. Verify the scrub had no errors
34 # 7. Load the dataset key and mount it
35 #
36
37 verify_runnable "global"
38
39 function cleanup
40 {
41         datasetexists $TESTPOOL/$TESTFS2 && \
42                 log_must zfs destroy $TESTPOOL/$TESTFS2
43 }
44 log_onexit cleanup
45
46 log_assert "Scrubs must work on an encrypted dataset with an unloaded key"
47
48 log_must eval "echo 'password' | zfs create -o encryption=on" \
49         "-o keyformat=passphrase $TESTPOOL/$TESTFS2"
50
51 typeset mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS2)
52 log_must mkfile 10m $mntpnt/file1
53
54 for i in 2..10; do
55         log_must mkfile 512b $mntpnt/file$i
56 done
57
58 log_must zfs unmount $TESTPOOL/$TESTFS2
59 log_must zfs unload-key $TESTPOOL/$TESTFS2
60
61 log_must zpool scrub -w $TESTPOOL
62
63 log_must check_pool_status $TESTPOOL "scan" "with 0 errors"
64
65 log_must eval "echo 'password' | zfs mount -l $TESTPOOL/$TESTFS2"
66
67 log_pass "Scrubs work on an encrypted dataset with an unloaded key"