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