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