Print this page
XXX Remove nawk(1)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh
1 1 #!/bin/ksh
2 2 #
3 3 # This file and its contents are supplied under the terms of the
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 5 # You may only use this file in accordance with the terms of version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy of the CDDL is also available via the Internet at
10 10 # http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 14 # Copyright (c) 2012 by Delphix. All rights reserved.
15 15 #
16 16
17 17 #
18 18 # DESCRIPTION
19 19 # verify 'zfs snapshot <list of snapshots>' works correctly
20 20 #
21 21 # STRATEGY
22 22 # 1. Create multiple datasets
23 23 # 2. Create mutiple snapshots with a list of valid and invalid
24 24 # snapshot names
25 25 # 3. Verify the valid snpashot creation
26 26
27 27 . $STF_SUITE/include/libtest.shlib
28 28
29 29 function cleanup
30 30 {
31 31 for ds in $datasets; do
32 32 datasetexists $ds && log_must $ZFS destroy -r $ds
33 33 done
34 34 $ZFS destroy -r $TESTPOOL/TESTFS4
35 35 }
36 36 datasets="$TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS2
37 37 $TESTPOOL/$TESTFS3"
38 38
39 39 invalid_args=("$TESTPOOL/$TESTFS1@now $TESTPOOL/$TESTFS2@now \
40 40 $TESTPOOL/$TESTFS@blah?" "$TESTPOOL/$TESTFS1@blah* \
41 41 $TESTPOOL/$TESTFS2@blah? $TESTPOOL/$TESTFS3@blah%" \
42 42 "$TESTPOOL/$TESTFS1@$($PYTHON -c 'print "x" * 300') $TESTPOOL/$TESTFS2@300 \
43 43 $TESTPOOL/$TESTFS3@300")
44 44
45 45 valid_args=("$TESTPOOL/$TESTFS1@snap $TESTPOOL/$TESTFS2@snap \
46 46 $TESTPOOL/$TESTFS3@snap" "$TESTPOOL/$TESTFS1@$($PYTHON -c 'print "x" * 200')\
47 47 $TESTPOOL/$TESTFS2@2 $TESTPOOL/$TESTFS3@s")
48 48
49 49 log_assert "verify zfs supports multiple consistent snapshots"
50 50 log_onexit cleanup
51 51 typeset -i i=1
52 52 test_data=$STF_SUITE/tests/functional/cli_root/zpool_upgrade/blockfiles
53 53
54 54 log_note "destroy a list of valid snapshots"
55 55 for ds in $datasets; do
56 56 log_must $ZFS create $ds
57 57 log_must $CP -r $test_data /$ds
58 58 done
59 59 i=0
60 60 while (( i < ${#valid_args[*]} )); do
61 61 log_must $ZFS snapshot ${valid_args[i]}
62 62 for token in ${valid_args[i]}; do
63 63 log_must snapexists $token && \
64 64 log_must $ZFS destroy $token
65 65 done
66 66 ((i = i + 1))
67 67 done
68 68 log_note "destroy a list of invalid snapshots"
69 69 i=0
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
70 70 while (( i < ${#invalid_args[*]} )); do
71 71 log_mustnot $ZFS snapshot ${invalid_args[i]}
72 72 for token in ${invalid_args[i]}; do
73 73 log_mustnot snapexists $token
74 74 done
75 75 ((i = i + 1))
76 76 done
77 77 log_note "verify multiple snapshot transaction group"
78 78 txg_group=$($ZDB -Pd $TESTPOOL | $GREP snap | $AWK '{print $7}')
79 79 for i in 1 2 3; do
80 - txg_tag=$($ECHO "$txg_group" | $NAWK -v j=$i 'FNR == j {print}')
80 + txg_tag=$($ECHO "$txg_group" | $AWK -v j=$i 'FNR == j {print}')
81 81 [[ $txg_tag != $($ECHO "$txg_group" | \
82 - $NAWK -v j=$i 'FNR == j {print}') ]] \
82 + $AWK -v j=$i 'FNR == j {print}') ]] \
83 83 && log_fail "snapshots belong to differnt transaction groups"
84 84 done
85 85 log_note "verify snapshot contents"
86 86 for ds in $datasets; do
87 87 status=$($DIRCMP /$ds /$ds/.zfs/snapshot/snap | $GREP "different")
88 88 [[ -z $status ]] || log_fail "snapshot contents are different from" \
89 89 "the filesystem"
90 90 done
91 91
92 92 log_note "verify multiple snapshot with -r option"
93 93 log_must $ZFS create $TESTPOOL/TESTFS4
94 94 log_must $ZFS create -p $TESTPOOL/$TESTFS3/TESTFSA$($PYTHON -c 'print "x" * 210')/TESTFSB
95 95 log_mustnot $ZFS snapshot -r $TESTPOOL/$TESTFS1@snap1 $TESTPOOL/$TESTFS2@snap1 \
96 96 $TESTPOOL/$TESTFS3@snap1 $TESTPOOL/TESTFS4@snap1
97 97 log_must $ZFS rename $TESTPOOL/$TESTFS3/TESTFSA$($PYTHON -c 'print "x" * 210') \
98 98 $TESTPOOL/$TESTFS3/TESTFSA
99 99 log_must $ZFS snapshot -r $TESTPOOL/$TESTFS1@snap1 $TESTPOOL/$TESTFS2@snap1 \
100 100 $TESTPOOL/$TESTFS3@snap1 $TESTPOOL/TESTFS4@snap1
101 101
102 102 log_pass "zfs multiple snapshot verified correctly"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX