Whamcloud - gitweb
LU-10467 lfsck: use wait_event_idle()
[fs/lustre-release.git] / lustre / tests / lnet-selftest.sh
1 #!/bin/bash
2
3 LUSTRE=${LUSTRE:-$(dirname $0)/..}
4 . $LUSTRE/tests/test-framework.sh
5 init_test_env $@
6 init_logging
7
8 ALWAYS_EXCEPT="$LNET_SELFTEST_EXCEPT"
9 if (( $LINUX_VERSION_CODE >= $(version_code 4.4.0) )); then
10         # bug number for skipped test: LU-10073
11         ALWAYS_EXCEPT+="               smoke "
12 fi
13
14 if [[ $(uname -m) = ppc64 ]]; then
15         # bug number for skipped test: LU-10073
16         ALWAYS_EXCEPT+="               smoke "
17 fi
18
19 build_test_filter
20
21 [ x$LST = x ] && skip_env "lst not found LST=$LST"
22
23 # FIXME: what is the reasonable value here?
24 lst_LOOP=${lst_LOOP:-100000}
25 lst_CONCR=${lst_CONCR:-"1 2 4 8"}
26 lst_SIZES=${lst_SIZES:-"4k 8k 256k 1M"}
27 if [ "$SLOW" = no ]; then
28     lst_CONCR="1 8"
29     lst_SIZES="4k 1M"
30     lst_LOOP=1000
31 fi
32
33 smoke_DURATION=${smoke_DURATION:-1800}
34 if [ "$SLOW" = no ]; then
35     [ $smoke_DURATION -le 300 ] || smoke_DURATION=300
36 fi
37
38 nodes=$(comma_list "$(osts_nodes) $(mdts_nodes)")
39 lst_SERVERS=${lst_SERVERS:-$(comma_list "$(host_nids_address $nodes $NETTYPE)")}
40 lst_CLIENTS=${lst_CLIENTS:-$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")}
41 interim_umount=false
42 interim_umount1=false
43
44 #
45 # _restore_mount(): This function calls restore_mount function for "MOUNT" and
46 # "MOUNT2" paths to mount clients if they were not mounted and were umounted
47 # in this file earlier.
48 # Parameter: None
49 # Returns: None. Exit with error if client mount fails.
50 #
51 _restore_mount () {
52         if $interim_umount && ! is_mounted $MOUNT; then
53                 restore_mount $MOUNT || error "Restore $MOUNT failed"
54         fi
55
56         if $interim_umount1 && ! is_mounted $MOUNT2; then
57                 restore_mount $MOUNT2 || error "Restore $MOUNT2 failed"
58         fi
59 }
60
61 if local_mode; then
62    lst_SERVERS=`hostname`
63    lst_CLIENTS=`hostname`
64 fi
65
66 # FIXME: do we really need to unload lustre modules on all nodes?
67 # bug 19387, comment 9
68 # unloading lustre modules is not strictly necessary but unmounting
69 # /mnt/lustre before running lst would be useful:
70 # 1) because lustre messages clutter logs - we needn't them for testing LNET
71 # 2) it's theoretically possible that lst tests congest comm paths so tightly
72 # that mounted lustre wouldn't able to perform some of its background activities
73 if is_mounted $MOUNT; then
74         cleanup_mount $MOUNT || error "Fail to unmount client $MOUNT"
75         interim_umount=true
76 fi
77
78 if is_mounted $MOUNT2; then
79         cleanup_mount $MOUNT2 || error "Fail to unmount client $MOUNT2"
80         interim_umount1=true
81 fi
82
83 lst_prepare () {
84     # Workaround for bug 15619
85     lst_cleanup_all
86     lst_setup_all
87 }
88
89 # make batch
90 test_smoke_sub () {
91     local servers=$1
92     local clients=$2
93
94
95     local nc=$(echo ${clients//,/ } | wc -w)
96     local ns=$(echo ${servers//,/ } | wc -w)
97     echo '#!/bin/bash'
98     echo 'set -e'
99
100     echo 'cleanup () { trap 0; echo killing $1 ... ; kill -9 $1 || true; }'
101
102     echo "$LST new_session --timeo 100000 hh"
103     echo "$LST add_group c $(nids_list $clients)"
104     echo "$LST add_group s $(nids_list $servers)"
105     echo "$LST add_batch b"
106
107     pre="$LST add_test --batch b --loop $lst_LOOP "
108     for t in "brw read" "brw write" ; do
109         for s in $lst_SIZES; do
110             for c in $lst_CONCR; do
111                 for d in "${nc}:${ns} --from c --to s" "${ns}:${nc} --from s --to c"; do
112                     echo -n "$pre"
113                     echo " --concurrency $c --distribute $d $t check=full size=$s"
114                  done
115             done
116         done
117     done
118
119     for c in $lst_CONCR; do
120         for d in "${nc}:${ns} --from c --to s" "${ns}:${nc} --from s --to c"; do
121             echo -n "$pre"
122             echo " --concurrency $c --distribute $d ping "
123         done
124     done
125
126     echo $LST run b
127     echo sleep 1
128     echo "$LST stat --delay 10 --timeout 10 c s &"
129     echo 'pid=$!'
130     echo 'trap "cleanup $pid" INT TERM'
131     echo sleep $smoke_DURATION
132     echo 'cleanup $pid'
133     
134 }
135
136 run_lst () {
137    local file=$1
138
139    export LST_SESSION=$$
140
141    # start lst
142    sh $file
143 }
144
145 check_lst_err () {
146         local log=$1
147
148         grep ^Total $log
149
150         if awk '/^Total.*nodes/ {print $2}' $log | grep -vq '^0$'; then
151                 _restore_mount
152                 error 'lst Error found'
153         fi
154 }
155
156 test_smoke () {
157         lst_prepare
158
159         local servers=$lst_SERVERS
160         local clients=$lst_CLIENTS
161
162         local runlst=$TMP/smoke.sh
163
164         local log=$TMP/$tfile.log
165         local rc=0
166
167         test_smoke_sub $servers $clients 2>&1 > $runlst
168
169         cat $runlst
170
171         run_lst $runlst | tee $log
172         rc=${PIPESTATUS[0]}
173         [ $rc = 0 ] || { _restore_mount; error "$runlst failed: $rc"; }
174
175         lst_end_session --verbose | tee -a $log
176
177         # error counters in "lst show_error" should be checked
178         check_lst_err $log
179         lst_cleanup_all
180 }
181 run_test smoke "lst regression test"
182
183 complete $SECONDS
184 _restore_mount
185 check_and_cleanup_lustre
186 exit_status