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