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