Project

General

Profile

Bug #3901 ยป test.sh

Michael Keller, 2013-07-20 10:48 PM

 
1
#!/bin/bash
2

    
3
# usage ./test2.sh source-canmount target-canmount [target-childs]
4
# 
5
# notes:
6
# 
7
# - if source-canmount is noauto the source is mounted by the script
8
# 
9
# - failed means that the second receive ( transfer... -i @back-1 @back2 ) failed with 
10
# 
11
#   "cannot receive incremental stream: destination tank/data/dev-zfstool/test/b/a has been modified"
12
# 
13
# - even if the target is created with canmount=off or canmount=noauto the target datasets 
14
#   got mounted during the first zfs receive -F
15
# 
16
# 
17
# test results:
18
# 
19
# ./test.sh off     off                         => OK
20
# ./test.sh off     on                          => OK
21
# ./test.sh on      off                         => OK
22
# ./test.sh on      on                          => OK
23
# ./test.sh noauto  off                         => OK
24
# ./test.sh noauto  on                          => OK
25
# ./test.sh off     noauto                      => OK
26
# ./test.sh off     noauto                      => OK
27
# ./test.sh on      noauto                      => OK
28
# ./test.sh on      noauto                      => OK
29
# ./test.sh noauto  noauto                      => OK
30
# ./test.sh noauto  noauto                      => OK
31
# ./test.sh off     off     target-childs       => OK
32
# ./test.sh off     on      target-childs       => OK
33
# ./test.sh off     noauto  target-childs       => OK
34
# ./test.sh off     noauto  target-childs       => OK
35
# ./test.sh on      off     target-childs       => failed
36
# ./test.sh on      on      target-childs       => failed
37
# ./test.sh noauto  off     target-childs       => failed
38
# ./test.sh noauto  on      target-childs       => failed
39
# ./test.sh on      noauto  target-childs       => failed
40
# ./test.sh on      noauto  target-childs       => failed
41
# ./test.sh noauto  noauto  target-childs       => failed
42
# ./test.sh noauto  noauto  target-childs       => failed
43
# 
44
# 
45

    
46
if [ $# -lt 2 ]; then
47
    echo "usage $0 source-canmount target-canmount [target-childs]" >&2
48
    exit 1
49
fi
50
    
51
echo "$0 $1 $2 $3"
52

    
53

    
54
ZFS=/usr/sbin/zfs
55
BASE=rpool/test
56
MP=/rpool/test
57

    
58
echo "prepare..."
59

    
60
OUT=`$ZFS list | grep $BASE/a`
61
if [ ! -z "$OUT" ]; then
62
    $ZFS destroy -r $BASE/a
63
    rm -R $MP/a
64
fi
65

    
66
OUT=`$ZFS list | grep $BASE/b`
67
if [ ! -z "$OUT" ]; then
68
    $ZFS destroy -r $BASE/b
69
    rm -R $MP/b
70
fi
71

    
72

    
73

    
74
echo "create..."
75

    
76
# source
77

    
78
$ZFS create -o canmount=$1 $BASE/a
79
if [ $1 == "noauto" ]; then
80
    echo "mounting source..."
81
    $ZFS mount $BASE/a
82
fi
83
$ZFS create $BASE/a/a
84
$ZFS create $BASE/a/a/a
85
$ZFS create $BASE/a/a/b
86
$ZFS create $BASE/a/b
87
$ZFS create $BASE/a/b/a
88
$ZFS create $BASE/a/b/b
89

    
90
# target
91

    
92
$ZFS create -o canmount=$2 $BASE/b
93

    
94
if [ ! -z "$3" ]; then
95
echo "creating target childs..."
96
$ZFS create $BASE/b/a
97
$ZFS create $BASE/b/a/a
98
$ZFS create $BASE/b/a/b
99
$ZFS create $BASE/b/b
100
$ZFS create $BASE/b/b/a
101
$ZFS create $BASE/b/b/b
102
fi
103

    
104
echo "snapshot @snap-1, @snap-2, @back-1..."
105

    
106
$ZFS snapshot -r $BASE/a@snap-1
107
$ZFS snapshot -r $BASE/a@snap-2
108
$ZFS snapshot -r $BASE/a@back-1
109

    
110

    
111
echo "transfer... @back-1"
112

    
113
$ZFS send -R $BASE/a@back-1 | $ZFS receive -F -e $BASE/b
114

    
115

    
116
echo "create... a/a/c"
117

    
118
$ZFS create $BASE/a/a/c
119

    
120

    
121
echo "snapshot @snap-3, @snap-4, @back-2..."
122

    
123
$ZFS snapshot -r $BASE/a@snap-3
124
$ZFS snapshot -r $BASE/a@snap-4
125
$ZFS snapshot -r $BASE/a@back-2
126

    
127

    
128
echo "transfer... -i @back-1 @back2"
129

    
130
$ZFS send -R -i $BASE/a@back-1 $BASE/a@back-2 | $ZFS receive -e $BASE/b
131
RESULT=$?
132

    
133
# list
134

    
135
echo
136

    
137
$ZFS list -t snapshot | grep $BASE/
138

    
139
echo "--------------------------------"
140
echo
141

    
142
exit $RESULT
143

    
144

    
145

    
    (1-1/1)