Whamcloud - gitweb
LU-15 slow IO with read intense application
[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 lst_SERVERS=${lst_SERVERS:-$(comma_list $(osts_nodes) $mds_HOST)}
30 lst_CLIENTS=${lst_CLIENTS:-${CLIENTS:-`hostname`}}
31
32 is_mounted () {
33     local mntpt=$1
34     local mounted=$(mounted_lustre_filesystems)
35     echo $mounted' ' | grep -w -q $mntpt' '
36 }
37
38 if local_mode; then
39    lst_SERVERS=`hostname`
40    lst_CLIENTS=`hostname`
41 fi
42
43 # FIXME: do we really need to unload lustre modules on all nodes?
44 # bug 19387, comment 9
45 # unloading lustre modules is not strictly necessary but unmounting
46 # /mnt/lustre before running lst would be useful:
47 # 1) because lustre messages clutter logs - we needn't them for testing LNET
48 # 2) it's theoretically possible that lst tests congest comm paths so tightly
49 # that mounted lustre wouldn't able to perform some of its background activities
50 if is_mounted $MOUNT || is_mounted $MOUNT2; then
51     local_mode && CLIENTONLY=yes
52     stopall
53     RESTORE_MOUNT=yes
54 fi
55
56 build_test_filter
57
58 lst_prepare () {
59     # Workaround for bug 15619
60     lst_cleanup_all
61     lst_setup_all
62 }
63
64 # make batch
65 test_smoke_sub () {
66     local servers=$1
67     local clients=$2
68
69
70     local nc=$(echo ${clients//,/ } | wc -w)
71     local ns=$(echo ${servers//,/ } | wc -w)
72     echo '#!/bin/bash'
73     echo 'set -e'
74
75     echo 'cleanup () { trap 0; echo killing $1 ... ; kill -9 $1 || true; }'
76
77     echo "$LST new_session --timeo 100000 hh"
78     echo "$LST add_group c $(nids_list $clients)"
79     echo "$LST add_group s $(nids_list $servers)"
80     echo "$LST add_batch b"
81
82     pre="$LST add_test --batch b --loop $lst_LOOP "
83     for t in "brw read" "brw write" ; do
84         for s in $lst_SIZES; do
85             for c in $lst_CONCR; do
86                 for d in "${nc}:${ns} --from c --to s" "${ns}:${nc} --from s --to c"; do
87                     echo -n "$pre"
88                     echo " --concurrency $c --distribute $d $t check=full size=$s"
89                  done
90             done
91         done
92     done
93
94     for c in $lst_CONCR; do
95         for d in "${nc}:${ns} --from c --to s" "${ns}:${nc} --from s --to c"; do
96             echo -n "$pre"
97             echo " --concurrency $c --distribute $d ping "
98         done
99     done
100
101     echo $LST run b
102     echo sleep 1
103     echo "$LST stat --delay 10 --timeout 10 c s &"
104     echo 'pid=$!'
105     echo 'trap "cleanup $pid" INT TERM'
106     echo sleep $smoke_DURATION
107     echo 'cleanup $pid'
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 }
153 run_test smoke "lst regression test"
154
155 complete $(basename $0) $SECONDS
156 if [ "$RESTORE_MOUNT" = yes ]; then
157     setupall
158 fi
159 exit_status