]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh
Add missing MMP status code to libzfs_status
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / zpool_import_errata3.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 # 'zpool import' should import a pool with Errata #3 while preventing
26 # the user from performing read write operations
27 #
28 # STRATEGY:
29 # 1. Import a pre-packaged pool with Errata #3
30 # 2. Attempt to write to the effected datasets
31 # 3. Attempt to read from the effected datasets
32 # 4. Attempt to perform a raw send of the effected datasets
33 # 5. Perform a regular send of the datasets under a new encryption root
34 # 6. Verify the new datasets can be read from and written to
35 # 7. Destroy the old effected datasets
36 # 8. Reimport the pool and verify that the errata is no longer present
37 #
38
39 verify_runnable "global"
40
41 POOL_NAME=cryptv0
42 POOL_FILE=cryptv0.dat
43
44 function uncompress_pool
45 {
46         log_note "Creating pool from $POOL_FILE"
47         log_must bzcat \
48             $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \
49             > /$TESTPOOL/$POOL_FILE
50         return 0
51 }
52
53 function cleanup
54 {
55         poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME
56         [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE
57         return 0
58 }
59 log_onexit cleanup
60
61 log_assert "Verify that Errata 3 is properly handled"
62
63 uncompress_pool
64 log_must zpool import -d /$TESTPOOL/ $POOL_NAME
65 log_must eval "zpool status $POOL_NAME | grep -q Errata"
66 log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER"
67 log_must eval "echo 'password' | zfs load-key $POOL_NAME/testfs"
68 log_must eval "echo 'password' | zfs load-key $POOL_NAME/testvol"
69
70 log_mustnot zfs mount $POOL_NAME/testfs
71 log_must zfs mount -o ro $POOL_NAME/testfs
72
73 old_mntpnt=$(get_prop mountpoint $POOL_NAME/testfs)
74 log_must eval "ls $old_mntpnt | grep -q testfile"
75 block_device_wait
76 log_mustnot dd if=/dev/zero of=/dev/zvol/$POOL_NAME/testvol bs=512 count=1
77 log_must dd if=/dev/zvol/$POOL_NAME/testvol of=/dev/null bs=512 count=1
78 log_must eval "echo 'password' | zfs create \
79         -o encryption=on -o keyformat=passphrase -o keylocation=prompt \
80         cryptv0/encroot"
81 log_mustnot eval "zfs send -w $POOL_NAME/testfs@snap1 | \
82         zfs recv $POOL_NAME/encroot/testfs"
83 log_mustnot eval "zfs send -w $POOL_NAME/testvol@snap1 | \
84         zfs recv $POOL_NAME/encroot/testvol"
85
86 log_must eval "zfs send $POOL_NAME/testfs@snap1 | \
87         zfs recv $POOL_NAME/encroot/testfs"
88 log_must eval "zfs send $POOL_NAME/testvol@snap1 | \
89         zfs recv $POOL_NAME/encroot/testvol"
90 block_device_wait
91 log_must dd if=/dev/zero of=/dev/zvol/$POOL_NAME/encroot/testvol bs=512 count=1
92 new_mntpnt=$(get_prop mountpoint $POOL_NAME/encroot/testfs)
93 log_must eval "ls $new_mntpnt | grep -q testfile"
94 log_must zfs destroy -r $POOL_NAME/testfs
95 log_must zfs destroy -r $POOL_NAME/testvol
96
97 log_must zpool export $POOL_NAME
98 log_must zpool import -d /$TESTPOOL/ $POOL_NAME
99 log_mustnot eval "zpool status $POOL_NAME | grep -q Errata"
100 log_mustnot eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER"
101 log_pass "Errata 3 is properly handled"