]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/mmp/mmp_hostid.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / mmp / mmp_hostid.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) 2019 by Lawrence Livermore National Security, LLC.
19 #
20
21 # DESCRIPTION:
22 #       Verify the hostid file can reside on a ZFS dataset.
23 #
24 # STRATEGY:
25 #       1. Create a non-redundant pool
26 #       2. Create an 'etc' dataset containing a valid hostid file
27 #       3. Create a file so the pool will have some contents
28 #       4. Verify multihost cannot be enabled until the /etc/hostid is linked
29 #       5. Verify vdevs may be attached and detached
30 #       6. Verify normal, cache, log and special vdevs can be added
31 #       7. Verify normal, cache, and log vdevs can be removed
32 #
33
34 . $STF_SUITE/include/libtest.shlib
35 . $STF_SUITE/tests/functional/mmp/mmp.cfg
36 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
37
38 verify_runnable "both"
39
40 function cleanup
41 {
42         default_cleanup_noexit
43         log_must rm $MMP_DIR/file.{0,1,2,3,4,5}
44         log_must rmdir $MMP_DIR
45         log_must mmp_clear_hostid
46         if [[ -L $HOSTID_FILE ]]; then
47                 rm -f $HOSTID_FILE
48         fi
49 }
50
51 log_assert "Verify hostid file can reside on a ZFS dataset"
52 log_onexit cleanup
53
54 log_must mkdir -p $MMP_DIR
55 log_must truncate -s $MINVDEVSIZE $MMP_DIR/file.{0,1,2,3,4,5}
56
57 # 1. Create a non-redundant pool
58 log_must zpool create $MMP_POOL $MMP_DIR/file.0
59
60 # 2. Create an 'etc' dataset containing a valid hostid file; caching is
61 #    disabled on the dataset to force the hostid to be read from disk.
62 log_must zfs create -o primarycache=none -o secondarycache=none $MMP_POOL/etc
63 mntpnt_etc=$(get_prop mountpoint $MMP_POOL/etc)
64 log_must mmp_set_hostid $HOSTID1
65 log_must mv $HOSTID_FILE $mntpnt_etc/hostid
66
67 # 3. Create a file so the pool will have some contents
68 log_must zfs create $MMP_POOL/fs
69 mntpnt_fs=$(get_prop mountpoint $MMP_POOL/fs)
70 log_must mkfile 1M $mntpnt_fs/file
71
72 # 4. Verify multihost cannot be enabled until the /etc/hostid is linked
73 log_mustnot zpool set multihost=on $MMP_POOL
74 log_mustnot ls -l $HOSTID_FILE
75 log_must ln -s $mntpnt_etc/hostid $HOSTID_FILE
76 log_must zpool set multihost=on $MMP_POOL
77
78 # 5. Verify vdevs may be attached and detached
79 log_must zpool attach $MMP_POOL $MMP_DIR/file.0 $MMP_DIR/file.1
80 log_must zpool detach $MMP_POOL $MMP_DIR/file.1
81
82 # 6. Verify normal, cache, log and special vdevs can be added
83 log_must zpool add $MMP_POOL $MMP_DIR/file.1
84 log_must zpool add $MMP_POOL $MMP_DIR/file.2
85 log_must zpool add $MMP_POOL cache $MMP_DIR/file.3
86 log_must zpool add $MMP_POOL log $MMP_DIR/file.4
87 log_must zpool add $MMP_POOL special $MMP_DIR/file.5
88
89 # 7. Verify normal, cache, and log vdevs can be removed
90 log_must zpool remove $MMP_POOL $MMP_DIR/file.2
91 log_must zpool remove $MMP_POOL $MMP_DIR/file.3
92 log_must zpool remove $MMP_POOL $MMP_DIR/file.4
93
94 log_pass "Verify hostid file can reside on a ZFS dataset."