Whamcloud - gitweb
LU-10488 tests: saved and restore layout for dom test
[fs/lustre-release.git] / lustre / tests / sanity-dom.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10 ALWAYS_EXCEPT="$SANITY_DOM_EXCEPT"
11 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13
14 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
15
16 . $LUSTRE/tests/test-framework.sh
17 CLEANUP=${CLEANUP:-:}
18 SETUP=${SETUP:-:}
19 init_test_env $@
20 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
21 init_logging
22
23 MULTIOP=${MULTIOP:-multiop}
24 OPENFILE=${OPENFILE:-openfile}
25 MOUNT_2=${MOUNT_2:-"yes"}
26 FAIL_ON_ERROR=false
27
28 check_and_setup_lustre
29
30 # $RUNAS_ID may get set incorrectly somewhere else
31 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
32         skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
33 fi
34 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
35
36 build_test_filter
37
38 DOM="yes"
39 DOM_SIZE=${DOM_SIZE:-"$((1024*1024))"}
40 OSC="mdc"
41
42 trap restore_default_layout EXIT
43 restore_default_layout() {
44         [ -n "$saved_layout" ] && restore_layout $DIR1 $saved_layout ||
45                 $LFS setstripe -d $DIR1
46 }
47
48 saved_layout=$(save_layout $DIR1)
49 $LFS setstripe -E $DOM_SIZE -L mdt -E EOF $DIR1
50
51 mkdir -p $MOUNT2
52 mount_client $MOUNT2
53
54 test_1() {
55         dd if=/dev/zero of=$DIR1/$tfile bs=7k count=1 || error "write 1"
56         $TRUNCATE $DIR2/$tfile 1000 || error "truncate"
57         dd if=/dev/zero of=$DIR1/$tfile bs=3k count=1 seek=1 || error "write 2"
58         $CHECKSTAT -t file -s 6144 $DIR2/$tfile || error "stat"
59         rm $DIR1/$tfile
60 }
61 run_test 1 "write a file on one mount, truncate on the other, write again"
62
63 test_2() {
64         SZ1=234852
65         dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4 || return 1
66         dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
67         dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=5 || return 3
68         $CHECKSTAT -t file -s $SZ1 $DIR/${tfile}_left ||
69                 error "Error reading at the end of the file $tfile"
70 }
71 run_test 2 "Write with a seek, append, read from a single mountpoint"
72
73 test_3() {
74         # Write on one node to the DoM stripe and then truncate to over DoM size
75         dd if=/dev/zero of=$DIR1/$tfile bs=$((DOM_SIZE-100)) count=1 ||
76                 return 1
77         truncate $DIR1/$tfile $((DOM_SIZE+700)) || return 2
78         # read on the second node inside DoM stripe to take a lock data from
79         # the first client
80         dd if=$DIR2/$tfile of=/dev/null bs=4096 count=1 seek=1 || return 3
81         $CHECKSTAT -t file -s $((DOM_SIZE+700)) $DIR2/$tfile ||
82                 error "Wrong size after first truncate $tfile on first node"
83         # now do local truncate over DoM size and check size is correct
84         truncate $DIR2/$tfile $((DOM_SIZE+500)) || return 4
85         $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR2/$tfile ||
86                 error "Wrong size after second truncate on the same node"
87         $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR1/$tfile ||
88                 error "Wrong size after second truncate on other node"
89 }
90 run_test 3 "Truncate over DoM size on different nodes"
91
92 test_fsx() {
93         local file1=$DIR1/$tfile
94         local file2=$DIR2/$tfile
95
96         touch $file1
97         fsx -c 50 -p 100 -N 1000 -l $((DOM_SIZE*2)) -S 0 -d -d $file1 $file2
98 }
99 run_test fsx "Dual-mount fsx with DoM files"
100
101 test_sanity()
102 {
103         local SAVE_ONLY=$ONLY
104
105         [ ! -f sanity.sh ] && skip_env "No sanity.sh skipping" && return
106         # XXX: to fix 45
107         ONLY="36 39 40 41 42 43 46 56r 101e 119a 131 150 155a 155b 155c \
108                 155d 207 241 251" OSC="mdc" DOM="yes" sh sanity.sh
109         ONLY=$SAVE_ONLY
110 }
111 run_test sanity "Run sanity with Data-on-MDT files"
112
113 test_sanityn()
114 {
115         local SAVE_ONLY=$ONLY
116
117         [ ! -f sanity.sh ] && skip_env "No sanity.sh skipping" && return
118         # XXX: to fix 60
119         ONLY="1 2 4 5 6 7 8 9 10 11 12 14 17 19 20 23 27 39 51a 51c 51d" \
120                 OSC="mdc" DOM="yes" sh sanityn.sh
121         ONLY=$SAVE_ONLY
122 }
123 run_test sanityn "Run sanityn with Data-on-MDT files"
124
125 complete $SECONDS
126 check_and_cleanup_lustre
127 exit_status