blob: 7cf6c4bc12fb11e870633b2ea88a3961df636952 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#!/bin/bash
BASETANK="share"
DATE=`date "+%Y%m%d"`
TEST_SMBFS=0
TEST_DESTROY=0
if [ -z "$1" ]; then
echo "Usage: `basename $0` [unpack]<[smbfs][snapshot][all]>"
exit 1
fi
set_onoff() {
type="$1"
dataset="$2"
toggle="$3"
current=`zfs get -H $type -o value $dataset`
if [ "$current" != "$toggle" ]; then
run "zfs set $type=$toggle $dataset"
fi
}
check_exists() {
dataset="$1"
extra=""
[ -n "$2" ] && extra="$2"
zfs get all "$dataset" > /dev/null 2>&1
if [ $? != 0 ]; then
run "zfs create $extra $dataset"
fi
}
check_shares() {
if [ "$TEST_SMBFS" == "1" ]; then
echo "Shares:"
echo "=> usershare list:"
net usershare list
echo
echo "=> /etc/dfs/sharetab:"
cat /etc/dfs/sharetab
echo
fi
sleep 2
}
test_header() {
echo "TEST: $*"
echo "======================================"
}
run() {
cmd="$*"
echo "CMD: $cmd"
$cmd
}
# ---------
# Needs more work...
if echo "$*" | grep -qi "unpack"; then
zfs unmount -a
zfs unshare -a
run "zfs destroy -r $BASETANK/tests"
sh /etc/init.d/zfs stop
# for tid in `grep ^tid /proc/net/iet/volume | sed "s@.*:\([0-9].*\) name.*@\1@"`
# do
# ietadm --op delete --tid $tid
# done
set -e
rmmod `lsmod | grep ^z | grep -v zlib_deflate | sed 's@ .*@@'` spl zlib_deflate
pushd / > /dev/null
[ -f "tmp/zfs.tgz" ] && tar xzf tmp/zfs.tgz && rm tmp/zfs.tgz
[ -f "tmp/spl.tgz" ] && tar xzf tmp/spl.tgz && rm tmp/spl.tgz
popd > /dev/null
depmod -a
sh /etc/init.d/zfs start
set +e
fi
# ---------
if echo "$*" | egrep -qi "smbfs|all"; then
check_exists $BASETANK/tests
TEST_SMBFS=1
test_header "Exists || Create"
str=
for volnr in 1 2 3; do
check_exists $BASETANK/tests/smbfs$volnr
str="$str $BASETANK/tests/smbfs$volnr"
done
run "zfs get sharesmb $str"
# Set sharesmb=on
test_header "Enable SMB share"
for volnr in 1 2 3; do
set_onoff sharesmb "$BASETANK/tests/smbfs$volnr" on
check_shares
done
# Share all
test_header "Share all (individually)"
for volnr in 1 2 3; do
run "zfs share $BASETANK/tests/smbfs$volnr"
check_shares
done
# Unshare all
test_header "Unshare all (individually)"
for volnr in 1 2 3; do
run "zfs unshare $BASETANK/tests/smbfs$volnr"
check_shares
done
# Change mountpoint - first unshare and then share individual
test_header "Change mount point (unshare ; share)"
mkdir -p /tests
set_onoff sharesmb "$str" off
for volnr in 3 1 2; do
run "zfs set mountpoint=/tests/smbfs$volnr $BASETANK/tests/smbfs$volnr"
echo "CMD: mount | grep ^$BASETANK/tests/smbfs$volnr"
mount | grep ^$BASETANK/tests/smbfs$volnr
echo
run "zfs mount $BASETANK/tests/smbfs$volnr"
echo "CMD: mount | grep ^$BASETANK/tests/smbfs$volnr"
mount | grep ^$BASETANK/tests/smbfs$volnr
echo
set_onoff sharesmb "$BASETANK/tests/smbfs$volnr" on
check_shares
run "zfs share $BASETANK/tests/smbfs$volnr"
check_shares
echo "-------------------"
done
# Change mountpoint - remounting
test_header "Change mount point (remounting)"
for volnr in 3 1 2; do
run "zfs set mountpoint=/$BASETANK/tests/smbfs$volnr $BASETANK/tests/smbfs$volnr"
echo "CMD: mount | grep ^$BASETANK/tests/smbfs$volnr"
mount | grep ^$BASETANK/tests/smbfs$volnr
echo
# => Doesn't seem to remount (!?)
run "zfs mount $BASETANK/tests/smbfs$volnr"
echo "CMD: mount | grep ^$BASETANK/tests/smbfs$volnr"
mount | grep ^$BASETANK/tests/smbfs$volnr
echo
# => Doesn't seem to reshare (!?)
check_shares
run "zfs share $BASETANK/tests/smbfs$volnr"
check_shares
echo "-------------------"
done
fi
# ---------
if echo "$*" | egrep -qi "smbfs|all"; then
test_header "Unshare + Share all"
run "zfs share -a" ; check_shares
run "zfs unshare -a" ; check_shares
fi
# ---------
if echo "$*" | grep -qi "snapshot|all"; then
test_header "Snapshots"
echo ; echo "-------------------"
check_exists $BASETANK/tests/destroy
check_exists $BASETANK/tests/destroy/destroy1
run "zfs destroy -r $BASETANK/tests/destroy"
echo ; echo "-------------------"
check_exists $BASETANK/tests/destroy
run "zfs snapshot $BASETANK/tests/destroy@$DATE"
run "zfs destroy -r $BASETANK/tests/destroy"
echo ; echo "-------------------"
check_exists $BASETANK/tests/destroy
run "zfs snapshot $BASETANK/tests/destroy@$DATE"
run "zfs destroy -r $BASETANK/tests/destroy@$DATE"
run "zfs destroy -r $BASETANK/tests/destroy"
fi
if echo "$*" | egrep -qi "smbfs|snapshot|all"; then
test_header "Cleanup (Share all + Destroy all)"
run "zfs share -a"
check_shares
run "zfs destroy -r $BASETANK/tests"
check_shares
run "zfs list"
fi
|