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